summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/css/display.css102
-rw-r--r--ext/display-templates.html3
-rw-r--r--ext/js/display/display-generator.js13
-rw-r--r--ext/js/display/display.js5
4 files changed, 71 insertions, 52 deletions
diff --git a/ext/css/display.css b/ext/css/display.css
index e9339ccc..ec117a1c 100644
--- a/ext/css/display.css
+++ b/ext/css/display.css
@@ -674,73 +674,87 @@ button.action-button[data-icon=source-term]::before {
/* Tags */
.tag {
- display: inline-block;
- padding: 0.2em 0.6em 0.3em;
- font-size: var(--tag-font-size);
- font-weight: var(--tag-font-weight);
- line-height: 1.25;
- text-align: center;
- white-space: nowrap;
- vertical-align: baseline;
+ --tag-color: var(--tag-default-background-color);
+
+ display: inline-flex;
+ flex-flow: row nowrap;
+ align-items: stretch;
+ border: none;
+ border-right: none;
+ font-size: 1em;
+ margin: calc(1em / var(--font-size-no-units)) 0.375em calc(1em / var(--font-size-no-units)) 0;
+}
+.tag-label {
+ display: flex;
+ flex-flow: row nowrap;
+ align-items: center;
+ background-color: var(--tag-color);
border-radius: 0.25em;
+ padding: calc(2.5em / var(--font-size-no-units)) 0.375em calc(2.5em / var(--font-size-no-units)) 0.375em;
color: var(--tag-text-color);
- background-color: var(--tag-default-background-color);
- border: var(--tag-border-size) var(--tag-border-style) var(--tag-border-color);
- margin-right: 0.375em;
cursor: pointer;
}
+.tag-label-content {
+ font-size: var(--tag-font-size);
+ font-weight: var(--tag-font-weight);
+}
+.tag-body {
+ position: relative;
+ padding: 0 0.375em 0 0.375em;
+}
+.tag-body::before {
+ content: '';
+ display: block;
+ position: absolute;
+ left: 0;
+ top: 0;
+ bottom: 0;
+ right: 0;
+ border-radius: 0.25em;
+ border: var(--tag-border-size) var(--tag-border-style) var(--tag-color);
+ border-left: none;
+ border-top-left-radius: 0;
+ border-bottom-left-radius: 0;
+}
+.tag-body-content {
+ position: relative;
+}
+.tag:not(.tag-has-body)>.tag-body {
+ display: none;
+}
+.tag.tag-has-body>.tag-label {
+ border-top-right-radius: 0;
+ border-bottom-right-radius: 0;
+}
.tag[data-category=name] {
- background-color: var(--tag-name-background-color);
+ --tag-color: var(--tag-name-background-color);
}
.tag[data-category=expression] {
- background-color: var(--tag-expression-background-color);
+ --tag-color: var(--tag-expression-background-color);
}
.tag[data-category=popular] {
- background-color: var(--tag-popular-background-color);
+ --tag-color: var(--tag-popular-background-color);
}
.tag[data-category=frequent] {
- background-color: var(--tag-frequent-background-color);
+ --tag-color: var(--tag-frequent-background-color);
}
.tag[data-category=archaism] {
- background-color: var(--tag-archaism-background-color);
+ --tag-color: var(--tag-archaism-background-color);
}
.tag[data-category=dictionary] {
- background-color: var(--tag-dictionary-background-color);
+ --tag-color: var(--tag-dictionary-background-color);
}
.tag[data-category=frequency] {
- background-color: var(--tag-frequency-background-color);
+ --tag-color: var(--tag-frequency-background-color);
}
.tag[data-category=partOfSpeech] {
- background-color: var(--tag-part-of-speech-background-color);
+ --tag-color: var(--tag-part-of-speech-background-color);
}
.tag[data-category=search] {
- background-color: var(--tag-search-background-color);
+ --tag-color: var(--tag-search-background-color);
}
.tag[data-category=pitch-accent-dictionary] {
- background-color: var(--tag-pitch-accent-dictionary-background-color);
-}
-.tag-inner {
- display: block;
-}
-.tag-details-disambiguation-list::before {
- content: 'Only: ';
-}
-.tag-details-disambiguation-list ruby>rt {
- display: inline;
- font-size: 1em;
-}
-.tag-details-disambiguation-list ruby>rt::before {
- content: '(';
-}
-.tag-details-disambiguation-list ruby>rt::after {
- content: ')';
-}
-.tag-details-disambiguation-list[data-unmatched-expression-count='0'],
-.tag-details-disambiguation-list:not([data-unmatched-expression-count]) {
- display: none;
-}
-.tag-details-disambiguation:not(:last-child)::after {
- content: ', ';
+ --tag-color: var(--tag-pitch-accent-dictionary-background-color);
}
diff --git a/ext/display-templates.html b/ext/display-templates.html
index e506159e..bb89ceaa 100644
--- a/ext/display-templates.html
+++ b/ext/display-templates.html
@@ -130,7 +130,8 @@
<template id="kanji-reading-template"><dd class="kanji-reading"></dd></template>
<!-- Tag templates -->
-<template id="tag-template"><span class="tag"><span class="tag-inner"></span></span></template>
+<template id="tag-template"><span class="tag"><span class="tag-label"><span class="tag-label-content"></span></span></span></template>
+<template id="tag-with-body-template"><span class="tag tag-has-body"><span class="tag-label"><span class="tag-label-content"></span></span><span class="tag-body"><span class="tag-body-content"></span></span></span></template>
<!-- Extra -->
<template id="footer-notification-template"><div class="footer-notification scrollbar-inverse">
diff --git a/ext/js/display/display-generator.js b/ext/js/display/display-generator.js
index d02e2d9c..9b451995 100644
--- a/ext/js/display/display-generator.js
+++ b/ext/js/display/display-generator.js
@@ -413,15 +413,16 @@ class DisplayGenerator {
}
_createTag(details) {
+ const {notes, name, category, redundant} = details;
const node = this._templates.instantiate('tag');
- const inner = node.querySelector('.tag-inner');
+ const inner = node.querySelector('.tag-label-content');
- node.title = details.notes;
- this._setTextContent(inner, details.name);
- node.dataset.details = details.notes || details.name;
- node.dataset.category = details.category;
- if (details.redundant) { node.dataset.redundant = 'true'; }
+ node.title = notes;
+ this._setTextContent(inner, name);
+ node.dataset.details = notes || name;
+ node.dataset.category = category;
+ if (redundant) { node.dataset.redundant = 'true'; }
return node;
}
diff --git a/ext/js/display/display.js b/ext/js/display/display.js
index 35f22718..517b391d 100644
--- a/ext/js/display/display.js
+++ b/ext/js/display/display.js
@@ -787,6 +787,9 @@ class Display extends EventDispatcher {
}
_showTagNotification(tagNode) {
+ tagNode = tagNode.parentNode;
+ if (tagNode === null) { return; }
+
if (this._tagNotification === null) {
const node = this._displayGenerator.createEmptyFooterNotification();
node.classList.add('click-scannable');
@@ -1677,7 +1680,7 @@ class Display extends EventDispatcher {
this._addMultipleEventListeners(entry, '.action-view-note', 'click', this._onNoteView.bind(this));
this._addMultipleEventListeners(entry, '.kanji-link', 'click', this._onKanjiLookup.bind(this));
this._addMultipleEventListeners(entry, '.debug-log-link', 'click', this._onDebugLogClick.bind(this));
- this._addMultipleEventListeners(entry, '.tag', 'click', this._onTagClick.bind(this));
+ this._addMultipleEventListeners(entry, '.tag-label', 'click', this._onTagClick.bind(this));
}
_updateDefinitionTextScanner(options) {