OSDN Git Service

Regular updates
[twpd/master.git] / cheatsheet-styles.md
1 ---
2 title: Cheatsheet styles
3 layout: 2017/sheet
4 tags: [WIP]
5 updated: 2017-10-26
6 intro: |
7   This is a reference of styles that you can use on Devhints cheatsheets. How
8   meta!
9   You can refer to this when contributing your own cheatsheets to the [GitHub repo](https://github.com/rstacruz/cheatsheets/).
10 ---
11
12 Intro
13 -----
14
15 Variants
16 --------
17 {: .-three-column}
18
19 ### H2 sections
20
21 | `-one-column` | |
22 | `-two-column` | _(default)_|
23 | `-three-column` | |
24 | `-left-reference` | 3 columns<br>_(short first column)_ |
25 | `-no-hide` | Don't hide H2 |
26
27 See: [H2 sections](#two-columns)
28
29 ### H3 sections
30
31 | `-prime` | Highlight |
32
33 See: [H3 sections](#h3-sections-1)
34
35 ### Tables
36
37 | `-bold-first` | Bold first column |
38 | `-headers` | Show headers |
39 | `-left-align` | Don't right align last column |
40 | `-mute-em` | Lower opacity for italics |
41 | `-no-wrap` | Don't wrap text |
42 | `-shortcuts` | Shortcut keys |
43
44 See: [Tables](#tables-1)
45
46 ### Code
47
48 | `-box-chars` | Less line height<br>_for box drawing chars_ |
49 | `-setup` | Gray background |
50 | `-wrap` | Enables line-wrapping |
51
52 See: [Code](#code-1)
53
54 ### Paragraphs
55
56 | `-setup` | Gray background |
57 | `-crosslink` | Has arrow on the link |
58 {: .-gray}
59
60 See: [Paragraphs](#paragraphs-1)
61
62 ### Lists
63
64 | `-also-see` | Lighter background |
65 | `-four-column` | |
66 | `-six-column` | |
67
68 See: [Lists](#lists-1)
69
70 ### Adding variants
71 {: .-prime}
72
73 ```
74 ## Section
75 {: .-two-column}
76 ```
77
78 Devhints uses Kramdown, and supports adding classes via Kramdown's syntax.
79
80 H3 sections
81 -----------
82 {: .-three-column}
83
84 ### Supported
85
86 Each section can have the following children:
87
88 #### White
89
90 - `pre`
91 - `ul`
92 - `table`
93
94 #### Gray
95
96 - `p`
97 - `h4`
98
99 ### Prime section
100 {: .-prime}
101
102 This is a section with `{: .-prime}`. Notice the fancy highlight! Great for "getting started" kind of snippets.
103
104 ### H3 section
105
106 Every box is an H3 section. The box will encompass everything inside the body of the H3.
107
108 This is a basic section with paragraphs in it.
109
110 Code
111 ----
112 {: .-three-column}
113
114 ### Basic code
115
116 ```js
117 here.is(() => {
118   some.code()
119 })
120 ```
121
122 ```js
123 here.is.some.more()
124 ```
125
126 Code blocks can be placed one after the other.
127
128 See: [Cheatsheets](/)
129
130 ### Code with headings
131
132 #### index.js
133 {: .-file}
134
135 ```js
136 here.is(() => {
137   some.code()
138 })
139 ```
140
141 #### other.js
142 {: .-file}
143
144 ```js
145 here.is.some.more()
146 ```
147
148 Code blocks can have headings.
149
150 ### Highlighted lines
151
152 ```js
153 app.start(() => {
154   const port = app.server.port
155   console.log(`Started at ${port}`)
156 })
157 ```
158 {: data-line="3"}
159
160 Add `{: data-line="3"}` to add line highlights.
161
162 ### Multiple highlights
163
164 ```js
165 app.start(() => {
166   const port = app.server.port
167   console.log(`Started at ${port}`)
168 })
169 ```
170 {: data-line="2,3"}
171
172 Add `{: data-line="2,3"}` to add multiple line highlights.
173
174 ### Setup blocks
175
176 ```js
177 import React from 'react'
178 ```
179 {: .-setup}
180
181 ```js
182 class Hello extends React.Component {
183   render () {
184     return <span>Hello</span>
185   }
186 }
187 ```
188
189 Add `{: .-setup}` to a `pre` or `table` or `ul`.
190
191 ### Long lines
192
193 ```js
194 function createNode(nodeName: string, options: { key: string }) {
195   return true
196 }
197 ```
198
199 Long lines will have scrollbars.
200
201 ### Line wrapping
202
203 ```js
204 <script>(function(d,s){if(window.Promise&&[].includes&&Object.assign&&window.Map)return;var js,sc=d.getElementsByTagName(s)[0];js=d.createElement(s);js.src='https://cdn.polyfill.io/v2/polyfill.min.js';sc.parentNode.insertBefore(js, sc);}(document,'script'))</script>
205 ```
206 {: .-wrap}
207
208 Add `-wrap` to wrap long lines.
209
210 ## Lists
211 {: .-three-column}
212
213 ### Lists
214
215 - This is
216 - a list
217 - with a few items
218
219 Here's an extra paragraph after the list.
220
221 ### Lists with headings
222
223 #### Part 1
224
225 - `createElement()`
226 - `componentDidMount()`
227 - `componentWillUnmount()`
228
229 #### Part 2
230
231 - `shouldComponentUpdate()`
232 - `componentWillReceiveProps()`
233
234
235 Here's an extra paragraph after the list.
236
237 ## List columns
238 {: .-one-column}
239
240 ### Six columns
241
242 - One
243 - Two
244 - Three
245 - Four
246 - Five
247 - Six
248 - Seven
249 - Eight
250 - Nine
251 - Ten
252 - Eleven
253 {: .-six-column}
254
255 Add `{: .-six-column}` to make large lists.
256
257 ### Four columns
258
259 - One
260 - Two
261 - Three
262 - Four
263 - Five
264 - Six
265 - Seven
266 - Eight
267 - Nine
268 - Ten
269 - Eleven
270 {: .-four-column}
271
272 Add `{: .-four-column}` to make large lists.
273
274 ### Also see
275
276 - One
277 - Two
278 - Three
279 - Four
280 - Five
281 - Six
282 - Seven
283 - Eight
284 - Nine
285 - Ten
286 {: .-also-see}
287
288 Add `{: .-also-see}`.
289
290 ## Paragraphs
291 {: .-three-column}
292
293 ### Basic paragraphs
294
295 This is a basic section with paragraphs in it. When paragraphs are the first elements in an H3 section's body, they appear as white.
296
297 ### Basic paragraphs
298
299 ```
300 ···
301 ```
302
303 When paragraphs appear after `pre`/`table`/`ul`, they appear with a gray background.
304
305 ### Preludes
306
307 Here's a prelude paragraph. Add `{: .-setup}` to make paragraphs appear with a gray background.
308 {: .-setup}
309
310 ```
311 ···
312 ```
313
314 ### Crosslink
315
316 Add `{: .-crosslink}` to make big loud external links:
317
318 ```
319 ···
320 ```
321
322 [Home](/)
323 {: .-crosslink}
324
325 ## Tables
326 {: .-three-column}
327
328 ### Basic table
329
330 #### Date
331
332 | Example         | Output                 |
333 | ---             | ---                    |
334 | `%m/%d/%Y`      | `06/05/2013`           |
335 | `%A, %B %e, %Y` | `Sunday, June 5, 2013` |
336 | `%b %e %a`      | `Jun 5 Sun`            |
337
338 #### Time
339
340 | Example         | Output                 |
341 | ---             | ---                    |
342 | `%H:%M`         | `23:05`                |
343 | `%I:%M %p`      | `11:05 PM`             |
344
345 This is a basic table with h4's.
346
347 ### Shortcuts
348
349 | `V` | Vector |
350 | `P` | Pencil |
351 | `T` | Text |
352 | `L` | Line |
353 | `R` | Rectangle |
354 | `O` | Oval |
355 | `U` | Rounded |
356 {: .-shortcuts}
357
358 Add `{: .-shortcuts}` to tables.
359
360 ### With headers
361
362 | Prefix | Example               | What     |
363 | ---    | ---                   | ---      |
364 | `//`   | `//hr[@class='edge']` | Anywhere |
365 | `./`   | `./a`                 | Relative |
366 | `/`    | `/html/body/div`      | Root     |
367 {: .-headers}
368
369 Add `{: .-headers}` to add headers.
370
371 ## Two columns
372
373 ### One
374
375 ```
376 ···
377 ```
378
379 ### Two
380
381 ```
382 ···
383 ```
384
385 ## Left reference
386 {: .-left-reference}
387
388 ### One
389
390 ```
391 ···
392 ···
393 ···
394 ···
395 ···
396 ···
397 ···
398 ···
399 ```
400
401 ### Two
402
403 ```
404 ···
405 ```
406
407 ### Three
408
409 ```
410 ···
411 ```
412
413 ## One column
414 {: .-one-column}
415
416 ### One
417
418 ```
419 ···
420 ```