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

[POC: Unmergeable] Idea on component-based theming #5888

Closed
wants to merge 6 commits into from

Conversation

cchaos
Copy link
Contributor

@cchaos cchaos commented May 8, 2022

Theming ideas

Can prop values be generated through the global theme layer?
This is all conjecture since I don't know if the provider can be used this way.

Example: Buttons

Amsterdam theme:

export const BUTTON_COLORS = ‘primary’ | ‘success’;
export const useEuiButtonColorCSS = () => {
  const euiTheme = useEuiTheme();
  return {
    primary: `
      background-color: ${euiButtonColor('primary', euiTheme)};
    `,
    success: `
      background-color: ${euiButtonColor('success', euiTheme)};
    `,
  }
}

Somehow the EuiThemeProvider should expect certain component prop type options like

EuiButtonProps[‘color’]: EuiThemeProvider.theme.button.colors

Then the button component would pull the available prop's map and related styling via the provider:

export type ButtonColor = EuiThemeProvider.theme.button.colors;
export const EuiButton: FunctionComponent<Props> = ({
  color,
)} => {
  const style = [useEuiButtonColorCSS[color]];
}
export const EuiBottomBar = forwardRef<HTMLElement, EuiBottomBarProps>(
  (props, ref) => {
    const BottomBar = _EuiBottomBar;
    return (
      <EuiThemeProvider colorMode={'dark'}>
        <BottomBar ref={ref} {...props} />
      </EuiThemeProvider>
    );
  }
);

Screen Shot 2022-05-08 at 18 09 13 PM

This screenshots show how the docs is still looping through manual list of previously available colors, but only 3 of which are available in this theme.


The nice thing about this approach, is it will separate basic / functional styles from purely visual ones. Perhaps open up a way to make those basic / functional styles static.

@github-actions
Copy link

github-actions bot commented Aug 7, 2022

👋 Hey there. This PR hasn't had any activity for 90 days. We'll automatically close it if that trend continues for another week. If you feel this issue is still valid and needs attention please let us know with a comment.

@github-actions
Copy link

❌ We're automatically closing this PR due to lack of activity. Please comment if you feel this was done in error.

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

Successfully merging this pull request may close these issues.

1 participant