Maharshi Alpesh 0250ced3d7
fix: fixing the layout color (#4879)
fix: adding tooltip to show items which are only for the visual purpose

fix: persist the theme across reloads

chore: modifying the mobile styles
2025-02-20 11:31:01 -03:00

60 lines
2.0 KiB
TypeScript

import {HeroUIPluginConfig} from "@heroui/theme";
import {readableColor} from "color2k";
import {Config, ThemeType} from "../types";
import {generateThemeColor} from "./colors";
function generateLayoutConfig(config: Config): HeroUIPluginConfig["layout"] {
return {
disabledOpacity: config.layout.otherParams.disabledOpacity,
};
}
function generateThemeColorsConfig(config: Config, theme: ThemeType) {
return {
default: generateThemeColor(config[theme].defaultColor.default, "default", "light"),
primary: generateThemeColor(config[theme].baseColor.primary, "primary", "light"),
secondary: generateThemeColor(config[theme].baseColor.secondary, "secondary", "light"),
success: generateThemeColor(config[theme].baseColor.success, "success", "light"),
warning: generateThemeColor(config[theme].baseColor.warning, "warning", "light"),
danger: generateThemeColor(config[theme].baseColor.danger, "danger", "light"),
background: config[theme].layoutColor.background,
foreground: config[theme].layoutColor.foreground,
content1: {
DEFAULT: config[theme].contentColor.content1,
foreground: readableColor(config[theme].contentColor.content1),
},
content2: {
DEFAULT: config[theme].contentColor.content2,
foreground: readableColor(config[theme].contentColor.content2),
},
content3: {
DEFAULT: config[theme].contentColor.content3,
foreground: readableColor(config[theme].contentColor.content3),
},
content4: {
DEFAULT: config[theme].contentColor.content4,
foreground: readableColor(config[theme].contentColor.content4),
},
focus: config[theme].layoutColor.focus,
overlay: config[theme].layoutColor.overlay,
};
}
/**
* Generate plugin configuration
*/
export function generatePluginConfig(config: Config): HeroUIPluginConfig {
return {
themes: {
light: {
colors: generateThemeColorsConfig(config, "light"),
},
dark: {
colors: generateThemeColorsConfig(config, "dark"),
},
},
layout: generateLayoutConfig(config),
};
}