|
2 | 2 | [![Build Status][travis-img]][travis]
|
3 | 3 | [![Version][version]](https://github.com/ElemeFE/postcss-salad/blob/master/CHANGELOG.md)
|
4 | 4 |
|
5 |
| -> Postcss-salad 是一个能够帮助你更加写出更加简洁、优雅的CSS的样式解决方案。 |
| 5 | +> Postcss-salad 是一个能够帮助你更加写出更加简洁、优雅的CSS的样式解决方案。<br> |
| 6 | +> 不仅提供了下一代css语法支持,还提供了基础的sass的语法、属性顺时针简写、rem填充、基础图形绘制、可定制样式的inline-svg以及bem类名自动转化等实用的功能。 |
6 | 7 |
|
7 |
| -Postcss-salad不仅提供了下一代css语法支持,还提供了基础的sass的语法、属性顺时针简写、rem填充、基础图形绘制、可定制样式的inline-svg以及bem类名自动转化等实用的功能。 |
8 |
| - |
9 |
| ---- |
10 |
| - |
11 |
| -## Examples |
12 |
| - |
13 |
| -#### 下一代css语法 |
14 |
| - |
15 |
| -```css |
16 |
| -/* before */ |
17 |
| -:root { |
18 |
| - --mainColor: red; |
19 |
| -} |
20 |
| -@custom-media --small-viewport (max-width: 30em); |
21 |
| - |
22 |
| -@media (--small-viewport) { |
23 |
| - a { |
24 |
| - color: var(--mainColor); |
25 |
| - } |
26 |
| -} |
27 |
| - |
28 |
| -/* after */ |
29 |
| -@media (max-width: 30em) { |
30 |
| - a { |
31 |
| - color: red; |
32 |
| - } |
33 |
| -} |
34 |
| -``` |
35 |
| - |
36 |
| -#### 顺时针简写 |
37 |
| - |
38 |
| -```css |
39 |
| -/* before */ |
40 |
| -a { |
41 |
| - position: absolute 1em 2em 3em 4em; |
42 |
| - margin: 30px *; |
43 |
| -} |
44 |
| -b { |
45 |
| - position: absolute 1em * * 4em; |
46 |
| - padding: 30px *; |
47 |
| -} |
48 |
| - |
49 |
| -/* after */ |
50 |
| -a { |
51 |
| - top: 1em; |
52 |
| - right: 2em; |
53 |
| - bottom: 3em; |
54 |
| - left: 4em; |
55 |
| - position: absolute; |
56 |
| - margin-top: 30px; |
57 |
| - margin-bottom: 30px; |
58 |
| -} |
59 |
| -b { |
60 |
| - top: 1em; |
61 |
| - left: 4em; |
62 |
| - position: absolute; |
63 |
| - padding-top: 30px; |
64 |
| - padding-bottom: 30px; |
65 |
| -} |
66 |
| -``` |
67 |
| - |
68 |
| -#### rem填充 |
69 |
| - |
70 |
| -```css |
71 |
| -/* before */ |
72 |
| -a { |
73 |
| - width: 10rem; |
74 |
| - margin: 30px 2rem 1rem 10px; |
75 |
| -} |
76 |
| - |
77 |
| -/* after */ |
78 |
| -a { |
79 |
| - width: 160px; |
80 |
| - margin: 30px 32px 16px 10px; |
81 |
| -} |
82 |
| -``` |
83 |
| - |
84 |
| -#### 基础图形绘制 |
85 |
| - |
86 |
| -```css |
87 |
| -/* before */ |
88 |
| -.rect { |
89 |
| - rect: 10px 20px #f00; |
90 |
| -} |
91 |
| -.cirlce { |
92 |
| - circle: 50px #ff0; |
93 |
| -} |
94 |
| -.triangle { |
95 |
| - triangle: 5px left #ff0; |
96 |
| -} |
97 |
| - |
98 |
| -/* after */ |
99 |
| -.rect { |
100 |
| - width: 10px; |
101 |
| - height: 20px; |
102 |
| - background-color: #f00; |
103 |
| -} |
104 |
| -.cirlce { |
105 |
| - width: 50px; |
106 |
| - height: 50px; |
107 |
| - border-radius: 50%; |
108 |
| -} |
109 |
| -.triangle { |
110 |
| - display: inline-block; |
111 |
| - width: 0; |
112 |
| - height: 0; |
113 |
| - border: solid transparent; |
114 |
| - border-width: 5px; |
115 |
| - border-right-color: #ff0; |
116 |
| -} |
117 |
| -``` |
118 |
| - |
119 |
| -#### 可定制的inline-svg |
120 |
| - |
121 |
| -```css |
122 |
| -/* before */ |
123 |
| -@svg-load nav url(../svgs/nav.svg) { |
124 |
| - path:nth-child(2){ |
125 |
| - fill:#0ff |
126 |
| - }; |
127 |
| -} |
128 |
| -h1 { |
129 |
| - background: svg-inline(nav) |
130 |
| -} |
131 |
| - |
132 |
| -/* after */ |
133 |
| -h1 { |
134 |
| - background: url("data:image/svg+xml;charset=utf-8,<svg xmlns=\'http://www.w3.org/2000/svg\' viewBox=\'0 0 50 50\'><path d=\'M10 12h30v4H10z\'/><path d=\'M10 22h30v4H10z\' fill=\'#0ff\'/><path d=\'M10 32h30v4H10z\'/></svg>"); |
135 |
| -} |
136 |
| -``` |
137 |
| - |
138 |
| -#### 基础sass语法 |
139 |
| - |
140 |
| -```css |
141 |
| -/* before */ |
142 |
| -$pass: green !default; |
143 |
| - |
144 |
| -@define-placeholder foo { |
145 |
| - background: pink; |
146 |
| -} |
147 |
| - |
148 |
| -.bar { |
149 |
| - @extend foo; |
150 |
| - |
151 |
| - background-color: @color; |
152 |
| - color: $pass; |
153 |
| -} |
154 |
| - |
155 |
| -/* after */ |
156 |
| -.bar { |
157 |
| - background: pink; |
158 |
| -} |
159 |
| - |
160 |
| -.bar { |
161 |
| - |
162 |
| - background-color: green; |
163 |
| - color: green; |
164 |
| -} |
165 |
| -``` |
166 |
| - |
167 |
| -#### bem类名 |
168 |
| - |
169 |
| -```css |
170 |
| -/* before */ |
171 |
| -@utility utilityName { |
172 |
| - color: green; |
173 |
| -} |
174 |
| - |
175 |
| -@utility utilityName small { |
176 |
| - color: blue; |
177 |
| -} |
178 |
| - |
179 |
| -@component ComponentName { |
180 |
| - color: cyan; |
181 |
| - |
182 |
| - @modifier modifierName { |
183 |
| - color: yellow; |
184 |
| - } |
185 |
| - |
186 |
| - @descendent descendentName { |
187 |
| - color: navy; |
188 |
| - } |
189 |
| - |
190 |
| - @when stateName { |
191 |
| - color: crimson; |
192 |
| - } |
193 |
| -} |
194 |
| - |
195 |
| -@component-namespace nmsp { |
196 |
| - @component ComponentName { |
197 |
| - color: red; |
198 |
| - } |
199 |
| -} |
200 |
| - |
201 |
| -/* after */ |
202 |
| -.u-utilityName { |
203 |
| - color: green; |
204 |
| -} |
205 |
| - |
206 |
| -.u-sm-utilityName { |
207 |
| - color: blue; |
208 |
| -} |
209 |
| - |
210 |
| -.ComponentName { |
211 |
| - color: cyan; |
212 |
| -} |
213 |
| - |
214 |
| -.ComponentName--modifierName { |
215 |
| - color: yellow; |
216 |
| -} |
217 |
| - |
218 |
| -.ComponentName-descendentName { |
219 |
| - color: navy; |
220 |
| -} |
221 |
| - |
222 |
| -.ComponentName.is-stateName { |
223 |
| - color: crimson; |
224 |
| -} |
225 |
| - |
226 |
| -.nmsp-ComponentName { |
227 |
| - color: red; |
228 |
| -} |
229 |
| -``` |
| 8 | +## [Documents] |
230 | 9 |
|
231 | 10 | ## Usage
|
232 | 11 |
|
@@ -260,7 +39,7 @@ postcss([
|
260 | 39 |
|
261 | 40 | #### Gulp
|
262 | 41 |
|
263 |
| -Add [Gulp PostCSS] to your build tool: |
| 42 | +Add [Gulp PostCSS]: to your build tool: |
264 | 43 |
|
265 | 44 | ```bash
|
266 | 45 | npm install gulp-postcss --save-dev
|
@@ -304,31 +83,32 @@ var options = {
|
304 | 83 | Postcss-salad powered by the following plugins (in this order):
|
305 | 84 |
|
306 | 85 | - [precss]: a tool that allows you to use Sass-like markup in your CSS files
|
| 86 | +- [postcss-css-reset]: reset style is dependent on normalize.css and combined with best practice. |
| 87 | +- [postcss-utils]: help you create functional fragments quickly via at-rules. |
307 | 88 | - [postcss-bem]: implementing BEM as at-rules
|
308 | 89 | - [postcss-calc]: plugin to reduce calc()
|
309 | 90 | - [postcss-initial]: fallback initial keyword
|
310 | 91 | - [postcss-inline-svg]: reference an SVG file and control its attributes with CSS syntax.
|
311 |
| -- [postcss-short-font-size]: extends the font-size property so that line-height may be set by the second value. |
312 |
| -- [postcss-short-spacing]: lets you write shorthand margin and padding properties while omitting edges in CSS. |
313 |
| -- [postcss-short-size]: Write shorthand size properties in CSS |
314 |
| -- [postcss-short-position]: Define edges inside the position property in CSS |
| 92 | +- [postcss-short]: lets you write styles more logically by extending shorthand properties in CSS. |
315 | 93 | - [postcss-shape]: draw basic shape with specified syntax in css rule
|
316 | 94 | - [node-pixrem]: generates pixel fallbacks for rem units.
|
317 | 95 | - [autoprefixer]: parse CSS and add vendor prefixes to CSS rules using values from Can I Use
|
318 | 96 |
|
319 |
| -[travis-img]: https://travis-ci.org/ElemeFE/postcss-salad.svg |
320 |
| -[travis]: https://travis-ci.org/ElemeFE/postcss-salad |
321 | 97 | [precss]: https://github.com/jonathantneal/precss
|
| 98 | +[postcss-css-reset]: https://npmjs.com/package/postcss-css-reset |
| 99 | +[postcss-utils]: https://github.com/baiyaaaaa/postcss-utils |
322 | 100 | [postcss-bem]: https://github.com/ileri/postcss-bem
|
323 | 101 | [postcss-calc]: https://github.com/postcss/postcss-calc
|
324 | 102 | [postcss-initial]: https://github.com/maximkoretskiy/postcss-initial
|
325 | 103 | [postcss-inline-svg]: https://github.com/TrySound/postcss-inline-svg
|
326 |
| -[postcss-short-font-size]: https://github.com/jonathantneal/postcss-short-font-size |
327 |
| -[postcss-short-spacing]: https://github.com/jonathantneal/postcss-short-spacing |
| 104 | +[postcss-short]: https://github.com/jonathantneal/postcss-short |
328 | 105 | [postcss-shape]: https://github.com/baiyaaaaa/postcss-shape
|
329 |
| -[postcss-short-size]: https://github.com/jonathantneal/postcss-short-size |
330 |
| -[postcss-short-position]: https://github.com/jonathantneal/postcss-short-position |
331 | 106 | [node-pixrem]: https://github.com/robwierzbowski/node-pixrem
|
332 | 107 | [autoprefixer]: https://github.com/postcss/autoprefixer
|
333 |
| -[Postcss-salad]: https://github.com/ElemeFE/postcss-salad |
| 108 | +[Postcss salad]: https://github.com/ElemeFE/postcss-salad |
334 | 109 | [version]: https://img.shields.io/npm/v/postcss-salad.svg
|
| 110 | +[Gulp PostCSS]: https://github.com/postcss/gulp-postcss |
| 111 | +[PostCSS]: http://postcss.org/ |
| 112 | +[travis-img]: https://travis-ci.org/ElemeFE/postcss-salad.svg |
| 113 | +[travis]: https://travis-ci.org/ElemeFE/postcss-salad |
| 114 | +[Documents]: http://elemefe.github.io/postcss-salad/ |
0 commit comments