[TypeStyle] Add type safety to CSS using TypeStyle

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>
时间: 2024-11-05 13:26:23

[TypeStyle] Add type safety to CSS using TypeStyle的相关文章

[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 browsers. TypeStyle gives media queries special attention, making it easy to write them using CSS in JS. In this lesson we show TypeStyle's media function.

[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 CSS if you ever need to migrate old code quickly. This lesson will demonstrate how to use the cssRaw function along with the real world use case of C

给 input 中 type=&quot;text&quot; 设置CSS样式

input[type="text"], input[type="password"] {    border: 1px solid #ccc;    padding: 2px;    font-size: 1.2em;    color: #444;    width: 200px;}

Type safety: Unchecked cast from Object to ArrayList

表明Object转化为ArrayList这个转化并不是安全的.. 编译的时候需要加入修饰符才能正常编译(具体是那个修饰符..不记得了.^_^),否则会提示有警告 当然这只是一个警告,如果楼主自信这个转化是没问题的,就可以在其所在函数前加上注解@SuppressWarnings("uncheck")这样就可以去掉那条难看的提示警告的小黄线了.. 但是不鼓励这么做,楼主还是应该使用安全的类型转换

C++ Core Guidelines

C++ Core Guidelines September 9, 2015 Editors: Bjarne Stroustrup Herb Sutter This document is a very early draft. It is inkorrekt, incompleat, and pµøoorly formatted. Had it been an open source (code) project, this would have been release 0.6. Copy

how to add Javascript and CSS in page layout with sharepoint 2013

how to add Javascript and CSS in page layout with sharepoint 2013 Sometimes, we need create a custom page layout, at the time, if we want to add some javascript and css code, how to do it? we cannot add the code in page layout file directly, the syet

asp.net后台添加css、 js 、 meta、ascx

1 //标题 2 Title = "标题"; 3 //关键词 4 HtmlMeta meta1 = new HtmlMeta(); 5 meta1.Name = "keywords"; 6 meta1.Content = "关键词"; 7 this.Page.Header.Controls.Add(meta1); 8 //描述 9 HtmlMeta meta2 = new HtmlMeta(); 10 meta2.Name = "des

ASP.NET给前端动态添加修改 CSS样式JS 标题 关键字

有很多网站读者能换自己喜欢的样式,还有一些网站想多站点共享后端代码而只动前段样式,可以采用动态替换CSS样式和JS. 如果是webform 开发,可以用下列方法: 流程是首先从数据中或者xml读取数据,然后赋值给前端页面 HTML <meta> 标签添加 HtmlMeta mtdes = new HtmlMeta();//新建实例 mtdes.Name = "Description";//标签 mtdes.Content = this.Descriptionp;//内容 H

解决MVC中使用BundleConfig.RegisterBundles引用Css及js文件发布后丢失的问题

ASP.NET MVC4,ASP.NET MVC5中对JS和CSS的引用又做了一次变化,在MVC3中我们这样引用资源文件: <link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" /> 将在运行的时候自动将虚拟(相对)路径转换为应用程序绝对路径.这是比较传统的引用方式,尽管他做了一次转换操作,对服务器的请求数量