Skip to content

Commit

Permalink
1.2.7
Browse files Browse the repository at this point in the history
  • Loading branch information
lewisnguyen2804 committed Jan 25, 2024
1 parent 8e206da commit 77335a9
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 19 deletions.
2 changes: 1 addition & 1 deletion lib/components/menu/menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export const Menu = ({
className={itemClasses}
onClick={() => onMenuItemClick(x.key)}
>
<div className={itemIconClasses}>{x.icon}</div>
{!!x.icon && <div className={itemIconClasses}>{x.icon}</div>}
{x.title}
</li>
));
Expand Down
11 changes: 2 additions & 9 deletions lib/customization/theme/index.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,18 @@
// src/themes/index.ts
import baseDark from "./dark/base";
import baseLight from "./light/base";
import blueLight from "./light/blue";
// import pinkLight from "./light/pink";
// import greenLight from "./light/green";
import { IThemes } from "./utils";

const THEMES = {
const themeList = {
baseLight: "baseLight",
blueLight: "blueLight",
baseDark: "baseDark",
// pinkLight: "pinkLight",
// greenLight: "greenLight",
};

export type ThemeType = keyof typeof THEMES;
export type IThemeType = keyof typeof themeList;

export const zeniThemes: IThemes = {
baseLight,
baseDark,
blueLight,
// pinkLight,
// greenLight,
};
8 changes: 4 additions & 4 deletions lib/customization/theme/use-change-theme.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { useEffect, useState } from "react";
import { ThemeType } from ".";
import { IThemeType } from ".";
import { applyTheme } from "./utils";

export function useChangeTheme() {
const [theme, setTheme] = useState<ThemeType | undefined>(() => {
const [theme, setTheme] = useState<IThemeType | undefined>(() => {
const savedTheme = localStorage.getItem("theme");
return savedTheme ? (savedTheme as ThemeType) : undefined;
return savedTheme ? (savedTheme as IThemeType) : undefined;
});

useEffect(() => {
Expand All @@ -16,4 +16,4 @@ export function useChangeTheme() {
}, [theme]);

return { theme, setTheme };
}
}
2 changes: 1 addition & 1 deletion lib/customization/theme/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { zeniThemes } from ".";

export type ITheme = Record<string, string>;
type ITheme = Record<string, string>;

export type IThemes = Record<string, ITheme>;

Expand Down
6 changes: 3 additions & 3 deletions lib/providers/zeni-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@ import {
ToastProvider,
ToastProviderProps,
} from "../main";
import { ThemeType } from "../customization/theme";
import { IThemeType } from "../customization/theme";
import { applyTheme } from "../customization/theme/utils";

export const ZeniProvider = ({
initialTheme,
children,
toastOptions,
}: {
initialTheme?: ThemeType;
initialTheme?: IThemeType;
children: React.ReactNode;
toastOptions?: ToastProviderProps;
}) => {
useEffect(() => {
const savedTheme = localStorage.getItem("theme");
const defaultTheme =
(savedTheme as ThemeType) || initialTheme || "baseLight";
(savedTheme as IThemeType) || initialTheme || "baseLight";
applyTheme(defaultTheme);
localStorage.setItem("theme", defaultTheme);
}, [initialTheme]);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "zeni-ui",
"private": false,
"version": "1.2.6-beta",
"version": "1.2.7-beta",
"type": "module",
"main": "dist/main.js",
"types": "dist/main.d.ts",
Expand Down

0 comments on commit 77335a9

Please sign in to comment.