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

[RFC] How should theme be extended #244

Open
seedy opened this issue Jan 18, 2022 · 0 comments
Open

[RFC] How should theme be extended #244

seedy opened this issue Jan 18, 2022 · 0 comments
Assignees
Labels
area/documentation Improvements or additions to documentation kind/proposal

Comments

@seedy
Copy link
Contributor

seedy commented Jan 18, 2022

Goals

  • Allow easy extension of our theme configuration
  • Allow following our pattern with specific theming per component

Background

Currently, we export our theme configuration and our custom color themes (dark/light)

image

We also export createTheme to allow other projects creating their own theme or completely overriding the ones we produced.

❎ We do not export a simple way to extend our already defined dark and light themes.

From stitches doc, I see no way to extend themes.

They only show how to extend the default theme returned by createStitches with createTheme.

Proposals

  1. Should we create custom local themes when we need per component extensions ?
import customThemeConfig from './CustomElement.themes.ts';

const CustomElement: () => JSX.Element = ...;

const customElementTheme = createTheme(..., {

...customThemeConfig, // somehow we add the custom theme config
});

const CustomElementWithTheme = () => {
  return (
    <div className={customElementTheme}>
      <CustomElement />
    </div>
  );
}

export default CustomElementWithTheme

I fear we might lose dark/light themes for the specific component's context to gain our custom config.

NB: I don't really like this option so far.

  1. Maybe we could expose a way to extend dark and light themes easily?
export const extendTheme: (existingTheme: 'dark' | 'light') => ReturnType<typeof createTheme>
@seedy seedy added the area/documentation Improvements or additions to documentation label Jan 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/documentation Improvements or additions to documentation kind/proposal
Projects
None yet
Development

No branches or pull requests

4 participants