Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow variant configuration overrides #8

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Krabba
Copy link

@Krabba Krabba commented Oct 12, 2024

Previously, the theme variants inherited the tree and types from the main theme, so you couldn't re-assign theme variants if the type is literal.

Changelog

  • With this feature branch, it allows overrides on the theme from a variant perspective:
const theme = new Theme({
  colors: {
    somecolor: "#e9e6ff" as const,
  },
});

const darkMode = theme.variant({
  colors: {
    somecolor: "#000000", // This is now valid in TypeScript
  },
});

@Krabba Krabba force-pushed the fix-typescript-in-variants branch from 2105943 to aea15f9 Compare October 22, 2024 15:54
Comment on lines +58 to +69
export type PartialThemePropertyConfig<PrimaryTheme extends ThemeProps> = {
[K in keyof PrimaryTheme]?: PrimaryTheme[K] extends infer PrimaryThemeKey
? {
[Key in keyof PrimaryThemeKey]?: PrimaryThemeKey[Key] extends infer Value
? Value extends object
? Value[keyof Value] extends string | object
? RecursiveOptionalKeyValuePair<keyof Value, Value[keyof Value]>
: never
: HexCode
: never;
}
: never;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could use the LiteralToPrimitiveDeep from type-fest instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants