From 95750cb9a9f918456565316776bcb899b8dcf473 Mon Sep 17 00:00:00 2001 From: Sana Javed Date: Mon, 5 Jun 2023 21:00:37 +0200 Subject: [PATCH] Values - Null --- source/documentation/values/null.liquid | 79 +++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 source/documentation/values/null.liquid diff --git a/source/documentation/values/null.liquid b/source/documentation/values/null.liquid new file mode 100644 index 0000000..b66d0f6 --- /dev/null +++ b/source/documentation/values/null.liquid @@ -0,0 +1,79 @@ +--- +title: "null" +introduction: > + The value `null` is the only value of its type. It represents the absence of a + value, and is often returned by [functions](/documentation/at-rules/function) to indicate + the lack of a result. +--- + +{% codeExample 'null', false %} + @use "sass:map"; + @use "sass:string"; + + @debug string.index("Helvetica Neue", "Roboto"); // null + @debug map.get(("large": 20px), "small"); // null + @debug &; // null + === + @use "sass:map" + @use "sass:string" + + @debug string.index("Helvetica Neue", "Roboto") // null + @debug map.get(("large": 20px), "small") // null + @debug & // null +{% endcodeExample %} + +{% markdown %} + If a [list][] contains a `null`, that `null` is omitted from the generated CSS. + + [list]: /documentation/values/lists +{% endmarkdown %} + +{% codeExample 'null-lists' %} + $fonts: ("serif": "Helvetica Neue", "monospace": "Consolas"); + + h3 { + font: 18px bold map-get($fonts, "sans"); + } + === + $fonts: ("serif": "Helvetica Neue", "monospace": "Consolas") + + h3 + font: 18px bold map-get($fonts, "sans") +{% endcodeExample %} + +{% markdown %} +If a property value is `null`, that property is omitted entirely. +{% endmarkdown %} + +{% codeExample 'null-value-omitted' %} + $fonts: ("serif": "Helvetica Neue", "monospace": "Consolas"); + + h3 { + font: { + size: 18px; + weight: bold; + family: map-get($fonts, "sans"); + } + } + === + $fonts: ("serif": "Helvetica Neue", "monospace": "Consolas") + + h3 + font: + size: 18px + weight: bold + family: map-get($fonts, "sans") +{% endcodeExample %} + +{% markdown %} + `null` is also [*falsey*][], which means it counts as `false` for any rules or + [operators][] that take booleans. This makes it easy to use values that can be + `null` as conditions for [`@if`][] and [`if()`][]. + + [*falsey*]: /documentation/at-rules/control/if#truthiness-and-falsiness + [operators]: /documentation/operators/boolean + [`@if`]: /documentation/at-rules/control/if + [`if()`]: /documentation/modules#if +{% endmarkdown %} + +{% render 'code-snippets/example-if-parent-selector' %}