Skip to content

Commit 408f3d3

Browse files
Haroenvj-f1
authored andcommitted
playground: add (s)css examples (#3696)
* playground: add (s)css examples see #3667 * escape quotes * add license notice * lol fix prettier on prettier codebase
1 parent cf511ec commit 408f3d3

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

website/static/playground.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,44 @@ function getExample(parser) {
401401
"",
402402
"type RequestType = 'GET' | 'HEAD' | 'POST' | 'PUT' | 'OPTIONS' | 'CONNECT' | 'DELETE' | 'TRACE'"
403403
].join("\n");
404+
case "css":
405+
// Excerpted from the Bootstrap source, which is licensed under the MIT license:
406+
// https://github.com/twbs/bootstrap/blob/v4.0.0-beta.3/LICENSE
407+
return [
408+
"@media (max-width: 480px) {",
409+
" .bd-examples {margin-right: -.75rem;margin-left: -.75rem",
410+
" }",
411+
" ",
412+
' .bd-examples>[class^="col-"] {',
413+
" padding-right: .75rem;",
414+
" padding-left: .75rem;",
415+
" ",
416+
" }",
417+
"}"
418+
].join("\n");
419+
case "scss":
420+
// Excerpted from the Bootstrap source, which is licensed under the MIT license:
421+
// https://github.com/twbs/bootstrap/blob/v4.0.0-beta.3/LICENSE
422+
return [
423+
"@function color-yiq($color) {",
424+
" $r: red($color);$g: green($color);$b: blue($color);",
425+
"",
426+
" $yiq: (($r * 299) + ($g * 587) + ($b * 114)) / 1000;",
427+
"",
428+
" @if ($yiq >= $yiq-contrasted-threshold) {",
429+
" @return $yiq-text-dark;",
430+
"} @else {",
431+
" @return $yiq-text-light;",
432+
" }",
433+
"}",
434+
"",
435+
"@each $color, $value in $colors {",
436+
" .swatch-#{$color} {",
437+
" color: color-yiq($value);",
438+
" background-color: #{$value};",
439+
" }",
440+
"}"
441+
].join("\n");
404442
default:
405443
return "";
406444
}

0 commit comments

Comments
 (0)