mirror of
https://github.com/Alamantus/Lexiconga.git
synced 2025-05-10 20:21:27 +02:00
Add edit/delete buttons to word dropdowns
This commit is contained in:
parent
c5e48d9b9e
commit
1eb60a9b44
1 changed files with 39 additions and 4 deletions
|
@ -14,6 +14,7 @@ export class WordDisplay extends Component {
|
||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
|
menuIsOpen: false,
|
||||||
isEditing: false,
|
isEditing: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,7 +27,27 @@ export class WordDisplay extends Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
edit () {
|
||||||
|
this.setState({
|
||||||
|
menuIsOpen: false,
|
||||||
|
isEditing: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
|
const { menuIsOpen, isEditing } = this.state;
|
||||||
|
|
||||||
|
if (isEditing) {
|
||||||
|
return (
|
||||||
|
<WordForm
|
||||||
|
name={this.props.word.name}
|
||||||
|
pronunciation={this.props.word.pronunciation}
|
||||||
|
partOfSpeech={this.props.word.partOfSpeech}
|
||||||
|
definition={this.props.word.definition}
|
||||||
|
details={this.props.word.details}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<div className='card'>
|
<div className='card'>
|
||||||
|
|
||||||
|
@ -60,11 +81,25 @@ export class WordDisplay extends Component {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
<a className='card-header-icon' aria-label='more options'>
|
<div aria-label='options'
|
||||||
<span className='icon'>
|
className={`card-header-icon dropdown is-right ${ menuIsOpen ? 'is-active' : '' }`}
|
||||||
<i className='fa fa-angle-down' aria-hidden='true'></i>
|
>
|
||||||
|
<span className='icon dropdown-trigger'
|
||||||
|
onClick={ () => this.setState({ menuIsOpen: !menuIsOpen }) }
|
||||||
|
>
|
||||||
|
<i className={`fa fa-angle-${ menuIsOpen ? 'up' : 'down' }`} aria-hidden='true'></i>
|
||||||
</span>
|
</span>
|
||||||
|
<div className='dropdown-menu' id='dropdown-menu' role='menu'>
|
||||||
|
<div className='dropdown-content'>
|
||||||
|
<a className='dropdown-item' onClick={ this.edit.bind(this) }>
|
||||||
|
Edit
|
||||||
</a>
|
</a>
|
||||||
|
<a className='dropdown-item is-danger'>
|
||||||
|
Delete
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<section className='card-content'>
|
<section className='card-content'>
|
||||||
|
|
Loading…
Add table
Reference in a new issue