Prefer component and utility classes when possible

This commit is contained in:
Jason Zimdars
2025-12-08 17:53:40 -06:00
parent 6e19e17ca4
commit 18c0a78759
2 changed files with 22 additions and 60 deletions
+12 -50
View File
@@ -1,58 +1,20 @@
@layer components {
.theme-switcher {
--gap: 8px;
align-items: center;
display: flex;
flex-wrap: wrap;
gap: var(--gap);
inline-size: 100%;
justify-content: center;
margin: 1rem auto;
max-inline-size: 100%;
}
.theme-switcher__btn {
--btn-border-radius: 0.4em;
align-items: center;
aspect-ratio: 5/3;
background-color: var(--color-ink-lightest);
border: none;
border-radius: 0.5em;
color: inherit;
cursor: pointer;
display: flex;
flex-basis: calc((100% - var(--gap) * 2) / 3);
flex-direction: column;
font-size: var(--text-small);
line-height: 1;
justify-content: center;
overflow: hidden;
padding: 0.5em;
position: relative;
row-gap: 0.3lh;
text-align: center;
.icon {
--icon-size: 2em;
}
span {
display: block;
text-wrap: nowrap;
}
@media (max-width: 639px) {
font-size: var(--text-x-small);
font-weight: 500;
flex-direction: column;
}
}
.theme-switcher__btn {
--btn-background: var(--color-ink-lightest);
--btn-border-radius: 0.4em;
--btn-border-size: 0;
--btn-gap: 0.3lh;
--icon-size: 2em;
@media (any-hover: hover) {
&:hover {
background-color: var(--color-ink-lighter);
}
}
flex: 1 0 33%;
flex-direction: column;
position: relative;
white-space: nowrap;
&[aria-selected="true"] {
background-color: var(--color-selected);
+10 -10
View File
@@ -1,20 +1,20 @@
<div class="flex flex-column align-center gap txt-medium--responsive txt-medium margin-block-start-double">
<strong class="txt-medium">Appearance</strong>
<section>
<strong class="divider txt-large">Appearance</strong>
<div class="theme-switcher">
<button type="button" class="theme-switcher__btn" data-action="click->theme#setLight" data-theme-target="lightBtn">
<div class="theme-switcher flex gap max-width justify-center txt-small margin-block-start-half">
<button type="button" class="btn theme-switcher__btn" data-action="click->theme#setLight" data-theme-target="lightBtn">
<%= icon_tag "sun" %>
<span>Always light</span>
<span class="overflow-ellipsis">Always light</span>
</button>
<button type="button" class="theme-switcher__btn" data-action="click->theme#setDark" data-theme-target="darkBtn">
<button type="button" class="btn theme-switcher__btn" data-action="click->theme#setDark" data-theme-target="darkBtn">
<%= icon_tag "moon" %>
<span>Always dark</span>
<span class="overflow-ellipsis">Always dark</span>
</button>
<button type="button" class="theme-switcher__btn" data-action="click->theme#setAuto" data-theme-target="autoBtn">
<button type="button" class="btn theme-switcher__btn" data-action="click->theme#setAuto" data-theme-target="autoBtn">
<%= icon_tag "monitor" %>
<span>Same as OS</span>
<span class="overflow-ellipsis">Same as OS</span>
</button>
</div>
</div>
</section>