mirror of
				https://github.com/Alamantus/Lexiconga.git
				synced 2025-11-04 10:17:01 +01:00 
			
		
		
		
	Style the WordDisplay component properly!
This commit is contained in:
		
							parent
							
								
									e131f7bff4
								
							
						
					
					
						commit
						c5e48d9b9e
					
				
					 2 changed files with 86 additions and 32 deletions
				
			
		| 
						 | 
					@ -2,6 +2,8 @@ import Inferno from 'inferno';
 | 
				
			||||||
import Component from 'inferno-component';
 | 
					import Component from 'inferno-component';
 | 
				
			||||||
import marked from 'marked';
 | 
					import marked from 'marked';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import './WordDisplay.scss';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import idManager from '../../managers/IDManager';
 | 
					import idManager from '../../managers/IDManager';
 | 
				
			||||||
import { Word } from '../../managers/Word';
 | 
					import { Word } from '../../managers/Word';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -14,6 +16,14 @@ export class WordDisplay extends Component {
 | 
				
			||||||
    this.state = {
 | 
					    this.state = {
 | 
				
			||||||
      isEditing: false,
 | 
					      isEditing: false,
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    this.wordDetailsHTML = marked(props.word.details);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  componentWillUpdate (nextProps, nextState) {
 | 
				
			||||||
 | 
					    if (this.props.word.details !== nextProps.word.details) {
 | 
				
			||||||
 | 
					      this.wordDetailsHTML = marked(nextProps.word.details);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  render () {
 | 
					  render () {
 | 
				
			||||||
| 
						 | 
					@ -21,42 +31,48 @@ export class WordDisplay extends Component {
 | 
				
			||||||
      <div className='card'>
 | 
					      <div className='card'>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        <header className='card-header'>
 | 
					        <header className='card-header'>
 | 
				
			||||||
          <h3 className='card-header-title'>
 | 
					          <div className='word-card-header-title'>
 | 
				
			||||||
 | 
					            <span className='word-name'>
 | 
				
			||||||
              { this.props.word.name }
 | 
					              { this.props.word.name }
 | 
				
			||||||
          </h3>
 | 
					            </span>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					              (this.props.word.pronunciation || this.props.word.partOfSpeech)
 | 
				
			||||||
 | 
					              && (
 | 
				
			||||||
 | 
					                <span className='word-classification'>
 | 
				
			||||||
 | 
					                  {
 | 
				
			||||||
 | 
					                    (this.props.word.pronunciation)
 | 
				
			||||||
 | 
					                    && (
 | 
				
			||||||
 | 
					                      <span className='word-pronunciation'>
 | 
				
			||||||
 | 
					                      { this.props.word.pronunciation }
 | 
				
			||||||
 | 
					                      </span>
 | 
				
			||||||
 | 
					                    )
 | 
				
			||||||
 | 
					                  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                  {
 | 
				
			||||||
 | 
					                    (this.props.word.partOfSpeech)
 | 
				
			||||||
 | 
					                    && (
 | 
				
			||||||
 | 
					                      <span className='word-part-of-speech'>
 | 
				
			||||||
 | 
					                      { this.props.word.partOfSpeech }
 | 
				
			||||||
 | 
					                      </span>
 | 
				
			||||||
 | 
					                    )
 | 
				
			||||||
 | 
					                  }
 | 
				
			||||||
 | 
					                </span>
 | 
				
			||||||
 | 
					              )
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					          </div>
 | 
				
			||||||
 | 
					          <a className='card-header-icon' aria-label='more options'>
 | 
				
			||||||
 | 
					            <span className='icon'>
 | 
				
			||||||
 | 
					              <i className='fa fa-angle-down' aria-hidden='true'></i>
 | 
				
			||||||
 | 
					            </span>
 | 
				
			||||||
 | 
					          </a>
 | 
				
			||||||
        </header>
 | 
					        </header>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        <section className='card-content'>
 | 
					        <section className='card-content'>
 | 
				
			||||||
          <div className='content'>
 | 
					          <div className='content'>
 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
              (this.props.word.pronunciation || this.props.word.partOfSpeech)
 | 
					 | 
				
			||||||
              && (
 | 
					 | 
				
			||||||
                <p>
 | 
					 | 
				
			||||||
                  {
 | 
					 | 
				
			||||||
                    (this.props.word.partOfSpeech)
 | 
					 | 
				
			||||||
                    ? (<small>{ this.props.word.partOfSpeech }</small>)
 | 
					 | 
				
			||||||
                    : ''
 | 
					 | 
				
			||||||
                  }
 | 
					 | 
				
			||||||
                
 | 
					 | 
				
			||||||
                  {
 | 
					 | 
				
			||||||
                    (this.props.word.partOfSpeech && this.props.word.pronunciation)
 | 
					 | 
				
			||||||
                    ? ' | '
 | 
					 | 
				
			||||||
                    : ''
 | 
					 | 
				
			||||||
                  }
 | 
					 | 
				
			||||||
                
 | 
					 | 
				
			||||||
                  {
 | 
					 | 
				
			||||||
                    (this.props.word.pronunciation)
 | 
					 | 
				
			||||||
                    ? (<small>{ this.props.word.pronunciation }</small>)
 | 
					 | 
				
			||||||
                    : ''
 | 
					 | 
				
			||||||
                  }
 | 
					 | 
				
			||||||
                </p>
 | 
					 | 
				
			||||||
              )
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
              (this.props.word.definition)
 | 
					              (this.props.word.definition)
 | 
				
			||||||
              && (
 | 
					              && (
 | 
				
			||||||
                <p>
 | 
					                <p className='word-definition'>
 | 
				
			||||||
                  { this.props.word.definition }
 | 
					                  { this.props.word.definition }
 | 
				
			||||||
                </p>
 | 
					                </p>
 | 
				
			||||||
              )
 | 
					              )
 | 
				
			||||||
| 
						 | 
					@ -65,9 +81,8 @@ export class WordDisplay extends Component {
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
              (this.props.word.details)
 | 
					              (this.props.word.details)
 | 
				
			||||||
              && (
 | 
					              && (
 | 
				
			||||||
                <p>
 | 
					                <p className='word-details'
 | 
				
			||||||
                  { this.props.word.details }
 | 
					                  dangerouslySetInnerHTML={{__html: this.wordDetailsHTML}} />
 | 
				
			||||||
                </p>
 | 
					 | 
				
			||||||
              )
 | 
					              )
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
          </div>
 | 
					          </div>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										39
									
								
								src/components/display/WordDisplay.scss
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								src/components/display/WordDisplay.scss
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,39 @@
 | 
				
			||||||
 | 
					@import '../../node_modules/bulma/sass/utilities/initial-variables';
 | 
				
			||||||
 | 
					@import '../../node_modules/bulma/sass/utilities/derived-variables';
 | 
				
			||||||
 | 
					@import '../../node_modules/bulma/sass/components/card';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.word-card-header-title {
 | 
				
			||||||
 | 
					  @extend .card-header-title;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  align-items: baseline;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  .word-name {
 | 
				
			||||||
 | 
					    font-size: 1.2em;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.word-card-header-title,
 | 
				
			||||||
 | 
					.word-classification {
 | 
				
			||||||
 | 
					  span:not(:last-child) {
 | 
				
			||||||
 | 
					    margin-right: 10px;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.word-classification {
 | 
				
			||||||
 | 
					  font-size: 0.75em;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  .word-pronunciation {
 | 
				
			||||||
 | 
					    font-weight: normal !important;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  .word-part-of-speech {
 | 
				
			||||||
 | 
					    font-style: italic;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.word-definition {
 | 
				
			||||||
 | 
					  font-style: italic;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.word-details {
 | 
				
			||||||
 | 
					  padding-left: 15px;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue