2.0.0-beta.14 • Published 4 years ago

stylist-react v2.0.0-beta.14

Weekly downloads
135
License
MIT
Repository
github
Last release
4 years ago

stylist

Theming first, fully static typed styled component library for React.

How to

  1. Create your own stylist factory
import { stylistFactory } from 'stylist-react';

/**
 * @param {string} namespace It allows multiple stylist factory.
 * @param {object} initialThemeConfig The configuration to build the initial theme. It can be empty if you are not yet ready for theming your app.
 * @param {function} buildThemeFunction It produces the actual theme for the given theme configuration
 * @returns {getStylist, setTheme} getStylist returns the stylist that can create styled components. setTheme can change themes.
 */
export const { getStylist, setTheme } = stylistFactory('MyNamespace', initialThemeConfig, buildThemeFunction);
  1. Use getStylist to create style components. Keep in mind that stylist is always scoped to a component and is used to create styled sub-components to compose the aforementioned component
// MyComponent.tsx

const { styleDiv } = getStylist('MyComponent');

const Root = styleDiv("Root", theme => ({
    height: "100vh",
    padding: "16px",
    background: theme.backgroundColor,
    color: theme.foregroundColor
}));

export class MyComponent extends React.Component {
    public render() {
      return (
          <Root>
          {this.props.children}
          </Root>
      );
    }
}

For details, Please take a look at the demo folder.

2.0.0-beta.16

4 years ago

2.0.0-beta.15

4 years ago

2.0.0-beta.14

4 years ago

2.0.0-beta.12

4 years ago

1.2.7

5 years ago

2.0.0-beta.11

5 years ago

2.0.0-beta.10

5 years ago

2.0.0-beta.9

5 years ago

2.0.0-beta.8

5 years ago

2.0.0-beta.7

5 years ago

2.0.0-beta.6

5 years ago

2.0.0-beta.5

5 years ago

2.0.0-beta.4

5 years ago

2.0.0-beta.3

5 years ago

2.0.0-beta.2

5 years ago

2.0.0-beta.1

5 years ago

1.2.6

5 years ago

2.0.0-beta.0

5 years ago

1.2.5

5 years ago

1.2.4

5 years ago

1.2.3

5 years ago

1.2.2

5 years ago

1.2.1

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago