-
-
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
Showing
10 changed files
with
1,502 additions
and
381 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
public-hoist-pattern[]=*@nextui-org/* |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,19 @@ | ||
"use client"; | ||
"use client" | ||
|
||
import * as React from "react"; | ||
import { NextUIProvider } from "@nextui-org/system"; | ||
import { ThemeProvider as NextThemesProvider } from "next-themes"; | ||
import { ThemeProviderProps } from "next-themes/dist/types"; | ||
import * as React from "react" | ||
import { NextUIProvider } from "@nextui-org/react" | ||
import { ThemeProvider as NextThemesProvider } from "next-themes" | ||
import { ThemeProviderProps } from "next-themes/dist/types" | ||
|
||
export interface ProvidersProps { | ||
children: React.ReactNode; | ||
themeProps?: ThemeProviderProps; | ||
children: React.ReactNode | ||
themeProps?: ThemeProviderProps | ||
} | ||
|
||
export function Providers({ children, themeProps }: ProvidersProps) { | ||
return ( | ||
<NextUIProvider> | ||
<NextThemesProvider {...themeProps}>{children}</NextThemesProvider> | ||
</NextUIProvider> | ||
); | ||
return ( | ||
<NextUIProvider> | ||
<NextThemesProvider {...themeProps}>{children}</NextThemesProvider> | ||
</NextUIProvider> | ||
) | ||
} |
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,14 +1,14 @@ | ||
"use client"; | ||
"use client" | ||
|
||
import { useState } from "react"; | ||
import { Button } from "@nextui-org/button"; | ||
import { useState } from "react" | ||
import { Button } from "@nextui-org/react" | ||
|
||
export const Counter = () => { | ||
const [count, setCount] = useState(0); | ||
const [count, setCount] = useState(0) | ||
|
||
return ( | ||
<Button radius="full" onPress={() => setCount(count + 1)}> | ||
Count is {count} | ||
</Button> | ||
); | ||
}; | ||
return ( | ||
<Button radius="full" onPress={() => setCount(count + 1)}> | ||
Count is {count} | ||
</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 |
---|---|---|
@@ -1,77 +1,83 @@ | ||
"use client"; | ||
"use client" | ||
|
||
import { FC } from "react"; | ||
import { VisuallyHidden } from "@react-aria/visually-hidden"; | ||
import { SwitchProps, useSwitch } from "@nextui-org/switch"; | ||
import { useTheme } from "next-themes"; | ||
import {useIsSSR} from "@react-aria/ssr"; | ||
import clsx from "clsx"; | ||
import { FC } from "react" | ||
import { VisuallyHidden } from "@react-aria/visually-hidden" | ||
import { SwitchProps, useSwitch } from "@nextui-org/react" | ||
import { useTheme } from "next-themes" | ||
import { useIsSSR } from "@react-aria/ssr" | ||
import clsx from "clsx" | ||
|
||
import { SunFilledIcon, MoonFilledIcon } from "@/components/icons"; | ||
import { SunFilledIcon, MoonFilledIcon } from "@/components/icons" | ||
|
||
export interface ThemeSwitchProps { | ||
className?: string; | ||
classNames?: SwitchProps["classNames"]; | ||
className?: string | ||
classNames?: SwitchProps["classNames"] | ||
} | ||
|
||
export const ThemeSwitch: FC<ThemeSwitchProps> = ({ | ||
className, | ||
classNames, | ||
className, | ||
classNames, | ||
}) => { | ||
const { theme, setTheme } = useTheme(); | ||
const isSSR = useIsSSR(); | ||
const { theme, setTheme } = useTheme() | ||
const isSSR = useIsSSR() | ||
|
||
const onChange = () => { | ||
theme === "light" ? setTheme("dark") : setTheme("light"); | ||
}; | ||
const onChange = () => { | ||
theme === "light" ? setTheme("dark") : setTheme("light") | ||
} | ||
|
||
const { | ||
Component, | ||
slots, | ||
isSelected, | ||
getBaseProps, | ||
getInputProps, | ||
getWrapperProps, | ||
} = useSwitch({ | ||
isSelected: theme === "light" || isSSR, | ||
"aria-label": `Switch to ${theme === "light" || isSSR ? "dark" : "light"} mode`, | ||
onChange, | ||
}); | ||
const { | ||
Component, | ||
slots, | ||
isSelected, | ||
getBaseProps, | ||
getInputProps, | ||
getWrapperProps, | ||
} = useSwitch({ | ||
isSelected: theme === "light" || isSSR, | ||
"aria-label": `Switch to ${ | ||
theme === "light" || isSSR ? "dark" : "light" | ||
} mode`, | ||
onChange, | ||
}) | ||
|
||
return ( | ||
<Component | ||
{...getBaseProps({ | ||
className: clsx( | ||
"px-px transition-opacity hover:opacity-80 cursor-pointer", | ||
className, | ||
classNames?.base | ||
), | ||
})} | ||
> | ||
<VisuallyHidden> | ||
<input {...getInputProps()} /> | ||
</VisuallyHidden> | ||
<div | ||
{...getWrapperProps()} | ||
className={slots.wrapper({ | ||
class: clsx( | ||
[ | ||
"w-auto h-auto", | ||
"bg-transparent", | ||
"rounded-lg", | ||
"flex items-center justify-center", | ||
"group-data-[selected=true]:bg-transparent", | ||
"!text-default-500", | ||
"pt-px", | ||
"px-0", | ||
"mx-0", | ||
], | ||
classNames?.wrapper | ||
), | ||
})} | ||
> | ||
{!isSelected || isSSR ? <SunFilledIcon size={22} /> : <MoonFilledIcon size={22} />} | ||
</div> | ||
</Component> | ||
); | ||
}; | ||
return ( | ||
<Component | ||
{...getBaseProps({ | ||
className: clsx( | ||
"px-px transition-opacity hover:opacity-80 cursor-pointer", | ||
className, | ||
classNames?.base | ||
), | ||
})} | ||
> | ||
<VisuallyHidden> | ||
<input {...getInputProps()} /> | ||
</VisuallyHidden> | ||
<div | ||
{...getWrapperProps()} | ||
className={slots.wrapper({ | ||
class: clsx( | ||
[ | ||
"w-auto h-auto", | ||
"bg-transparent", | ||
"rounded-lg", | ||
"flex items-center justify-center", | ||
"group-data-[selected=true]:bg-transparent", | ||
"!text-default-500", | ||
"pt-px", | ||
"px-0", | ||
"mx-0", | ||
], | ||
classNames?.wrapper | ||
), | ||
})} | ||
> | ||
{!isSelected || isSSR ? ( | ||
<SunFilledIcon size={22} /> | ||
) : ( | ||
<MoonFilledIcon size={22} /> | ||
)} | ||
</div> | ||
</Component> | ||
) | ||
} |
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
Oops, something went wrong.