Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use system theme if there is no preference #1074

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion apps/ui/src/composables/useUserSkin.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
type Skin = 'dark' | 'light' | 'none';

const preferredColor = usePreferredColorScheme();
export function useUserSkin() {
Comment on lines +3 to 4
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should always have new line between variable and a function

Suggested change
const preferredColor = usePreferredColorScheme();
export function useUserSkin() {
const preferredColor = usePreferredColorScheme();
export function useUserSkin() {

Copy link
Member Author

@ChaituVR ChaituVR Dec 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have this in a few other places on this repo, better to add a new eslint rule snapshot-labs/config#27

const store = useStorage<Skin>('skin', 'none');
const currentMode = computed(() =>
['light', 'none'].includes(store.value) ? 'light' : 'dark'
store.value === 'none'
? (preferredColor.value as 'dark' | 'light')
: store.value
);

function toggleSkin() {
Expand Down