Skip to content

Commit 86793a1

Browse files
feat: update dark/light toggle
1 parent 252f859 commit 86793a1

File tree

6 files changed

+34
-10
lines changed

6 files changed

+34
-10
lines changed

examples/guider/kitchen-sink/theme.config.tsx

-4
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ const siteTemplate = site('docs', {
1212
dropdown: [
1313
link('Documentation', '/docs/guides', { icon: 'fa6-solid:house' }),
1414
],
15-
// navigation: [
16-
// link('Email Support', '/docs/guides', { icon: 'fa6-solid:house' }),
17-
// link('Polymarket', 'https://polymarket.com/'),
18-
// ],
1915
});
2016

2117
export default defineTheme([

package.json

+3
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,8 @@
1616
"typescript": "^5.4.5",
1717
"vite": "^5.4.2",
1818
"vitest": "^1.6.0"
19+
},
20+
"dependencies": {
21+
"lucide-react": "^0.437.0"
1922
}
2023
}

packages/guider/src/client/partials/header/header.tsx

+11-6
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,17 @@ import { HeaderDropdown } from './dropdown';
1010
import { SidebarMobileNav } from './sidebar-mobile-nav';
1111
import { TopMobileNav } from './top-mobile-nav';
1212
import { HeaderSearch } from './search';
13+
import { Sun } from 'lucide-react';
14+
import { Moon } from 'lucide-react';
15+
1316

1417
export function HeaderInternal() {
1518
const ctx = useContext(GuiderLayoutContext);
19+
const [isDark, setIsDark] = useState(false);
1620
const { site, settings } = useGuider(ctx?.meta);
1721

22+
console.log(settings.colors.background);
23+
1824
const [isScrolledFromTop, setIsScrolledFromTop] = useState(false);
1925

2026
useEffect(() => {
@@ -43,7 +49,7 @@ export function HeaderInternal() {
4349
)}
4450
>
4551
<div className="gd-fixed neato-guider-overlay gd-transition-opacity gd-duration-150 gd-opacity-0 gd-inset-0 gd-bg-gradient-to-b gd-from-black/80 gd-to-transparent gd-z-[60] gd-pointer-events-none" />
46-
<div className="gd-flex gd-justify-between gd-mb-6">
52+
<div className="gd-flex gd-justify-between gd-mb-6 gd-items-center">
4753
<div className="gd-flex gd-items-center">
4854
<GuiderLogo />
4955
{site.dropdown.length > 0 ? (
@@ -63,11 +69,10 @@ export function HeaderInternal() {
6369
/>
6470
) : null}
6571
</div>
66-
{/* <div className="gd-flex gd-items-center">
67-
<span className="gd-inline-flex gd-items-center gd-justify-center gd-p-2 gd-bg-indigo-500 gd-rounded-md gd-shadow-lg">
68-
<svg className="gd-h-6 gd-w-6 gd-text-white" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" aria-hidden="true"></svg>
69-
</span>
70-
</div> */}
72+
{isDark ?
73+
<Moon onClick={() => setIsDark(false)} /> :
74+
<Sun onClick={() => setIsDark(true)} />
75+
}
7176
<div className="gd-flex md:gd-hidden gd-items-center">
7277
{site.navigation.length > 0 || site.github ? (
7378
<TopMobileNav

packages/guider/src/theme/components/layout.ts

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ const baseLayoutConfig: PopulatedLayoutSettings = {
2525
textLighter: '#9AB3BD',
2626
textHighlight: '#FFFFFF',
2727
background: '#050F13',
28+
backgroundLight: '#f5f9fa',
29+
backgroundDark: '#050F13',
2830
backgroundLighter: '#07171C',
2931
backgroundLightest: '#081E24',
3032
backgroundDarker: '#040C0F',

packages/guider/src/theme/components/settings.ts

+2
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ export type PopulatedLayoutSettings = {
5353
primaryLighter: string;
5454
primaryDarker: string;
5555
background: string;
56+
backgroundLight: string;
57+
backgroundDark: string;
5658
backgroundLighter: string;
5759
backgroundLightest: string;
5860
text: string;

pnpm-lock.yaml

+16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)