Email filter: custom dropdown with SVG icons for each option

The All/Unread/Favorites/etc selector was a native <select>, which
can't render SVG inside <option>. Replace it with a custom picker
that:

- Keeps the existing <select id="email-lib-filter"> as the value
  store (hidden via display:none). All existing 'change' listeners
  keep working — the picker just dispatches a change event after
  updating the select's value.
- Renders a styled button + drop-out menu built from the select's
  options (preserves optgroup labels like 'Tags').
- Each option carries an SVG icon: lines for All, ringed dot for
  Unread, star for Favorites, empty checkbox for Undone, bell for
  Reminders, reply arrow for Unanswered/Reply-soon, clock for
  Pending, calendar-x for Stale, exclamation-triangle for Urgent,
  ban for Spam, newsletter and megaphone for the marketing tags.
- Icons use var(--accent) so they pick up the user's theme color.
- Click outside / Esc closes the menu (Esc handler is capture-phase
  + stopPropagation so it doesn't bubble to the modal-close listener
  and shut the whole email window).

CSS scoped under .email-filter-picker.
This commit is contained in:
pewdiepie-archdaemon
2026-06-11 12:53:39 +09:00
parent df908b4c11
commit 9dfea188bf
2 changed files with 238 additions and 1 deletions
+124
View File
@@ -11046,6 +11046,130 @@ textarea.memory-add-input {
border-color: var(--red);
}
/* Custom email filter picker (All / Unread / Favorites / ). Replaces the
native <select> so options can carry SVG icons. The hidden source
<select id="email-lib-filter"> is the value store and dispatches
'change' on selection. */
.email-filter-picker {
position: relative;
top: 3px;
}
.email-filter-btn {
display: flex;
align-items: center;
gap: 6px;
width: 100%;
background: var(--bg);
color: var(--fg);
border: 1px solid var(--border);
border-radius: 6px;
font-family: inherit;
font-size: 11px;
height: 24px;
padding: 0 8px 0 8px;
cursor: pointer;
text-align: left;
transition: border-color 0.12s, background 0.12s;
}
.email-filter-btn:hover { border-color: color-mix(in srgb, var(--accent, var(--red)) 50%, var(--border)); }
.email-filter-btn:focus-visible {
outline: none;
border-color: var(--accent, var(--red));
}
.email-filter-current {
flex: 1;
display: inline-flex;
align-items: center;
gap: 6px;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.email-filter-icon {
display: inline-flex;
align-items: center;
justify-content: center;
width: 13px;
height: 13px;
color: var(--accent, var(--red));
flex-shrink: 0;
}
.email-filter-icon svg { width: 13px; height: 13px; }
.email-filter-label {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.email-filter-caret {
flex-shrink: 0;
opacity: 0.6;
transition: transform 0.15s;
}
.email-filter-picker .email-filter-btn[aria-expanded="true"] .email-filter-caret {
transform: rotate(180deg);
}
.email-filter-menu {
position: absolute;
top: calc(100% + 4px);
left: 0;
right: 0;
z-index: 100;
max-height: 320px;
overflow-y: auto;
background: var(--panel, var(--bg));
border: 1px solid var(--border);
border-radius: 8px;
box-shadow: 0 6px 20px rgba(0,0,0,0.22);
padding: 4px;
display: flex;
flex-direction: column;
gap: 1px;
}
.email-filter-menu[hidden] { display: none; }
.email-filter-group {
font-size: 9px;
font-weight: 600;
letter-spacing: 0.6px;
text-transform: uppercase;
opacity: 0.55;
padding: 8px 9px 3px;
}
.email-filter-item {
all: unset;
display: flex;
align-items: center;
gap: 8px;
width: 100%;
padding: 6px 9px;
border-radius: 5px;
font-size: 12px;
cursor: pointer;
color: var(--fg);
box-sizing: border-box;
}
.email-filter-item:hover,
.email-filter-item:focus-visible {
background: color-mix(in srgb, var(--fg) 8%, transparent);
}
.email-filter-item-icon {
display: inline-flex;
align-items: center;
justify-content: center;
width: 14px;
height: 14px;
color: var(--accent, var(--red));
flex-shrink: 0;
}
.email-filter-item-icon svg { width: 13px; height: 13px; }
.email-filter-item-label {
flex: 1;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
/* Item metadata row */
.memory-item-meta {
display: flex;