2.5.2 • Published 3 years ago

zenstyle v2.5.2

Weekly downloads
2
License
MIT
Repository
github
Last release
3 years ago

Zenstyle

This library exposes a new interface to emotion.

Gist

import { Styled, StyledTag } from 'zenstyle';

// Use the Styled.tag components
const inlineStyle = <Styled.div zs={{ color: 'red' }}></Styled.div>;

// Or create a styled tag
const Button = StyledTag.button({
  color: 'violet',
});

const button = <Button />;

The ZS props

The ZS props accept one of the following types:

  • A CSSObject
  • null
  • A function (theme: Theme) => CSSObject
  • An array of any of the above

The CSSObject accept any css properties including pseudo selector and child selector (this object is directly passed to emotion).

API

Styled

Ready to use components that accept a zs props

StyledTag

A factory to create a styled component (similar to styled component)

import { StyledTag } from 'zenstyle';

const Button = StyledTag.button([
  { color: 'violet' },
  theme => ({ background: theme.background }),
]);

StyledComponent

Inject a className to an existing componnent

import { StyledComponent } from 'zenstyle';
import { Link } from 'react-router-dom';

const RedLink = StyledComponent(Link)({
  color: 'red',
});

StyledTagWithProps

Add custom props on an html element to control it's style

import { StyledTagWithProps } from 'zenstyle';

const Button = StyledTagWithProps.button<{ primary?: boolean }>(({ primary = false, ...props }) => {
  return {
    ...props,
    zs: {
      fontSize: primary ? '1rem' : '1.3rem',
      fontWeoght: primary ? : 'bold' : 'normal'
    }
  }
});
3.0.0-1

3 years ago

3.0.0-0

3 years ago

2.5.2

4 years ago

2.5.1

4 years ago

2.5.0

4 years ago

2.4.1

4 years ago

2.4.2

4 years ago

2.4.0

4 years ago

2.3.0

4 years ago

2.2.0

4 years ago

2.1.1

4 years ago

2.1.0

4 years ago

2.0.0

4 years ago

1.0.0

4 years ago

1.0.0-alpha.0

4 years ago