码迷,mamicode.com
首页 > Web开发 > 详细

[TypeStyle] Add type safety to CSS using TypeStyle

时间:2017-06-05 18:24:58      阅读:266      评论:0      收藏:0      [点我收藏+]

标签:str   his   config   eve   pes   and   classname   doc   script   

TypeStyle is the only current CSS in JS solution that is designed with TypeSafety and TypeScript developer ergonomics in mind.

In this lesson we will show how easy it is to setup with zero configuration and also demonstrate its UI framework agnostic nature. We will also show how to integrate it with your application framework of choice using ReactJS as an example.

 

Install:

npm install --save typestyle

 

Using:

import { style } from ‘typestyle‘;
import * as React from ‘react‘;
import * as ReactDOM from ‘react-dom‘;

const className = style({
   color: ‘red‘,
   background: ‘yellow‘
});

ReactDOM.render(
    <div className={className}>
        Hello Typestyle
    </div>,
    document.getElementById(‘root‘)
);

 

It generate unqiue class name:

.fdulqt6 {
    background: yellow;
    color: red;
}
<div data-reactroot="" class="fdulqt6">Hello Typestyle</div>

 

[TypeStyle] Add type safety to CSS using TypeStyle

标签:str   his   config   eve   pes   and   classname   doc   script   

原文地址:http://www.cnblogs.com/Answer1215/p/6946381.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!