-
Notifications
You must be signed in to change notification settings - Fork 13
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 #2002 from codecrafters-io/add-dark-mode-toggle
add dark mode toggle
- Loading branch information
Showing
27 changed files
with
157 additions
and
79 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
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,19 @@ | ||
<TertiaryButton class="pl-2 {{if @isSelected 'border-teal-500 hover:bg-white'}}" ...attributes data-test-dark-mode-toggle-option> | ||
<div class="flex items-center text-sm sm:text-base {{if @isSelected 'text-teal-500' 'text-gray-600'}}"> | ||
<AnimatedContainer class="overflow-hidden"> | ||
{{#animated-if @isSelected rules=this.rules duration=100}} | ||
{{! wrapping div is required for animations to work }} | ||
<div class="flex"> | ||
{{svg-jar "check-circle" class="w-4 h-4 mr-1.5 text-teal-500 flex-shrink-0"}} | ||
</div> | ||
{{else}} | ||
{{! wrapping div is required for animations to work }} | ||
<div class="flex"> | ||
{{svg-jar "check" class="w-4 h-4 mr-1.5 text-gray-400 flex-shrink-0"}} | ||
</div> | ||
{{/animated-if}} | ||
</AnimatedContainer> | ||
|
||
{{yield}} | ||
</div> | ||
</TertiaryButton> |
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,31 @@ | ||
import Component from '@glimmer/component'; | ||
import { toRight, toLeft } from 'ember-animated/transitions/move-over'; | ||
|
||
export interface Signature { | ||
Element: HTMLButtonElement; | ||
|
||
Args: { | ||
isSelected: boolean; | ||
}; | ||
|
||
Blocks: { default: [] }; | ||
} | ||
|
||
export default class DarkModeToggleOptionComponent extends Component<Signature> { | ||
toRight = toRight; | ||
toLeft = toLeft; | ||
|
||
rules({ newItems }: { newItems: unknown[] }) { | ||
if (newItems[0]) { | ||
return toRight; | ||
} else { | ||
return toLeft; | ||
} | ||
} | ||
} | ||
|
||
declare module '@glint/environment-ember-loose/registry' { | ||
export default interface Registry { | ||
DarkModeToggleOption: typeof DarkModeToggleOptionComponent; | ||
} | ||
} |
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,9 +1,5 @@ | ||
{{#each this.possiblePreferences as |preference|}} | ||
{{#if (eq this.darkMode.localStoragePreference preference)}} | ||
<PrimaryButton @size="small" class="capitalize" {{on "click" (fn this.setPreference preference)}}>{{or preference "unset"}}</PrimaryButton> | ||
{{else}} | ||
<TertiaryButton @size="small" class="capitalize" {{on "click" (fn this.setPreference preference)}}>{{or preference "unset"}}</TertiaryButton> | ||
{{/if}} | ||
{{/each}} | ||
|
||
{{yield}} | ||
<DarkModeToggleOption @isSelected={{eq this.darkMode.localStoragePreference preference}} {{on "click" (fn this.setPreference preference)}}> | ||
{{or preference "unset"}} | ||
</DarkModeToggleOption> | ||
{{/each}} |
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 +1 @@ | ||
<div class="h-px bg-gray-100 my-6"></div> | ||
<div class="h-px bg-gray-100 my-6 dark:bg-gray-900"></div> |
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
15 changes: 15 additions & 0 deletions
15
app/components/settings/profile-page/dark-mode-section.hbs
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,15 @@ | ||
<Settings::FormSection @title="Dark Mode" @description="Choose when CodeCrafters should use dark mode."> | ||
<:belowDescription> | ||
<Pill @color="green"> | ||
{{svg-jar "shield-check" class="w-4 h-4 text-green-500 mr-1"}} | ||
Staff only | ||
|
||
<EmberTooltip @text="This feature is only available to CodeCrafters staff." /> | ||
</Pill> | ||
</:belowDescription> | ||
<:default> | ||
<div class="inline-flex items-center gap-3"> | ||
<DarkModeToggle /> | ||
</div> | ||
</:default> | ||
</Settings::FormSection> |
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,13 @@ | ||
import Component from '@glimmer/component'; | ||
|
||
interface Signature { | ||
Element: HTMLDivElement; | ||
} | ||
|
||
export default class DarkModeSectionComponent extends Component<Signature> {} | ||
|
||
declare module '@glint/environment-ember-loose/registry' { | ||
export default interface Registry { | ||
'Settings::ProfilePage::DarkModeSection': typeof DarkModeSectionComponent; | ||
} | ||
} |
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
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 was deleted.
Oops, something went wrong.
Oops, something went wrong.