From 8ae383e42a4387cb6eb0322bbe89fdddfdfed5b2 Mon Sep 17 00:00:00 2001 From: "Rico Sta. Cruz" Date: Tue, 29 Aug 2017 01:39:39 +0800 Subject: [PATCH] Update --- Readme.md | 2 ++ _sass/2017/markdown/table.scss | 22 +++++++++++++++++++++ extras/js-lazy.md => js-lazy.md | 34 ++++++++++++++++++++++----------- 3 files changed, 47 insertions(+), 11 deletions(-) rename extras/js-lazy.md => js-lazy.md (59%) diff --git a/Readme.md b/Readme.md index 62887422a..f822efab9 100644 --- a/Readme.md +++ b/Readme.md @@ -17,6 +17,8 @@ `table` supports these: {: .-shortcuts} + {: .-left-align} + {: .-headers} `pre` supports these: diff --git a/_sass/2017/markdown/table.scss b/_sass/2017/markdown/table.scss index fbf8abbe8..2f3bdf8dd 100644 --- a/_sass/2017/markdown/table.scss +++ b/_sass/2017/markdown/table.scss @@ -20,8 +20,10 @@ & th { padding: 8px 16px; vertical-align: top; + text-align: left; } + & tr th:last-child, & tr td:last-child { text-align: right; } @@ -50,6 +52,11 @@ & thead { display: none; } + + & thead th { + font-weight: normal; + color: $base-a; + } } .MarkdownBody table.-shortcuts { @@ -65,3 +72,18 @@ color: $base-text; } } + +.MarkdownBody table.-left-align { + & tr th, + & tr td, + & tr td:last-child { + text-align: left; + } +} + +.MarkdownBody table.-headers { + & thead { + display: table-header-group; + border-bottom: solid 1px $dark-line-color; + } +} diff --git a/extras/js-lazy.md b/js-lazy.md similarity index 59% rename from extras/js-lazy.md rename to js-lazy.md index 08bfb8218..b19114119 100644 --- a/extras/js-lazy.md +++ b/js-lazy.md @@ -1,22 +1,34 @@ --- title: JavaScript lazy shortcuts category: JavaScript +layout: 2017/sheet --- -| What | Lazy mode | "The right way" | -| --- | --- | --- | -| String to number | `+str` | `parseInt(str, 10)` or `parseFloat()` | -| Math floor | `num | 0` | `Math.floor(num)` | -| Number to string | `'' + num` | `num.toString()` | -| Date to UNIX timestamp | `+new Date()` | `new Date().getTime()` | -| Any to boolean | `!!value` | `Boolean(value)` | -| Check array contents | `if (~arr.indexOf(v))` | `if (arr.includes(v))` | +## Shortcuts +{: .-left-reference} -> `.includes` is ES6-only, otherwise use `.indexOf(val) !== -1` if you don't polyfill - -## Examples +### Examples ```js n = +'4096' // n === 4096 s = '' + 200 // s === '200' ``` + +```js +now = +new Date() +isPublished = !!post.publishedAt +``` + +### Shortcuts + +| What | Lazy mode | "The right way" | +| --- | --- | --- | +| String to number | `+str` | `parseInt(str, 10)` _or_ `parseFloat()` | +| Math floor | `num | 0` | `Math.floor(num)` | +| Number to string | `'' + num` | `num.toString()` | +| Date to UNIX timestamp | `+new Date()` | `new Date().getTime()` | +| Any to boolean | `!!value` | `Boolean(value)` | +| Check array contents | `if (~arr.indexOf(v))` | `if (arr.includes(v))` | +{: .-left-align.-headers} + +`.includes` is ES6-only, otherwise use `.indexOf(val) !== -1` if you don't polyfill.