@nju33/styled-components
TypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published

@nju33/styled-components

github npm:version typescript ci:status document:typedoc license code style:prettier

My styled-components helpers

Usage

/**
 * Before, To install this and styled-components
 * ```sh
 * yarn add @nju33/styled-components styled-components @types/styled-components
 * ```
 */
import {Mixin, RequiredAtomProps, createMedia} from '@nju33/styled-components';

Example

const foo = 'foo' as 'foo';
const bar = 'bar' as 'bar';

type MixinName = typeof foo | typeof bar;
type CurrentComponentMixin = Mixin<MixinName>;

const mixin: CurrentComponentMixin = (mixinName => (
  first,
  ...interpolations
) => css`
  &.${mixinName} {
    ${css(first, ...interpolations)}
  }
`) as CurrentComponentMixin;

mixin[foo] = mixin(foo)`
  font-size: 15px;
`;

mixin[bar] = mixin(bar)`
  font-size: 13;
`;

// tslint:disable-next-line:no-unused-expression
styled.div<RequiredAtomProps<MixinName>>`
  ${mixin.foo};
  ${mixin.bar};
`;
interface Sizes {
	desktop: number;
	tablet: number;
	phone: number;
}

const media = createMedia<Sizes>({
	desktop 992,
	tablet: 768,
	phone: 576
});

styled.div`
	color: blue;

	${media.desktop`
		color: orange;
	`};
`;
// color: blue;
// @media screen and (min-width: 992px) {
//   color: orange;
// }

Readme

Keywords

none

Package Sidebar

Install

npm i @nju33/styled-components

Weekly Downloads

2

Version

0.2.0

License

MIT

Unpacked Size

8.69 kB

Total Files

17

Last publish

Collaborators

  • nju33