diff --git a/src/helpers.js b/src/helpers.js new file mode 100644 index 0000000..1f90346 --- /dev/null +++ b/src/helpers.js @@ -0,0 +1,22 @@ +export function removeTags(html) { +var tagBody = '(?:[^"\'>]|"[^"]*"|\'[^\']*\')*'; + +var tagOrComment = new RegExp( + '<(?:' + // Comment body. + + '!--(?:(?:-*[^->])*--+|-?)' + // Special "raw text" elements whose content should be elided. + + '|script\\b' + tagBody + '>[\\s\\S]*?[\\s\\S]*?', + 'gi'); + var oldHtml; + do { + oldHtml = html; + html = html.replace(tagOrComment, ''); + } while (html !== oldHtml); + return html.replace(/Alphabetical Order: ${ (alphabeticalOrder.length > 0 ? alphabeticalOrder : ['English Alphabet']).map(letter => `${letter}`).join(' ') }

`; - + const generalHTML = `

General

${partsOfSpeechHTML}${alphabeticalOrderHTML}`; - detailsPanel.innerHTML = partsOfSpeechHTML + alphabeticalOrderHTML; + const {consonants, vowels, blends, phonotactics} = phonology + const consonantHTML = `

Consonants: ${consonants.map(letter => `${letter}`).join(' ')}

`; + const vowelHTML = `

Vowels: ${vowels.map(letter => `${letter}`).join(' ')}

`; + const blendHTML = blends.length > 0 ? `

Polyphthongs / Blends: ${blends.map(letter => `${letter}`).join(' ')}

` : ''; + const phonologyHTML = `

Phonology

+
+
${consonantHTML}
+
${vowelHTML}
+
+ ${blendHTML}`; + + const {onset, nucleus, coda, exceptions} = phonotactics; + const onsetHTML = `

Onset: ${onset.map(letter => `${letter}`).join(' ')}

`; + const nucleusHTML = `

Nucleus: ${nucleus.map(letter => `${letter}`).join(' ')}

`; + const codaHTML = `

Coda: ${coda.map(letter => `${letter}`).join(' ')}

`; + const exceptionsHTML = exceptions.trim().length > 0 ? '

Exceptions:

' + md(removeTags(exceptions)) + '
' : ''; + const phonotacticsHTML = `

Phonotactics

+
+
${onsetHTML}
+
${nucleusHTML}
+
${codaHTML}
+
+ ${exceptionsHTML}`; + + const orthographyHTML = '

Orthography

Notes:

' + md(removeTags(orthography.notes)) + '
'; + const grammarHTML = '

Grammar

Notes:

' + md(removeTags(grammar.notes)) + '
'; + + detailsPanel.innerHTML = generalHTML + phonologyHTML + phonotacticsHTML + orthographyHTML + grammarHTML; } function showStats() { diff --git a/src/styles/_elements.scss b/src/styles/_elements.scss index a99ae4b..0866a19 100644 --- a/src/styles/_elements.scss +++ b/src/styles/_elements.scss @@ -74,4 +74,28 @@ span .tag { border-bottom: 1px solid $white; } } +} + +.split { + display: block; + + div { + display: inline-block; + vertical-align: top; + margin: 0; + margin-right: 2%; + + &:last-child { + margin-right: unset; + margin-left: 2%; + } + } + + &.two div { + width: 46%; + } + + &.three div { + width: 30%; + } } \ No newline at end of file diff --git a/src/styles/_structure.scss b/src/styles/_structure.scss index c2a9bde..f9ae21c 100644 --- a/src/styles/_structure.scss +++ b/src/styles/_structure.scss @@ -72,6 +72,8 @@ #detailsPanel { background-color: $white; padding: 20px; + max-height: 400px; + overflow-y: auto; } }