Skip to content
This repository was archived by the owner on Jun 18, 2024. It is now read-only.

Commit 2ae68e0

Browse files
authored
Merge pull request #14 from sonnat/master
2 parents 28b95ad + 9d4d708 commit 2ae68e0

File tree

4 files changed

+12
-10
lines changed

4 files changed

+12
-10
lines changed

lib/styles/createTheme.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import * as React from "react";
2-
import type { EmptyIntersectionObject } from "../typings";
32
import createBreakpoints, {
43
type Breakpoints,
54
type BreakpointsInput
65
} from "./createBreakpoints";
76
import createColors, { type Colors, type ColorsInput } from "./createColors";
87
import createMixins, { type Mixins } from "./createMixins";
8+
import createRadius, { type Radius } from "./createRadius";
99
import createSpacings, {
1010
type Spacings,
1111
type SpacingsInput
@@ -15,7 +15,6 @@ import createTypography, {
1515
type TypographyInput
1616
} from "./createTypography";
1717
import createZIndexes, { type ZIndexes } from "./createZIndexes";
18-
import createRadius, { type Radius } from "./createRadius";
1918
import swatches, { type Swatches } from "./swatches";
2019

2120
export type Direction = "ltr" | "rtl";
@@ -48,7 +47,7 @@ export interface ThemeBase {
4847
};
4948
}
5049

51-
const createTheme = <CustomProps = EmptyIntersectionObject>(
50+
const createTheme = <CustomProps = unknown>(
5251
themeInput?: Partial<ThemeInput> & {
5352
custom?: CustomProps | ((theme: ThemeBase) => CustomProps);
5453
}

lib/styles/useDarkMode.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import * as React from "react";
22
import usePreviousValue from "../utils/usePreviousValue";
3-
import { type Theme } from "./createTheme";
4-
import defaultTheme from "./defaultTheme";
3+
import defaultTheme, { type DefaultTheme } from "./defaultTheme";
4+
import type { Theme } from "./createTheme";
55

6-
const useDarkMode = (isDarkMode = false, theme = defaultTheme): Theme => {
6+
const useDarkMode = <T extends Theme = DefaultTheme>(
7+
isDarkMode = false,
8+
theme: T = defaultTheme as T
9+
): T => {
710
const cachedTheme = React.useRef(theme);
811
const prevState = usePreviousValue(isDarkMode);
912

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@sonnat/ui",
3-
"version": "2.0.2",
3+
"version": "2.0.3",
44
"description": "React component library using Sonnat Design System to build faster, elegant, and accessible web applications.",
55
"license": "MIT",
66
"homepage": "https://www.sonnat.dev/",

pages/_app.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { AppProps } from "next/app";
22
import Head from "next/head";
33
import * as React from "react";
44
import CssBaseline from "../lib/CssBaseline";
5-
import { useDarkMode, makeStyles, SonnatInitializer } from "../lib/styles";
5+
import { makeStyles, SonnatInitializer, useDarkMode } from "../lib/styles";
66

77
interface IAppContext {
88
setIsDarkMode: React.Dispatch<React.SetStateAction<boolean>>;
@@ -43,10 +43,10 @@ const App = (props: AppProps) => {
4343

4444
const [isDarkMode, setIsDarkMode] = React.useState(false);
4545

46-
const theme = useDarkMode(isDarkMode);
46+
const newTheme = useDarkMode(isDarkMode);
4747

4848
return (
49-
<SonnatInitializer theme={theme} injectFirst>
49+
<SonnatInitializer theme={newTheme} injectFirst>
5050
<Head>
5151
<meta
5252
name="viewport"

0 commit comments

Comments
 (0)