Skip to content

Build your personal knowledge base with Trilium Notes

feat(share): style the search box like the app's quick search

Elian Doran1cfbb2daf8f1
diff --git a/packages/share-theme/src/base.css b/packages/share-theme/src/base.css
index 6be88c60a8..172114afb6 100644
--- a/packages/share-theme/src/base.css
+++ b/packages/share-theme/src/base.css
@@ -35,6 +35,15 @@ html.theme-light {
--tree-item-active-background: #FFFFFF;
--tree-item-active-color: #000000;
--tree-item-active-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
+ /* The quick search colors of `theme-next-light.css`. */
+ --quick-search-background: #00000012;
+ --quick-search-color: #06060682;
+ --quick-search-hover-background: #00000020;
+ --quick-search-focus-border: #00000029;
+ --quick-search-focus-background: #ffffff80;
+ --quick-search-focus-color: #000000;
+ --quick-search-button-active-background: rgba(0, 0, 0, 0.11);
+ --quick-search-button-active-color: #383838;
--mermaid-theme: default;
color-scheme: light;
}
@@ -57,6 +66,15 @@ html.theme-dark {
--tree-item-active-background: #ffffff25;
--tree-item-active-color: #dfdfdf;
--tree-item-active-shadow: 1px 1px 2px rgba(0, 0, 0, 0.6);
+ /* The quick search colors of `theme-next-dark.css`. */
+ --quick-search-background: #ffffff12;
+ --quick-search-color: #ffffff52;
+ --quick-search-hover-background: #ffffff1f;
+ --quick-search-focus-border: #80808095;
+ --quick-search-focus-background: #ffffff1f;
+ --quick-search-focus-color: #ffffff;
+ --quick-search-button-active-background: #ffffff73;
+ --quick-search-button-active-color: #000000;
--mermaid-theme: dark;
color-scheme: dark;
}
diff --git a/packages/share-theme/src/page/search.css b/packages/share-theme/src/page/search.css
index c6808c389b..5449ee4f2d 100644
--- a/packages/share-theme/src/page/search.css
+++ b/packages/share-theme/src/page/search.css
@@ -1,26 +1,73 @@
+/* The quick search box of the app's default theme (`widgets/quick_search.css`). */
.search-item {
display: flex;
align-items: center;
position: relative;
+ border: 2px solid transparent;
+ border-radius: 6px;
+ background: var(--quick-search-background);
+ transition: background-color 200ms ease-in;
+}
+
+.search-item:hover {
+ background: var(--quick-search-hover-background);
+ transition: background-color 75ms ease-out;
+}
+
+.search-item:focus-within {
+ border-color: var(--quick-search-focus-border);
+ background: var(--quick-search-focus-background);
+ transition: background-color 100ms ease-out;
}
.search-input {
- color: var(--text-primary);
- background: var(--background-highlight);
- outline: 0;
- border: 0;
flex: 1;
- padding: 5px 5px 5px 32px;
- width: 200px;
- border-radius: 6px;
+ min-width: 0;
+ width: 100%;
+ padding: 3px 8px;
+ border: 0;
+ outline: 0;
+ background: transparent;
+ color: var(--text-primary);
+ font: inherit;
+ line-height: 24px;
+}
+
+.search-input::placeholder {
+ color: var(--quick-search-color);
+ opacity: 1;
}
-.search-icon {
+.search-item:focus-within .search-input {
+ color: var(--quick-search-focus-color);
+}
+
+/* Outranks the icon pack's `.bx { display: inline-block }`, which the page loads after this. */
+.search-item .search-icon {
display: flex;
- color: var(--text-primary);
- position: absolute;
- font-size: 20px;
- left: 5px;
+ flex: none;
+ align-items: center;
+ justify-content: center;
+ width: 25px;
+ height: 25px;
+ margin-inline-end: 8px;
+ border-radius: 50%;
+ color: var(--quick-search-color);
+ font-size: 16px;
+ transition: background-color 200ms ease-in;
+}
+
+.search-item:focus-within:has(.search-input:not(:placeholder-shown)) .search-icon {
+ background: var(--quick-search-button-active-background);
+ color: var(--quick-search-button-active-color);
+ transition: background-color 500ms ease-out;
+}
+
+@media (prefers-reduced-motion: reduce) {
+ .search-item,
+ .search-icon {
+ transition: none;
+ }
}
.search-results {
diff --git a/packages/share-theme/src/templates/page.ejs b/packages/share-theme/src/templates/page.ejs
index 90a73ca6e6..482154abd7 100644
--- a/packages/share-theme/src/templates/page.ejs
+++ b/packages/share-theme/src/templates/page.ejs
@@ -56,8 +56,8 @@
</div>
<% if (navigation.length) { %>
<div class="search-item">
+ <input type="text" class="search-input" placeholder="<%= t("share_theme.search_placeholder") %>" aria-label="<%= t("share_theme.search_placeholder") %>">
<span class="search-icon tn-icon bx bx-search" aria-hidden="true"></span>
- <input type="text" class="search-input" placeholder="<%= t("share_theme.search_placeholder") %>">
</div>
<% } %>
</div>