Skip to content

Build your personal knowledge base with Trilium Notes

fix(client): give the icon picker button its own stylesheet

Elian Dorancf3ef951b604
diff --git a/apps/client/src/widgets/collections/board/index.css b/apps/client/src/widgets/collections/board/index.css
index f4078c67ce..9edd9d053a 100644
--- a/apps/client/src/widgets/collections/board/index.css
+++ b/apps/client/src/widgets/collections/board/index.css
@@ -571,7 +571,7 @@ body.mobile .board-view-container .board-add-column {
}
/* Centred on the first line, in a box the size of the glyph. The size is rounded to whole pixels,
- as `note_icon.css` rounds the picker's glyph. */
+ as `IconPickerButton.css` rounds the picker's glyph. */
.board-view-container .board-note > .title > .icon {
position: absolute;
inset-inline-start: var(--card-icon-inset);
@@ -1039,7 +1039,7 @@ body#trilium-app.motion-disabled .board-view.editing-open :is(
* worked out where it is used, and both sit in the card's own font.
*/
.board-view-container .title-editor-field .title-editor-icon {
- /* Rounded here, not in `note_icon.css`: that file rounds the glyph but not the box, and the
+ /* Rounded here, not in `IconPickerButton.css`: that file rounds the glyph but not the box, and the
insets below are computed from the box. */
--note-icon-size: round(var(--card-icon-size), 1px);
--note-icon-container-padding-size: 4px;
diff --git a/apps/client/src/widgets/note_icon.css b/apps/client/src/widgets/note_icon.css
index ce7244e69f..bdf0fe0519 100644
--- a/apps/client/src/widgets/note_icon.css
+++ b/apps/client/src/widgets/note_icon.css
@@ -1,125 +1,3 @@
div.note-icon-root {
display: contents;
}
-
-div.note-icon-widget {
- /* The size of the icon */
- --note-icon-size: 30px;
- /* The padding size for the icon container */
- --note-icon-container-padding-size: 10px;
- contain: unset;
-}
-
-.note-icon-widget button.note-icon {
- /* `1em` is this button's font size, which `--note-icon-size` already set: naming that variable
- here again would scale a value given in `em` a second time. */
- --size: calc(1em + var(--note-icon-container-padding-size) * 2);
-
- width: var(--size);
- height: var(--size);
- padding: 0;
- border: 1px solid transparent;
- background-color: transparent;
- color: var(--muted-text-color);
- cursor: pointer;
- font-size: var(--note-icon-size);
-}
-
-/* A glyph rasterises on whole pixels while the disc behind it does not, so a gap of half a pixel
- between the two puts the icon high or low depending on where the widget lands on the page.
- Rounding both leaves a gap of twice the ring, which is always whole. */
-@supports (width: round(1px, 1px)) {
- .note-icon-widget button.note-icon {
- --size: calc(1em + round(var(--note-icon-container-padding-size), 1px) * 2);
-
- font-size: round(var(--note-icon-size), 1px);
- }
-}
-
-.note-icon-widget button.note-icon:disabled {
- cursor: default;
- opacity: .75;
-}
-
-.note-icon-widget .dropdown-menu {
- border-radius: 10px;
- border-width: 2px;
- box-shadow: 10px 10px 93px -25px black;
- --padding: 0;
- padding: 0 !important;
- overflow: clip;
-
- .filter-row {
- padding: 10px 15px 0;
- }
-}
-
-.note-icon-widget button.note-icon {
- --input-focus-outline-color: var(--note-icon-hover-background-color);
-
- position: relative;
- background: transparent !important;
-
- &, &:hover {
- border-radius: 50%;
- }
-
- /* The icon */
- &::before {
- position: relative;
- z-index: 1;
- color: var(--note-icon-custom-color, var(--note-icon-color));
- }
-
- /* The background circle */
- &:not(.bx-empty:disabled)::after {
- content: "";
- position: absolute;
- inset: 0;
- border-radius: 50%;
- background: var(--note-icon-custom-background-color, var(--note-icon-background-color));
- }
-
- &:focus-visible {
- outline: 2px solid var(--note-icon-custom-color, var(--note-icon-color));
- }
-
- &:hover:not(.bx-empty:disabled)::after {
- background: var(--note-icon-hover-custom-background-color, var(--note-icon-hover-background-color));
- transition: background 200ms ease-out;
- }
-}
-
-body.mobile .modal.icon-switcher {
- .modal-dialog {
- left: 0;
- right: 0;
- margin: unset;
- transform: unset;
- max-width: 100%;
- height: 100%;
- }
-
- .modal-body {
- padding: 0;
- display: flex;
- flex-direction: column;
-
- > .filter-row {
- padding: 0.25em var(--bs-modal-padding) 0.5em var(--bs-modal-padding);
- border-bottom: 1px solid var(--main-border-color);
- }
- }
-
- .icon-list {
- --scroll-fade-top: 0px;
- --icon-list-inset: 0px;
- margin: auto;
- flex-grow: 1;
- height: 100%;
-
- span {
- padding: 12px;
- }
- }
-}
diff --git a/apps/client/src/widgets/react/IconPicker.tsx b/apps/client/src/widgets/react/IconPicker.tsx
index a862614926..5aa842c82b 100644
--- a/apps/client/src/widgets/react/IconPicker.tsx
+++ b/apps/client/src/widgets/react/IconPicker.tsx
@@ -1,4 +1,5 @@
import "./IconPicker.css";
+import "./IconPickerButton.css";
import { IconRegistry } from "@triliumnext/commons";
import type { Tooltip } from "bootstrap";
diff --git a/apps/client/src/widgets/react/IconPickerButton.css b/apps/client/src/widgets/react/IconPickerButton.css
new file mode 100644
index 0000000000..badf045035
--- /dev/null
+++ b/apps/client/src/widgets/react/IconPickerButton.css
@@ -0,0 +1,121 @@
+div.note-icon-widget {
+ /* The size of the icon */
+ --note-icon-size: 30px;
+ /* The padding size for the icon container */
+ --note-icon-container-padding-size: 10px;
+ contain: unset;
+}
+
+.note-icon-widget button.note-icon {
+ /* `1em` is this button's font size, which `--note-icon-size` already set: naming that variable
+ here again would scale a value given in `em` a second time. */
+ --size: calc(1em + var(--note-icon-container-padding-size) * 2);
+
+ width: var(--size);
+ height: var(--size);
+ padding: 0;
+ border: 1px solid transparent;
+ background-color: transparent;
+ color: var(--muted-text-color);
+ cursor: pointer;
+ font-size: var(--note-icon-size);
+}
+
+/* A glyph rasterises on whole pixels while the disc behind it does not, so a gap of half a pixel
+ between the two puts the icon high or low depending on where the widget lands on the page.
+ Rounding both leaves a gap of twice the ring, which is always whole. */
+@supports (width: round(1px, 1px)) {
+ .note-icon-widget button.note-icon {
+ --size: calc(1em + round(var(--note-icon-container-padding-size), 1px) * 2);
+
+ font-size: round(var(--note-icon-size), 1px);
+ }
+}
+
+.note-icon-widget button.note-icon:disabled {
+ cursor: default;
+ opacity: .75;
+}
+
+.note-icon-widget .dropdown-menu {
+ border-radius: 10px;
+ border-width: 2px;
+ box-shadow: 10px 10px 93px -25px black;
+ --padding: 0;
+ padding: 0 !important;
+ overflow: clip;
+
+ .filter-row {
+ padding: 10px 15px 0;
+ }
+}
+
+.note-icon-widget button.note-icon {
+ --input-focus-outline-color: var(--note-icon-hover-background-color);
+
+ position: relative;
+ background: transparent !important;
+
+ &, &:hover {
+ border-radius: 50%;
+ }
+
+ /* The icon */
+ &::before {
+ position: relative;
+ z-index: 1;
+ color: var(--note-icon-custom-color, var(--note-icon-color));
+ }
+
+ /* The background circle */
+ &:not(.bx-empty:disabled)::after {
+ content: "";
+ position: absolute;
+ inset: 0;
+ border-radius: 50%;
+ background: var(--note-icon-custom-background-color, var(--note-icon-background-color));
+ }
+
+ &:focus-visible {
+ outline: 2px solid var(--note-icon-custom-color, var(--note-icon-color));
+ }
+
+ &:hover:not(.bx-empty:disabled)::after {
+ background: var(--note-icon-hover-custom-background-color, var(--note-icon-hover-background-color));
+ transition: background 200ms ease-out;
+ }
+}
+
+body.mobile .modal.icon-switcher {
+ .modal-dialog {
+ left: 0;
+ right: 0;
+ margin: unset;
+ transform: unset;
+ max-width: 100%;
+ height: 100%;
+ }
+
+ .modal-body {
+ padding: 0;
+ display: flex;
+ flex-direction: column;
+
+ > .filter-row {
+ padding: 0.25em var(--bs-modal-padding) 0.5em var(--bs-modal-padding);
+ border-bottom: 1px solid var(--main-border-color);
+ }
+ }
+
+ .icon-list {
+ --scroll-fade-top: 0px;
+ --icon-list-inset: 0px;
+ margin: auto;
+ flex-grow: 1;
+ height: 100%;
+
+ span {
+ padding: 12px;
+ }
+ }
+}