Skip to content

Passing callbacks as styles to components #91

@efoken

Description

@efoken

Is your feature request related to a problem? Please describe.
Now that the Context API is available in Atomico, it would be very nice to be able to pass callbacks to component.styles.

Describe the solution you'd like
I would like to support the following:

const Button: Component = () => {
  // ...
}

Button.styles = [
  ({ theme }) => css`
    :host {
      color: ${theme.colors.brand};
    }
  `,
];

I know there are CSS variables, but as we share our theme with React Native components we cannot use CSS variables. And besides that our theme contains a lot more than just colors, there are even objects containing text styles or shadows.

The question is, how to tell the Button component above to use ThemeContext?!

Maybe:

Button.context = ThemeContext;

or even:

Button.styles = [
  ThemeContext,
  ({ theme }) => css`
    ...
  `,
];

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions