# ycss **Repository Path**: jiuker/ycss ## Basic Information - **Project Name**: ycss - **Description**: No description available - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-04-02 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 简介 这是一个自动替换css的工具,当你写一句class,然后保存的时候,程序会自动执行替换规则 原理和正则里面的replace(/c-(\d{1,2})/,(a)=>{xxx})一致 如下图: 当你有一个 class="c-ffffff bb-1-eee" 程序会自动生成: .c-ffffff{color:#ffffff} .bb-1-eee{border-bottom:1px solid #eee} 并且插入指定位置 ![Image text](https://gitee.com/jiuker/ycss/blob/master/res/vue.gif) ![Image text](https://gitee.com/jiuker/ycss/blob/master/res/react-native.gif) # 开始 * 解压 ycss-xxxxx.tar.bz2 * 直接运行里面的 二进制文件,如 ./ycss # 配置 ## 特点 * 动态生效,也就是配置是动态 ## 位置 * ./res/config/confg.json ## 配置字段 { "debug": true, // true|false "type": "rn", // rn|vue "common": ["./res/regexp/common/rn.reg"],// reg path, "single": ["./res/regexp/single/rn.reg"],// single path, "outUnit": "upx", // out unit,will work in vue "zoom": 1.4, // value zoom,if px need to rem; "needZoomUnit": "px|rem", // vaule unit will zoom,if not match will do nothing "reg": ["GetStyle\\(\"([^\"]+)\""],// how to find your class,eq:class="w-15" "watchDir": ["./res/sample/rn"],// watch dir to do "oldCssReg": "/\\* Automatic generation Start \\*/([^/]+)/\\*", // both vue and rn do as (auto code) ,if not match do nothing; "keyNeedZoom": [ // will work in rn,if value need zoom ,please set it "width", "height" ], "static": { // work at @key,code is newCssUint "red": "#ff0000", "red-1": "#ff1100", "height": 12 }, "outPath": "@FILEDIR/@FILENAME.@FILETYPE" // if static ,will write in a file,dir/name.type is constant } # 匹配规则 匹配规则分为两层,一层是common,一层是single,可以理解为一层common有多层single 也就是 common: .box-c-fff{ d-f ai-c jc-c c-(fff)} #(fff)相当于 $1 single: .d-f{display:flex;} .ai-c{align-item:center} .jc-c{justify-content:center} c-$1{color:#$1} 最后生成样式为: box-c{display:flex;align-item:center;justify-content:center;color:#fff} ## 公用(common) 包含了多个single ## Single 最基础的样式,也就是实际样式的设置,可以是多个如 display:flex;display:box;等 ### Vue * 它的key就是匹配规则 * 值里面 $1,$2 会被替换成key里面的值,w-($1)-h-($2) ### RN * 它的key就是匹配规则 * 值里面的-1,-2是类似上面的替换规则,他能保持数据类型,比如 -1,'-1' 代表 数字和字符串 # example 程序里面已经带有example,并且具有最基础样式,你可以配置自己的样式,在配置里面引入即可使用 ## /res/sample # 欢迎提交issue # 讨论群 * 941057162