0.0.3 • Published 4 years ago

styled-injector v0.0.3

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

Styled-Injector

npm GitHub TypeScript

Styled-Injector is a lightweight utility for React UI-toolkit maintainers that wish to use a styled-api, but don't wish to require their users to use a specific styled-api.

This way, if one user is using emotion and another is using styled-components, they can both use the same UI-toolkit without having to install a second CSS-in-JS library.

Note

This package is intended for maintainers of React UI-toolkits, and is likely not useful for anyone building an app.

Usage

// src/styled.ts

import styled from "styled-components";
import { createStyled } from "styled-injector";

export const Styled = createStyled(styled);
// src/list.tsx

import Styled from "./styled";

const { styled } = Styled;

const List = styled.ul`
	list-style-type: none;
	width: 200px;
	padding: 0;
	margin: 0;
	box-shadow: 0 0 4px black;
`;

const ListItem = styled.li`
	display: flex;
	align-items: center;
	border-bottom: 1px solid lightgray;
	height: 40px;
	padding-left: 12px;
`;
// src/app.tsx

import Styled from "./styled";
import { List, ListItem } from "./list";

const { Provider } = Styled;

const App = () => {
	return (
		<Provider>
			<List>
				<ListItem>Apple</ListItem>
				<ListItem>Banana</ListItem>
				<ListItem>Cherry</ListItem>
			</List>
		</Provider>
	);
};
0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago