-
Notifications
You must be signed in to change notification settings - Fork 579
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8559 from Turbo87/dark-mode
Implement dark mode via `light-dark()` fn
- Loading branch information
Showing
37 changed files
with
273 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<Dropdown local-class="dropdown" data-test-dark-mode-menu ...attributes as |dd|> | ||
<dd.Trigger @hideArrow={{true}} local-class="trigger" data-test-dark-mode-toggle> | ||
{{svg-jar this.icon local-class="icon"}} | ||
<span local-class="trigger-label">Change color scheme</span> | ||
</dd.Trigger> | ||
|
||
<dd.Menu local-class="menu" as |menu|> | ||
{{#each this.colorSchemes as |colorScheme|}} | ||
<menu.Item> | ||
<button | ||
local-class="menu-button {{if (eq colorScheme.mode this.colorScheme.scheme) 'selected'}}" | ||
type="button" | ||
{{on 'click' (fn this.colorScheme.set colorScheme.mode)}} | ||
> | ||
{{svg-jar colorScheme.svg local-class="icon"}} {{colorScheme.mode}} | ||
</button> | ||
</menu.Item> | ||
{{/each}} | ||
</dd.Menu> | ||
</Dropdown> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { inject as service } from '@ember/service'; | ||
import Component from '@glimmer/component'; | ||
|
||
export default class Header extends Component { | ||
/** @type {import("../services/dark-mode").default} */ | ||
@service colorScheme; | ||
|
||
colorSchemes = [ | ||
{ mode: 'light', svg: 'sun' }, | ||
{ mode: 'dark', svg: 'moon' }, | ||
{ mode: 'system', svg: 'color-mode' }, | ||
]; | ||
|
||
get icon() { | ||
return this.colorSchemes.find(({ mode }) => mode === this.colorScheme.scheme)?.svg; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
.dropdown { | ||
line-height: 1rem; | ||
} | ||
|
||
.icon { | ||
width: 1.4em; | ||
height: auto; | ||
} | ||
|
||
.trigger { | ||
background: none; | ||
border: 0; | ||
padding: 0; | ||
} | ||
|
||
.trigger-label { | ||
composes: sr-only from '../styles/shared/a11y.module.css' | ||
} | ||
|
||
.menu { | ||
right: 0; | ||
min-width: max-content; | ||
} | ||
|
||
.menu-button { | ||
composes: button-reset from '../styles/shared/buttons.module.css'; | ||
align-items: center; | ||
gap: var(--space-2xs); | ||
cursor: pointer; | ||
text-transform: capitalize; | ||
} | ||
|
||
.selected { | ||
background: light-dark(#e6e6e6, #404040); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
<button type="button" local-class="button" {{on "click" @toggle}} ...attributes> | ||
{{yield}} | ||
<span local-class="arrow"></span> | ||
{{#unless @hideArrow}} | ||
<span local-class="arrow"></span> | ||
{{/unless}} | ||
</button> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.