glitz-style-function
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

Glitz

A tiny Glitz utility function to be able to pass props to a style function. Any $-prefixed props will be emitted and never reach the inner styled component. It's basically an alternative styled function that accepts functions that returns a style object as a second argument, which original styled doesn't.

import { styled } from '@glitz/react';
import withStyleFunction from 'glitz-style-function';
 
const Link = withStyleFunction(styled.A, props => ({ fontSize: props.$size === 'large' ? '24px' : '18px' }));
 
const Message = withStyleFunction(
  props => (
    <div className={props.apply()}>
      {props.title}
      {props.children}
      <Link href="/more/info" $size="large">
        More info
      </Link>
    </div>;
  ),
  props => ({ backgroundColor: props.$success ? 'green' : 'red' }),
);
 
export default () => {
  <Message title="Hurray!" $success>
    The operation was successful
  </Message>;
};

Read more at @glitz/react!

Note! This package was primarily created for a easier migration from Styletron to Glitz.

Readme

Keywords

none

Package Sidebar

Install

npm i glitz-style-function

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

12.1 kB

Total Files

6

Last publish

Collaborators

  • faddee