Renames in Frontend

This commit is contained in:
Qstick
2020-05-15 23:32:52 -04:00
committed by ta264
parent ee4e44b81a
commit ee43ccf620
387 changed files with 4036 additions and 4364 deletions
@@ -0,0 +1,31 @@
import PropTypes from 'prop-types';
import React from 'react';
import Modal from 'Components/Modal/Modal';
import AddNewBookModalContentConnector from './AddNewBookModalContentConnector';
function AddNewBookModal(props) {
const {
isOpen,
onModalClose,
...otherProps
} = props;
return (
<Modal
isOpen={isOpen}
onModalClose={onModalClose}
>
<AddNewBookModalContentConnector
{...otherProps}
onModalClose={onModalClose}
/>
</Modal>
);
}
AddNewBookModal.propTypes = {
isOpen: PropTypes.bool.isRequired,
onModalClose: PropTypes.func.isRequired
};
export default AddNewBookModal;
@@ -0,0 +1,126 @@
.container {
display: flex;
}
.poster {
flex: 0 0 170px;
margin-right: 20px;
height: 250px;
}
.info {
flex-grow: 1;
}
.name {
font-weight: 300;
font-size: 36px;
}
.authorName {
margin-bottom: 20px;
font-weight: 300;
font-size: 20px;
}
.disambiguation {
margin-bottom: 20px;
color: $disabledColor;
font-weight: 300;
font-size: 20px;
}
.overview {
margin-bottom: 30px;
max-height: 230px;
text-align: justify;
}
.header {
position: relative;
display: flex;
align-items: center;
margin-top: 5px;
margin-bottom: 5px;
width: 100%;
font-size: 24px;
cursor: pointer;
}
.left {
display: flex;
align-items: center;
flex: 0 1 300px;
}
.bookType {
margin-bottom: 20px;
border: 1px solid $borderColor;
border-radius: 4px;
background-color: $white;
&:last-of-type {
margin-bottom: 0;
}
}
.bookTypeLabel {
margin-right: 5px;
margin-left: 5px;
}
.bookCount {
color: #8895aa;
font-style: italic;
font-size: 18px;
}
.expandButton {
composes: link from '~Components/Link/Link.css';
flex-grow: 1;
width: 100%;
text-align: center;
}
.searchForNewBookLabelContainer {
display: flex;
margin-top: 2px;
}
.searchForNewBookLabel {
margin-right: 8px;
font-weight: normal;
}
.searchForNewBookContainer {
composes: container from '~Components/Form/CheckInput.css';
flex: 0 1 0;
}
.searchForNewBookInput {
composes: input from '~Components/Form/CheckInput.css';
margin-top: 0;
}
.modalFooter {
composes: modalFooter from '~Components/Modal/ModalFooter.css';
}
.addButton {
@add-mixin truncate;
composes: button from '~Components/Link/SpinnerButton.css';
}
@media only screen and (max-width: $breakpointSmall) {
.modalFooter {
display: block;
text-align: center;
}
.addButton {
margin-top: 10px;
}
}
@@ -0,0 +1,157 @@
import PropTypes from 'prop-types';
import React, { Component } from 'react';
import TextTruncate from 'react-text-truncate';
import { kinds } from 'Helpers/Props';
import SpinnerButton from 'Components/Link/SpinnerButton';
import CheckInput from 'Components/Form/CheckInput';
import ModalContent from 'Components/Modal/ModalContent';
import ModalHeader from 'Components/Modal/ModalHeader';
import ModalBody from 'Components/Modal/ModalBody';
import ModalFooter from 'Components/Modal/ModalFooter';
import BookCover from 'Book/BookCover';
import AddAuthorOptionsForm from '../Common/AddAuthorOptionsForm.js';
import styles from './AddNewBookModalContent.css';
class AddNewBookModalContent extends Component {
//
// Lifecycle
constructor(props, context) {
super(props, context);
this.state = {
searchForNewBook: false
};
}
//
// Listeners
onSearchForNewBookChange = ({ value }) => {
this.setState({ searchForNewBook: value });
}
onAddBookPress = () => {
this.props.onAddBookPress(this.state.searchForNewBook);
}
//
// Render
render() {
const {
bookTitle,
authorName,
disambiguation,
overview,
images,
isAdding,
isExistingAuthor,
isSmallScreen,
onModalClose,
...otherProps
} = this.props;
return (
<ModalContent onModalClose={onModalClose}>
<ModalHeader>
Add new Book
</ModalHeader>
<ModalBody>
<div className={styles.container}>
{
isSmallScreen ?
null:
<div className={styles.poster}>
<BookCover
className={styles.poster}
images={images}
size={250}
/>
</div>
}
<div className={styles.info}>
<div className={styles.name}>
{bookTitle}
</div>
{
!!disambiguation &&
<span className={styles.disambiguation}>({disambiguation})</span>
}
<div>
<span className={styles.authorName}> By: {authorName}</span>
</div>
{
overview ?
<div className={styles.overview}>
<TextTruncate
truncateText="…"
line={8}
text={overview}
/>
</div> :
null
}
{
!isExistingAuthor &&
<AddAuthorOptionsForm
authorName={authorName}
includeNoneMetadataProfile={true}
{...otherProps}
/>
}
</div>
</div>
</ModalBody>
<ModalFooter className={styles.modalFooter}>
<label className={styles.searchForNewBookLabelContainer}>
<span className={styles.searchForNewBookLabel}>
Start search for new book
</span>
<CheckInput
containerClassName={styles.searchForNewBookContainer}
className={styles.searchForNewBookInput}
name="searchForNewBook"
value={this.state.searchForNewBook}
onChange={this.onSearchForNewBookChange}
/>
</label>
<SpinnerButton
className={styles.addButton}
kind={kinds.SUCCESS}
isSpinning={isAdding}
onPress={this.onAddBookPress}
>
Add {bookTitle}
</SpinnerButton>
</ModalFooter>
</ModalContent>
);
}
}
AddNewBookModalContent.propTypes = {
bookTitle: PropTypes.string.isRequired,
authorName: PropTypes.string.isRequired,
disambiguation: PropTypes.string.isRequired,
overview: PropTypes.string,
images: PropTypes.arrayOf(PropTypes.object).isRequired,
isAdding: PropTypes.bool.isRequired,
addError: PropTypes.object,
isExistingAuthor: PropTypes.bool.isRequired,
isSmallScreen: PropTypes.bool.isRequired,
onModalClose: PropTypes.func.isRequired,
onAddBookPress: PropTypes.func.isRequired
};
export default AddNewBookModalContent;
@@ -0,0 +1,132 @@
import PropTypes from 'prop-types';
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { createSelector } from 'reselect';
import { metadataProfileNames } from 'Helpers/Props';
import { setAddDefault, addBook } from 'Store/Actions/searchActions';
import createDimensionsSelector from 'Store/Selectors/createDimensionsSelector';
import selectSettings from 'Store/Selectors/selectSettings';
import AddNewBookModalContent from './AddNewBookModalContent';
function createMapStateToProps() {
return createSelector(
(state, { isExistingAuthor }) => isExistingAuthor,
(state) => state.search,
(state) => state.settings.metadataProfiles,
createDimensionsSelector(),
(isExistingAuthor, searchState, metadataProfiles, dimensions) => {
const {
isAdding,
addError,
defaults
} = searchState;
const {
settings,
validationErrors,
validationWarnings
} = selectSettings(defaults, {}, addError);
// For adding single books, default to None profile
const noneProfile = metadataProfiles.items.find((item) => item.name === metadataProfileNames.NONE);
return {
isAdding,
addError,
showMetadataProfile: true,
isSmallScreen: dimensions.isSmallScreen,
validationErrors,
validationWarnings,
noneMetadataProfileId: noneProfile.id,
...settings
};
}
);
}
const mapDispatchToProps = {
setAddDefault,
addBook
};
class AddNewBookModalContentConnector extends Component {
//
// Lifecycle
constructor(props, context) {
super(props, context);
this.state = {
metadataProfileIdDefault: props.metadataProfileId.value
};
// select none as default
this.onInputChange({
name: 'metadataProfileId',
value: props.noneMetadataProfileId
});
}
componentWillUnmount() {
// reinstate standard default
this.props.setAddDefault({ metadataProfileId: this.state.metadataProfileIdDefault });
}
//
// Listeners
onInputChange = ({ name, value }) => {
this.props.setAddDefault({ [name]: value });
}
onAddBookPress = (searchForNewBook) => {
const {
foreignBookId,
rootFolderPath,
monitor,
qualityProfileId,
metadataProfileId,
tags
} = this.props;
this.props.addBook({
foreignBookId,
rootFolderPath: rootFolderPath.value,
monitor: monitor.value,
qualityProfileId: qualityProfileId.value,
metadataProfileId: metadataProfileId.value,
tags: tags.value,
searchForNewBook
});
}
//
// Render
render() {
return (
<AddNewBookModalContent
{...this.props}
onInputChange={this.onInputChange}
onAddBookPress={this.onAddBookPress}
/>
);
}
}
AddNewBookModalContentConnector.propTypes = {
isExistingAuthor: PropTypes.bool.isRequired,
foreignBookId: PropTypes.string.isRequired,
rootFolderPath: PropTypes.object,
monitor: PropTypes.object.isRequired,
qualityProfileId: PropTypes.object,
metadataProfileId: PropTypes.object,
noneMetadataProfileId: PropTypes.number.isRequired,
tags: PropTypes.object.isRequired,
onModalClose: PropTypes.func.isRequired,
setAddDefault: PropTypes.func.isRequired,
addBook: PropTypes.func.isRequired
};
export default connect(createMapStateToProps, mapDispatchToProps)(AddNewBookModalContentConnector);
@@ -0,0 +1,76 @@
.searchResult {
position: relative;
margin: 20px 0;
padding: 20px;
width: 100%;
color: inherit;
}
.underlay {
@add-mixin cover;
background-color: $white;
transition: background 500ms;
&:hover {
background-color: #eaf2ff;
color: inherit;
text-decoration: none;
}
}
.overlay {
@add-mixin linkOverlay;
position: relative;
display: flex;
}
.poster {
flex: 0 0 170px;
margin-right: 20px;
height: 250px;
}
.content {
flex: 0 1 100%;
}
.name {
display: flex;
font-weight: 300;
font-size: 36px;
}
.authorName {
font-weight: 300;
font-size: 20px;
}
.year {
margin-left: 10px;
color: $disabledColor;
}
.mbLink {
composes: link from '~Components/Link/Link.css';
margin-top: -4px;
margin-left: auto;
color: $textColor;
}
.mbLinkIcon {
margin-left: 10px;
}
.alreadyExistsIcon {
margin-left: 10px;
color: #37bc9b;
}
.overview {
overflow: hidden;
margin-top: 20px;
text-align: justify;
}
@@ -0,0 +1,226 @@
import moment from 'moment';
import PropTypes from 'prop-types';
import React, { Component } from 'react';
import TextTruncate from 'react-text-truncate';
import dimensions from 'Styles/Variables/dimensions';
import fonts from 'Styles/Variables/fonts';
import { icons, sizes } from 'Helpers/Props';
import HeartRating from 'Components/HeartRating';
import Icon from 'Components/Icon';
import Label from 'Components/Label';
import Link from 'Components/Link/Link';
import BookCover from 'Book/BookCover';
import AddNewBookModal from './AddNewBookModal';
import styles from './AddNewBookSearchResult.css';
const columnPadding = parseInt(dimensions.authorIndexColumnPadding);
const columnPaddingSmallScreen = parseInt(dimensions.authorIndexColumnPaddingSmallScreen);
const defaultFontSize = parseInt(fonts.defaultFontSize);
const lineHeight = parseFloat(fonts.lineHeight);
function calculateHeight(rowHeight, isSmallScreen) {
let height = rowHeight - 70;
if (isSmallScreen) {
height -= columnPaddingSmallScreen;
} else {
height -= columnPadding;
}
return height;
}
class AddNewBookSearchResult extends Component {
//
// Lifecycle
constructor(props, context) {
super(props, context);
this.state = {
isNewAddBookModalOpen: false
};
}
componentDidUpdate(prevProps) {
if (!prevProps.isExistingBook && this.props.isExistingBook) {
this.onAddBookModalClose();
}
}
//
// Listeners
onPress = () => {
this.setState({ isNewAddBookModalOpen: true });
}
onAddBookModalClose = () => {
this.setState({ isNewAddBookModalOpen: false });
}
onMBLinkPress = (event) => {
event.stopPropagation();
}
//
// Render
render() {
const {
foreignBookId,
goodreadsId,
titleSlug,
title,
releaseDate,
disambiguation,
overview,
ratings,
images,
author,
isExistingBook,
isExistingAuthor,
isSmallScreen
} = this.props;
const {
isNewAddBookModalOpen
} = this.state;
const linkProps = isExistingBook ? { to: `/book/${titleSlug}` } : { onPress: this.onPress };
const height = calculateHeight(230, isSmallScreen);
return (
<div className={styles.searchResult}>
<Link
className={styles.underlay}
{...linkProps}
/>
<div className={styles.overlay}>
{
!isSmallScreen &&
<BookCover
className={styles.poster}
images={images}
size={250}
lazy={false}
/>
}
<div className={styles.content}>
<div className={styles.name}>
{title}
{
!!disambiguation &&
<span className={styles.year}>({disambiguation})</span>
}
{
isExistingBook ?
<Icon
className={styles.alreadyExistsIcon}
name={icons.CHECK_CIRCLE}
size={20}
title="Book already in your library"
/> :
null
}
<Link
className={styles.mbLink}
to={`https://goodreads.com/book/show/${goodreadsId}`}
onPress={this.onMBLinkPress}
>
<Icon
className={styles.mbLinkIcon}
name={icons.EXTERNAL_LINK}
size={28}
/>
</Link>
</div>
<div>
<span className={styles.authorName}> By: {author.authorName}</span>
{
isExistingAuthor ?
<Icon
className={styles.alreadyExistsIcon}
name={icons.CHECK_CIRCLE}
size={15}
title="Author already in your library"
/> :
null
}
</div>
<div>
<Label size={sizes.LARGE}>
<HeartRating
rating={ratings.value}
iconSize={13}
/>
</Label>
{
!!releaseDate &&
<Label size={sizes.LARGE}>
{moment(releaseDate).format('YYYY')}
</Label>
}
</div>
<div
className={styles.overview}
style={{
maxHeight: `${height}px`
}}
>
<TextTruncate
truncateText="…"
line={Math.floor(height / (defaultFontSize * lineHeight))}
text={overview}
/>
</div>
</div>
</div>
<AddNewBookModal
isOpen={isNewAddBookModalOpen && !isExistingBook}
isExistingAuthor={isExistingAuthor}
foreignBookId={foreignBookId}
bookTitle={title}
disambiguation={disambiguation}
authorName={author.authorName}
overview={overview}
images={images}
onModalClose={this.onAddBookModalClose}
/>
</div>
);
}
}
AddNewBookSearchResult.propTypes = {
foreignBookId: PropTypes.string.isRequired,
goodreadsId: PropTypes.number.isRequired,
titleSlug: PropTypes.string.isRequired,
title: PropTypes.string.isRequired,
releaseDate: PropTypes.string,
disambiguation: PropTypes.string,
overview: PropTypes.string,
ratings: PropTypes.object.isRequired,
author: PropTypes.object,
images: PropTypes.arrayOf(PropTypes.object).isRequired,
isExistingBook: PropTypes.bool.isRequired,
isExistingAuthor: PropTypes.bool.isRequired,
isSmallScreen: PropTypes.bool.isRequired
};
export default AddNewBookSearchResult;
@@ -0,0 +1,17 @@
import { connect } from 'react-redux';
import { createSelector } from 'reselect';
import createDimensionsSelector from 'Store/Selectors/createDimensionsSelector';
import AddNewBookSearchResult from './AddNewBookSearchResult';
function createMapStateToProps() {
return createSelector(
createDimensionsSelector(),
(dimensions) => {
return {
isSmallScreen: dimensions.isSmallScreen
};
}
);
}
export default connect(createMapStateToProps)(AddNewBookSearchResult);