mirror of
https://github.com/Alamantus/Lexiconga.git
synced 2025-04-29 06:43:07 +02:00
Make WordForm float in LeftColumn and closed by default
Expands RightColumn display when closed and compresses when open, unless on mobile screen.
This commit is contained in:
parent
5934230d00
commit
f866932de5
4 changed files with 151 additions and 73 deletions
|
@ -1,4 +1,5 @@
|
||||||
import Inferno from 'inferno';
|
import Inferno from 'inferno';
|
||||||
|
import Component from 'inferno-component';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
|
||||||
import { LeftColumn } from './structure/LeftColumn';
|
import { LeftColumn } from './structure/LeftColumn';
|
||||||
|
@ -8,46 +9,83 @@ import { WordForm } from './management/WordForm';
|
||||||
import { DictionaryDetails } from './display/DictionaryDetails';
|
import { DictionaryDetails } from './display/DictionaryDetails';
|
||||||
import { WordsList } from './display/WordsList';
|
import { WordsList } from './display/WordsList';
|
||||||
|
|
||||||
export const MainDisplay = (props) => {
|
export class MainDisplay extends Component {
|
||||||
PropTypes.checkPropTypes({
|
constructor (props) {
|
||||||
dictionaryInfo: PropTypes.object.isRequired,
|
super(props);
|
||||||
wordsToDisplay: PropTypes.array.isRequired,
|
|
||||||
updateDisplay: PropTypes.func.isRequired,
|
|
||||||
updater: PropTypes.object.isRequired,
|
|
||||||
}, props, 'prop', 'MainDisplay');
|
|
||||||
|
|
||||||
const { dictionaryInfo, wordsToDisplay, updateDisplay, updater } = props;
|
PropTypes.checkPropTypes({
|
||||||
|
dictionaryInfo: PropTypes.object.isRequired,
|
||||||
|
wordsToDisplay: PropTypes.array.isRequired,
|
||||||
|
updateDisplay: PropTypes.func.isRequired,
|
||||||
|
updater: PropTypes.object.isRequired,
|
||||||
|
}, props, 'prop', 'MainDisplay');
|
||||||
|
|
||||||
return (
|
this.state = {
|
||||||
<section className='section'>
|
isMobile: false,
|
||||||
<div className='container'>
|
wordFormIsOpen: false,
|
||||||
<div className='columns'>
|
};
|
||||||
|
}
|
||||||
|
|
||||||
<LeftColumn>
|
openWordForm () {
|
||||||
<WordForm
|
this.setState({ wordFormIsOpen: true });
|
||||||
updateDisplay={ updateDisplay }
|
}
|
||||||
/>
|
|
||||||
</LeftColumn>
|
|
||||||
|
|
||||||
<RightColumn>
|
closeWordForm () {
|
||||||
<DictionaryDetails
|
this.setState({ wordFormIsOpen: false });
|
||||||
updater={ updater }
|
}
|
||||||
name={ dictionaryInfo.name }
|
|
||||||
specification={ dictionaryInfo.specification }
|
|
||||||
description={ dictionaryInfo.description }
|
|
||||||
partsOfSpeech={ dictionaryInfo.partsOfSpeech }
|
|
||||||
details={ dictionaryInfo.details }
|
|
||||||
alphabeticalOrder={ dictionaryInfo.alphabeticalOrder }
|
|
||||||
/>
|
|
||||||
|
|
||||||
<WordsList
|
checkIsMobile () {
|
||||||
words={ wordsToDisplay }
|
this.setState({ isMobile: window.innerWidth < 769 });
|
||||||
adsEveryXWords={ 10 }
|
}
|
||||||
updateDisplay={ updateDisplay } />
|
|
||||||
</RightColumn>
|
|
||||||
|
|
||||||
|
componentDidMount () {
|
||||||
|
window.addEventListener('resize', this.checkIsMobile.bind(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
componentWillUnmount () {
|
||||||
|
window.removeEventListener('resize');
|
||||||
|
}
|
||||||
|
|
||||||
|
render () {
|
||||||
|
const { dictionaryInfo, wordsToDisplay, updateDisplay, updater } = this.props;
|
||||||
|
const { isMobile, wordFormIsOpen } = this.state;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<section className='section'>
|
||||||
|
<div className='container'>
|
||||||
|
<div className='columns'>
|
||||||
|
|
||||||
|
<LeftColumn
|
||||||
|
isMobile={ this.state.isMobile }
|
||||||
|
displayForm={ this.state.wordFormIsOpen }
|
||||||
|
openWordForm={ this.openWordForm.bind(this) }
|
||||||
|
closeWordForm={ this.closeWordForm.bind(this) }
|
||||||
|
>
|
||||||
|
<WordForm
|
||||||
|
updateDisplay={ updateDisplay }
|
||||||
|
/>
|
||||||
|
</LeftColumn>
|
||||||
|
|
||||||
|
<RightColumn formIsDisplayed={ this.state.wordFormIsOpen }>
|
||||||
|
<DictionaryDetails
|
||||||
|
updater={ updater }
|
||||||
|
name={ dictionaryInfo.name }
|
||||||
|
specification={ dictionaryInfo.specification }
|
||||||
|
description={ dictionaryInfo.description }
|
||||||
|
partsOfSpeech={ dictionaryInfo.partsOfSpeech }
|
||||||
|
details={ dictionaryInfo.details }
|
||||||
|
alphabeticalOrder={ dictionaryInfo.alphabeticalOrder }
|
||||||
|
/>
|
||||||
|
|
||||||
|
<WordsList
|
||||||
|
words={ wordsToDisplay }
|
||||||
|
adsEveryXWords={ 10 }
|
||||||
|
updateDisplay={ updateDisplay } />
|
||||||
|
</RightColumn>
|
||||||
|
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</section>
|
||||||
</section>
|
);
|
||||||
);
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,32 +1,55 @@
|
||||||
import Inferno from 'inferno';
|
import Inferno from 'inferno';
|
||||||
import Component from 'inferno-component';
|
import PropTypes from 'prop-types';
|
||||||
|
|
||||||
import { Modal } from '../Modal';
|
import { Modal } from '../Modal';
|
||||||
|
|
||||||
import './styles.scss';
|
import './styles.scss';
|
||||||
|
|
||||||
export class LeftColumn extends Component {
|
export const LeftColumn = (props) => {
|
||||||
constructor (props) {
|
PropTypes.checkPropTypes({
|
||||||
super(props);
|
isMobile: PropTypes.bool.isRequired,
|
||||||
|
displayForm: PropTypes.bool.isRequired,
|
||||||
|
openWordForm: PropTypes.func.isRequired,
|
||||||
|
closeWordForm: PropTypes.func.isRequired,
|
||||||
|
children: PropTypes.object,
|
||||||
|
}, props, 'prop', 'LeftColumn');
|
||||||
|
|
||||||
this.isMobile = window.innerWidth < 769;
|
const { isMobile, displayForm, openWordForm, closeWordForm } = props;
|
||||||
}
|
|
||||||
|
|
||||||
render () {
|
return (
|
||||||
return (
|
<div className={ `left-column-${ displayForm ? 'open' : 'closed' }` } >
|
||||||
<div className='left-column'>
|
{isMobile
|
||||||
{this.isMobile
|
? (
|
||||||
? (
|
<div className='floating-word-button'>
|
||||||
<div className='floating-word-button'>
|
<Modal title='New Word'
|
||||||
<Modal title='New Word'
|
buttonText={<span className='icon'><i className='fa fa-plus' /></span>}
|
||||||
buttonText={<span className='icon'><i className='fa fa-plus' /></span>}
|
>
|
||||||
>
|
{ props.children }
|
||||||
{ this.props.children }
|
</Modal>
|
||||||
</Modal>
|
</div>
|
||||||
</div>
|
) : (
|
||||||
) : this.props.children
|
<div>
|
||||||
}
|
{displayForm
|
||||||
</div>
|
? (
|
||||||
);
|
<div className='floating-word-form'>
|
||||||
}
|
<a className='button is-pulled-right'
|
||||||
|
onClick={ closeWordForm }
|
||||||
|
>
|
||||||
|
<span className='icon'><i className='fa fa-close' /></span>
|
||||||
|
</a>
|
||||||
|
{ props.children }
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<div className='floating-word-button'>
|
||||||
|
<a className='button' onClick={ openWordForm }>
|
||||||
|
<span className='icon'><i className='fa fa-plus' /></span>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,29 @@
|
||||||
|
@import '../../node_modules/bulma/sass/utilities/initial-variables';
|
||||||
|
@import '../../node_modules/bulma/sass/utilities/derived-variables';
|
||||||
@import '../../node_modules/bulma/sass/utilities/mixins';
|
@import '../../node_modules/bulma/sass/utilities/mixins';
|
||||||
@import '../../node_modules/bulma/sass/grid/columns';
|
@import '../../node_modules/bulma/sass/grid/columns';
|
||||||
|
@import '../../node_modules/bulma/sass/components/navbar';
|
||||||
|
|
||||||
.left-column {
|
.left-column-open {
|
||||||
@extend .column;
|
@extend .column;
|
||||||
@extend .is-one-third;
|
@extend .is-one-third;
|
||||||
}
|
}
|
||||||
|
|
||||||
.floating-word-button {
|
.floating-word-button {
|
||||||
|
margin: $column-gap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.floating-word-button,
|
||||||
|
.floating-word-form {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
z-index: 2;
|
z-index: 2;
|
||||||
|
top: $navbar-height;
|
||||||
left: 0;
|
left: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.floating-word-form {
|
||||||
|
@extend .column;
|
||||||
|
@extend .is-one-third;
|
||||||
|
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
|
|
@ -1,16 +1,17 @@
|
||||||
import Inferno from 'inferno';
|
import Inferno from 'inferno';
|
||||||
import Component from 'inferno-component';
|
import PropTypes from 'prop-types';
|
||||||
|
|
||||||
export class RightColumn extends Component {
|
export const RightColumn = (props) => {
|
||||||
constructor (props) {
|
PropTypes.checkPropTypes({
|
||||||
super(props);
|
formIsDisplayed: PropTypes.bool.isRequired,
|
||||||
}
|
children: PropTypes.object,
|
||||||
|
}, props, 'prop', 'RightColumn');
|
||||||
|
|
||||||
render () {
|
const { formIsDisplayed } = props;
|
||||||
return (
|
|
||||||
<div className='column is-two-thirds'>
|
return (
|
||||||
{ this.props.children }
|
<div className={ `column ${ formIsDisplayed ? 'is-two-thirds' : '' }` }>
|
||||||
</div>
|
{ props.children }
|
||||||
);
|
</div>
|
||||||
}
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue