-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a66487d
commit fac43d1
Showing
10 changed files
with
86 additions
and
26 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
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
14 changes: 14 additions & 0 deletions
14
packages/ui/src/components/ThemeButton/ThemeButton.stories.tsx
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,14 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
|
||
import { ThemeButton } from './ThemeButton'; | ||
|
||
const meta = { | ||
component: ThemeButton, | ||
tags: [ 'autodocs' ] | ||
} satisfies Meta<typeof ThemeButton>; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Default: Story = {}; |
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,41 @@ | ||
'use client'; | ||
|
||
import { useContext } from 'react'; | ||
import { Button, ButtonProps } from '@nextui-org/react'; | ||
import { MoonIcon, SunIcon } from '@heroicons/react/24/solid'; | ||
|
||
import { DoobUiContext } from '@do-ob/ui/context'; | ||
|
||
/** | ||
* Theme switch properties. | ||
*/ | ||
export interface ThemeButtonProps extends ButtonProps { | ||
/** | ||
* The theme switch label. | ||
*/ | ||
children?: string; | ||
} | ||
|
||
/** | ||
* This button is used to toggle the theme of the application. It toggles between 'light' and 'dark' | ||
* class names that are applied to the html element of the document. | ||
*/ | ||
export function ThemeButton({ | ||
children, | ||
...props | ||
}: ThemeButtonProps) { | ||
|
||
const { mode, modeToggle } = useContext(DoobUiContext); | ||
|
||
return ( | ||
<Button | ||
onClick={modeToggle} | ||
startContent={mode === 'dark' ? <MoonIcon className="size-2/3" /> : <SunIcon className="size-2/3" />} | ||
isIconOnly={!children} | ||
aria-label="Toggle theme" | ||
{...props} | ||
> | ||
{children} | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,5 +37,3 @@ export function ThemeSwitch({ | |
</Switch> | ||
); | ||
} | ||
|
||
export default ThemeSwitch; |
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