-
Notifications
You must be signed in to change notification settings - Fork 1.4k
docs: light mode dark mode #8050
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
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
f7675d9
feat(docs): add ThemeScript component to root
JerryWu1234 ec44bf9
feat(docs): enhance theme toggle functionality and styles
JerryWu1234 df13812
Merge branch 'QwikDev:main' into light-mode-dark-mode
JerryWu1234 9f6eb31
Merge branch 'main' into light-mode-dark-mode
JerryWu1234 a871af8
feat: enhance dark mode support and clean up theme toggle components
JerryWu1234 94d105b
feat: improve dark mode styles and remove unused theme toggle components
JerryWu1234 5088ec8
fix: update SVG logos to use consistent fill color for dark mode
JerryWu1234 f70566b
Merge branch 'main' into light-mode-dark-mode
JerryWu1234 68c7d21
refactor: streamline theme handling and remove unused dark mode styles
JerryWu1234 c4a2fd4
refactor: update SVG logos to use 'currentColor' for fill attribute
JerryWu1234 12441e5
refactor: reorganize theme handling and remove deprecated theme script
JerryWu1234 fd65cc9
refactor: enhance theme toggle component for better responsiveness
JerryWu1234 183646c
refactor: extract theme loading logic into a separate module
JerryWu1234 f68330f
refactor: remove IIFE from load-theme.js for cleaner code structure
JerryWu1234 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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.
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 @@ | ||
import { component$ } from '@builder.io/qwik'; | ||
|
||
interface BrillianceIconProps { | ||
class?: string; | ||
} | ||
|
||
export const BrillianceIcon = component$<BrillianceIconProps>(({ class: className, ...props }) => { | ||
return ( | ||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
fill="currentColor" | ||
class={className} | ||
viewBox="0 0 16 16" | ||
{...props} | ||
> | ||
<path d="M8 16A8 8 0 1 1 8 0a8 8 0 0 1 0 16M1 8a7 7 0 0 0 7 7 3.5 3.5 0 1 0 0-7 3.5 3.5 0 1 1 0-7 7 7 0 0 0-7 7" /> | ||
</svg> | ||
); | ||
}); |
This file contains hidden or 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,25 @@ | ||
import { component$ } from '@builder.io/qwik'; | ||
|
||
interface MoonIconProps { | ||
class?: string; | ||
} | ||
|
||
export const MoonIcon = component$<MoonIconProps>(({ class: className, ...props }) => { | ||
return ( | ||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
fill="none" | ||
viewBox="0 0 24 24" | ||
stroke-width="1.5" | ||
stroke="currentColor" | ||
class={className} | ||
{...props} | ||
> | ||
<path | ||
stroke-linecap="round" | ||
stroke-linejoin="round" | ||
d="M21.752 15.002A9.72 9.72 0 0 1 18 15.75c-5.385 0-9.75-4.365-9.75-9.75 0-1.33.266-2.597.748-3.752A9.753 9.753 0 0 0 3 11.25C3 16.635 7.365 21 12.75 21a9.753 9.753 0 0 0 9.002-5.998Z" | ||
/> | ||
</svg> | ||
); | ||
}); |
This file contains hidden or 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,25 @@ | ||
import { component$ } from '@builder.io/qwik'; | ||
|
||
interface SunIconProps { | ||
class?: string; | ||
} | ||
|
||
export const SunIcon = component$<SunIconProps>(({ class: className, ...props }) => { | ||
return ( | ||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
fill="none" | ||
viewBox="0 0 24 24" | ||
stroke-width="1.5" | ||
stroke="currentColor" | ||
class={className} | ||
{...props} | ||
> | ||
<path | ||
stroke-linecap="round" | ||
stroke-linejoin="round" | ||
d="M12 3v2.25m6.364.386-1.591 1.591M21 12h-2.25m-.386 6.364-1.591-1.591M12 18.75V21m-4.773-4.227-1.591 1.591M5.25 12H3m4.227-4.773L5.636 5.636M15.75 12a3.75 3.75 0 1 1-7.5 0 3.75 3.75 0 0 1 7.5 0Z" | ||
/> | ||
</svg> | ||
); | ||
}); |
This file contains hidden or 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,16 @@ | ||
try { | ||
const getItem = localStorage.getItem('theme-preference'); | ||
const el = document.firstElementChild; | ||
if (!el) { | ||
throw new Error('documentElement not found'); | ||
} | ||
|
||
if (getItem === 'light' || getItem === 'dark') { | ||
el.setAttribute('data-theme', getItem); | ||
} else { | ||
const isDark = window.matchMedia('(prefers-color-scheme: dark)').matches; | ||
el.setAttribute('data-theme', isDark ? 'dark' : 'light'); | ||
} | ||
} catch (err) { | ||
console.error(err); | ||
} |
84 changes: 0 additions & 84 deletions
84
packages/docs/src/components/theme-toggle/sun-and-moon.css
This file was deleted.
Oops, something went wrong.
25 changes: 0 additions & 25 deletions
25
packages/docs/src/components/theme-toggle/sun-and-moon.tsx
This file was deleted.
Oops, something went wrong.
18 changes: 18 additions & 0 deletions
18
packages/docs/src/components/theme-toggle/theme-script.tsx
This file contains hidden or 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,18 @@ | ||
import loadThemeScript from './load-theme?compiled-string'; | ||
export const themeStorageKey = 'theme-preference'; | ||
|
||
export const colorSchemeChangeListener = (onColorSchemeChange: (isDark: boolean) => void) => { | ||
const listener = ({ matches: isDark }: MediaQueryListEvent) => { | ||
onColorSchemeChange(isDark); | ||
}; | ||
window | ||
.matchMedia('(prefers-color-scheme: dark)') | ||
.addEventListener('change', (event) => listener(event)); | ||
|
||
return () => | ||
window.matchMedia('(prefers-color-scheme: dark)').removeEventListener('change', listener); | ||
}; | ||
|
||
export const ThemeScript = () => { | ||
return <script dangerouslySetInnerHTML={loadThemeScript} />; | ||
}; |
40 changes: 12 additions & 28 deletions
40
packages/docs/src/components/theme-toggle/theme-toggle.css
This file contains hidden or 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,33 +1,17 @@ | ||
.theme-toggle { | ||
--size: 22px; | ||
--icon-fill: hsl(210 10% 15%); | ||
--icon-fill-hover: hsl(210 10% 30%); | ||
|
||
display: block; | ||
|
||
background: none; | ||
border: none; | ||
padding: 0; | ||
|
||
inline-size: var(--size); | ||
block-size: var(--size); | ||
aspect-ratio: 1; | ||
border-radius: 50%; | ||
|
||
cursor: pointer; | ||
touch-action: manipulation; | ||
-webkit-tap-highlight-color: transparent; | ||
|
||
outline-offset: 5px; | ||
.themeIcon { | ||
opacity: 0; | ||
transition: opacity 400ms ease-in-out; | ||
width: 25px; | ||
height: 25px; | ||
} | ||
|
||
[data-theme='dark'] .theme-toggle { | ||
--icon-fill: hsl(210 10% 100%); | ||
--icon-fill-hover: hsl(210 15% 70%); | ||
.themeIcon.auto { | ||
width: 21px; | ||
height: 21px; | ||
} | ||
|
||
.theme-toggle > svg { | ||
inline-size: 100%; | ||
block-size: 100%; | ||
stroke-linecap: round; | ||
button.pref-light .themeIcon.light, | ||
button.pref-dark .themeIcon.dark, | ||
button.pref-auto .themeIcon.auto { | ||
opacity: 1; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.