首页 > Web开发 > 详细

[TypeStyle] Add type safety to CSS using TypeStyle

时间:2017-06-05 18:20:39      阅读:271      评论:0      收藏:0      [点我收藏+]

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

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!