Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 62 additions & 6 deletions public/css/hanzi-graph.css
Original file line number Diff line number Diff line change
Expand Up @@ -694,18 +694,38 @@ https://developer.mozilla.org/en-US/docs/Web/API/File_API/Using_files_from_web_a
margin-bottom: 12px;
}

.character-data+.character-data {
border-top: 1px solid var(--border-color);
margin-top: 16px;
padding-top: 16px;
}

.character-data a.navigable {
margin-right: 20px;
}

.collocations-detail {
text-align: center;
margin: 6px 0 0 0;
margin: 6px 0 14px;
}

.flow-subpane {
background: var(--sentence-card-background-color);
border: var(--border);
border-radius: 12px;
padding: 14px 16px 10px;
}

.sankey-container {
margin-top: 8px;
}

.collocation a:first-of-type::before,
.collocation a:last-of-type::after {
content: '...'
content: '...';
opacity: 0.4;
font-style: italic;
margin: 0 2px;
}

.collocation {
Expand All @@ -722,7 +742,12 @@ https://developer.mozilla.org/en-US/docs/Web/API/File_API/Using_files_from_web_a
}

.character-data h3 {
margin: 8px 0;
margin: 10px 0 4px;
font-size: 11px;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.07em;
opacity: 0.55;
}

.pinyin-relationship {
Expand All @@ -734,6 +759,26 @@ https://developer.mozilla.org/en-US/docs/Web/API/File_API/Using_files_from_web_a
.related-characters {
font-size: 30px;
font-weight: var(--target-language-font-weight);
display: flex;
flex-wrap: wrap;
gap: 6px 16px;
align-items: baseline;
margin-bottom: 4px;
}

.character-data>div:not(.related-characters) {
font-style: italic;
font-size: var(--secondary-control-font-size);
opacity: 0.6;
margin-bottom: 4px;
}

.character-data .explanation {
font-size: var(--secondary-control-font-size);
font-weight: normal;
text-align: center;
opacity: 0.7;
margin-bottom: 10px;
}

.nowrap {
Expand Down Expand Up @@ -934,8 +979,19 @@ https://developer.mozilla.org/en-US/docs/Web/API/File_API/Using_files_from_web_a
}

.explore-stat-header {
margin: 8px 0 0 0;
margin: 0 0 10px;
text-align: center;
font-size: 18px;
font-weight: 700;
letter-spacing: -0.01em;
}

.stat-section {
background: var(--sentence-card-background-color);
border-radius: 12px;
border: var(--border);
padding: 14px 16px;
margin-bottom: 16px;
}

.coverage-explanation {
Expand Down Expand Up @@ -2466,7 +2522,7 @@ main.auth-form {
--explore-tab-active-background-color: #c800ff;
--explore-tab-active-text-color: #fff;
--explore-tab-hover-background-color: rgba(200, 0, 255, 0.15);
--sentence-card-background-color: rgba(100, 150, 255, 0.1);
--sentence-card-background-color: rgba(100, 150, 255, 0.08);
--link-font-color: #68aaee;
--primary-input-box-shadow: 0;
--button-font-color: black;
Expand Down Expand Up @@ -2659,4 +2715,4 @@ main.auth-form {
.graph-expander:hover .big-up-arrow {
animation: upward-for-some-reason 0.75s 2;
}
}
}
27 changes: 16 additions & 11 deletions public/js/modules/explore.js
Original file line number Diff line number Diff line change
Expand Up @@ -748,29 +748,34 @@ let renderMeaning = function (word, definitionList, examples, maxExamples, conta
renderExamples(word, examples, maxExamples, container);
};
let renderStats = function (word, container) {
let wordFreqHeader = document.createElement('h3');
wordFreqHeader.classList.add('explore-stat-header');
wordFreqHeader.innerText = 'Word Frequency Stats';
let renderedWordFreq = false;
if (coverageGraph && ('words' in coverageGraph) && (word in wordSet)) {
container.appendChild(wordFreqHeader);
renderCoverageGraph(coverageGraph['words'], word, wordSet[word], 'word', container);
let wordSection = document.createElement('div');
wordSection.classList.add('stat-section');
let wordFreqHeader = document.createElement('h3');
wordFreqHeader.classList.add('explore-stat-header');
wordFreqHeader.innerText = 'Word Frequency Stats';
wordSection.appendChild(wordFreqHeader);
container.appendChild(wordSection);
renderCoverageGraph(coverageGraph['words'], word, wordSet[word], 'word', wordSection);
renderedWordFreq = true;
}
let charSection = document.createElement('div');
charSection.classList.add('stat-section');
let charFreqHeader = document.createElement('h3');
charFreqHeader.classList.add('explore-stat-header');
charFreqHeader.innerText = 'Character Frequency Stats';
container.appendChild(charFreqHeader);
charSection.appendChild(charFreqHeader);
let renderedCharacterFreq = false;
for (const character of word) {
if (charFreqs && (character in charFreqs) && coverageGraph && ('chars' in coverageGraph)) {
renderCoverageGraph(coverageGraph['chars'], character, charFreqs[character], 'character', container);
if (!renderedCharacterFreq) {
container.appendChild(charSection);
}
renderCoverageGraph(coverageGraph['chars'], character, charFreqs[character], 'character', charSection);
renderedCharacterFreq = true;
}
}
if (!renderedCharacterFreq) {
charFreqHeader.style.display = 'none';
}
if (!renderedWordFreq && !renderedCharacterFreq) {
let unavailableMessage = document.createElement('p');
unavailableMessage.innerText = 'Sorry, no stats found.';
Expand Down Expand Up @@ -933,7 +938,7 @@ function renderExplore(word, container, definitionList, examples, maxExamples, a
statsContainer.classList.add('explore-subpane');
statsContainer.style.display = 'none';
let flowContainer = document.createElement('div');
flowContainer.classList.add('explore-subpane');
flowContainer.classList.add('explore-subpane', 'flow-subpane');
flowContainer.style.display = 'none';
// TODO: make this smarter
currentTabs = renderTabs(tabs, ['Meaning', 'Tree', 'Stats', 'Flow'], [meaningContainer, componentsContainer, statsContainer, flowContainer], [() => { }, () => {
Expand Down
5 changes: 4 additions & 1 deletion public/js/modules/flow-diagram.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,10 @@ async function renderUsageDiagram(term, container) {
fontSize: getFontSize(container.offsetWidth),
nodeStroke: null
});
container.appendChild(chart);
const sankeyContainer = document.createElement('div');
sankeyContainer.classList.add('sankey-container');
sankeyContainer.appendChild(chart);
container.appendChild(sankeyContainer);
}

async function getCollocations(word) {
Expand Down
Loading