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的更多相关文章

  1. 解决Type safety: The expression of type List needs

    解决Type safety: The expression of type List needs unchecked conversion to conform to 在方法前加上这句话就可以了@Su ...

  2. [TypeScript] Increase TypeScript's type safety with noImplicitAny

    TypeScript tries to infer as much about your code as it can. But sometimes there really is not enoug ...

  3. [TypeStyle] Add responsive styles using TypeStyle Media Queries

    Media queries are very important for designs that you want to work on both mobile and desktop browse ...

  4. [TypeStyle] Load raw CSS in TypeStyle

    TypeStyle tries to be an all in one CSS in JS management solution so you can always fall back to raw ...

  5. 给 input 中 type="text" 设置CSS样式

    input[type="text"], input[type="password"] {    border: 1px solid #ccc;    paddi ...

  6. Type Safety and Type Inference

    Swift is a type-safe language. A type safe language encourages you to be clear about the types of va ...

  7. CSS:给 input 中 type="text" 设置CSS样式

    input[type="text"], input[type="password"] {    border: 1px solid #ccc;    paddi ...

  8. java中的类型安全问题-Type safety: Unchecked cast from Object to ...

    首先,java语言室类型安全的,通常我们遇到这个问题是出现在Object转化为目标类型时, 这个转化并不是安全的.这个问题普遍认为因为使用了jdk1.5或者1.6的泛型, request.getAtt ...

  9. Type safety: Unchecked cast from Object to ArrayList

    表明Object转化为ArrayList这个转化并不是安全的.. 编译的时候需要加入修饰符才能正常编译(具体是那个修饰符..不记得了.^_^),否则会提示有警告 当然这只是一个警告,如果楼主自信这个转 ...

随机推荐

  1. 玩转redux--从会用到庖丁解牛

    目录 为何而写 redux是什么 redux的设计哲学 redux的工作流 redux的几个核心要素 store action reducer actionCreator combineReducer ...

  2. [分享]ip地址爬取过滤的shell

    http://www.hbbzy.me/分享ip地址爬取过滤的shell #!/bin/base #ip zhi地址匹配 #获取最新的ip地址 #author:haifeng #wget ftp:// ...

  3. java中goto语句

    goto是java中一个保留字,但在语言中并未使用它. goto语句起源于汇编语言的程序控制,是源码级上的跳跃,这使其招致了不好的声誉,若一个程序总是从一个地方跳转到另一个地方, 还有什么办法能识别程 ...

  4. BZOJ3674可持久化并查集(模板)

    没什么可说的,就是一个可持久化线段树维护一个数组fa以及deep按秩合并好了 注意一下强制在线 蒟蒻的我搞了好长时间QAQ 贴代码: #include<cstdio> #include&l ...

  5. 2018/8/15 qbxt 测试

    2018/8/15 qbxt 测试 期望得分:100:实际得分:50   不知道为什么写挂了,明明是个水题 T^T 思路:模拟 注意:如果用 char 类型存储的话,如果有'z' + 9 会爆char ...

  6. 洛谷——P1781 宇宙总统

    https://www.luogu.org/problem/show?pid=1781 题目背景 宇宙总统竞选 题目描述 地球历公元6036年,全宇宙准备竞选一个最贤能的人当总统,共有n个非凡拔尖的人 ...

  7. 关于android主线程异常NetworkOnMainThread不能訪问网络

    今天在学习的过程中遇到了NetworkOnMainThread的异常,关于这个异常问题在android sdk 4.0版本号上,这个问题可能比較常见,查了许些资料大多都是大概解说原因,可是没有解说到详 ...

  8. touch、touchevent-事件总结

    1.废话不多说,直接上代码,如下 package com.example.mygestrue; import android.support.v7.app.ActionBarActivity; imp ...

  9. Android中Alarm的机制

    本次给大家分析的是Android中Alarm的机制所用源码为最新的Android4.4.4.首先简单介绍如何使用Alarm并给出其工作原理,接着分析Alarm和Timer以及Handler在完成定时任 ...

  10. 洛谷 P2118 比例简化

    P2118 比例简化 题目描述 在社交媒体上,经常会看到针对某一个观点同意与否的民意调查以及结果.例如,对某一观点表示支持的有1498 人,反对的有 902人,那么赞同与反对的比例可以简单的记为149 ...