styled mixin
1.0.0
스타일링 컴포넌트 믹스 인을 만들기위한 매우 간단한 래퍼. 아마도 덮어 쓰기 규칙에 대한 인간이 읽을 수있는 구문 일 것입니다
npm i --save styled-mixin import styled from 'styled-component' ;
import createMixin from 'styled-mixin' ;
const tomatoColorMixin = createMixin `
color: tomato;
` ;
const Header = styled . h1 `
color: black;
font-size: 20px;
` ;
const Button = styled . button `
color: black;
border: none;
` ;
const TomatoHeader = tomatoColorMixin ( Header ) ;
const TomatoButton = tomatoColorMixin ( Button ) ;사용
import createMixin from 'styled-mixin/native' ;반응 네이티브 모드가 필요한 경우.
import styled , { keyframes } from 'styled-component' ;
import createMixin from 'styled-mixin' ;
const Header = styled . h1 `
color: black;
` ;
const rotate360Keyframes = keyframes `
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
` ;
const rotate = createMixin `
animation: ${ rotate360Keyframes } 2s linear infinite;
` ;
const Uiiiii = rotate ( Header ) ; import styled from 'styled-component' ;
import createMixin from 'styled-mixin' ;
const blackOrTomatoMixin = createMixin `
color: ${ props => props . tomato ? 'tomato' : 'black' } ;
` ;
const Button = blackOrTomatoMixin ( styled . button `
border: none;
` ) ; < Button tomato > Tomato!!! </ Button > import styled from 'styled-component' ;
import createMixin from 'styled-mixin' ;
const Header = styled . h1 `
color: black;
` ;
const tomatoColorMixin = createMixin `
color: tomato;
` ;
const fontSizeMixin = createMixin `
font-size: 20px;
` ;
const TomatoHeader = tomatoColorMixin ( fontSizeMixin ( Header ) ) ; 드미트리 파블로브 스키