-
-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ feat(_flags.scss): Add flags for conditionally including/excluding …
…classes to generate, add support for conditional generation for util classes
- Loading branch information
1 parent
ec0f511
commit a455e2a
Showing
18 changed files
with
743 additions
and
153 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,78 @@ | ||
@use 'sass:list'; | ||
|
||
// Flag Constants | ||
$ALL: 'ALL'; | ||
|
||
$CLEARFIX: 'CLEARFIX'; | ||
$DISPLAY: 'DISPLAY'; | ||
$FLEX: 'FLEX'; | ||
$FLOAT: 'FLOAT'; | ||
$OVERFLOW: 'OVERFLOW'; | ||
$POSITION: 'POSITION'; | ||
$TEXT: 'TEXT'; | ||
$MARGIN-PADDING: 'MARGIN-PADDING'; | ||
$OPACITY: 'OPACITY'; | ||
$WIDTHS: 'WIDTHS'; | ||
$HEIGHTS: 'HEIGHTS'; | ||
$ZINDEX: 'ZINDEX'; | ||
$ABSOLUTE: 'ABSOLUTE'; | ||
$FLEX-GAP: 'FLEX-GAP'; | ||
$MIN-HEIGHT: 'MIN-HEIGHT'; | ||
$MAX-HEIGHT: 'MAX-HEIGHT'; | ||
$MIN-WIDTH: 'MIN-WIDTH'; | ||
$MAX-WIDTH: 'MAX-WIDTH'; | ||
$GRID: 'GRID'; | ||
$ROUND: 'ROUND'; | ||
$SHADOWS: 'SHADOWS'; | ||
|
||
// Turn on/off generating viewport classes to save on size. | ||
$_VIEWPORT_CLASS_FLAGS: ( | ||
'CLEARFIX': true, | ||
'DISPLAY': true, | ||
'FLEX': true, | ||
'FLOAT': true, | ||
'OVERFLOW': true, | ||
'POSITION': true, | ||
'TEXT': true, | ||
'MARGIN_PADDING': true, | ||
'OPACITY': true, | ||
'WIDTHS': true, | ||
'HEIGHTS': true, | ||
'ZINDEX': false, | ||
'ABSOLUTE': false, | ||
'FLEX-GAP': false, | ||
'MIN-HEIGHT': false, | ||
'MAX-HEIGHT': false, | ||
'MIN-WIDTH': false, | ||
'MAX-WIDTH': false, | ||
'GRID': true, | ||
); | ||
// TODO extend to include "!important" option | ||
$VIEWPORT_CLASS_FLAGS: ( | ||
$CLEARFIX: true, | ||
$DISPLAY: true, | ||
$FLEX: true, | ||
$FLOAT: true, | ||
$OVERFLOW: true, | ||
$POSITION: true, | ||
$TEXT: true, | ||
$MARGIN-PADDING: true, | ||
$OPACITY: true, | ||
$WIDTHS: true, | ||
$HEIGHTS: true, | ||
$ZINDEX: false, | ||
$ABSOLUTE: false, | ||
$FLEX-GAP: false, | ||
$MIN-HEIGHT: false, | ||
$MAX-HEIGHT: false, | ||
$MIN-WIDTH: false, | ||
$MAX-WIDTH: false, | ||
$GRID: true, | ||
); | ||
|
||
// Turn off certain features from being loaded. If left blank, all components are generated by default. | ||
$EXCLUDE: ( | ||
|
||
); | ||
|
||
// Enable certain classes to be generated. Takes precedence over $EXCLUDE. | ||
$INCLUDE: ( | ||
|
||
); | ||
|
||
/* | ||
Helper function to determine if a set of classes should be generated based on given include/exclude configuration. | ||
*/ | ||
@function _should-generate-classes($flag) { | ||
$generate-classes: true; | ||
@if list.index($EXCLUDE, $ALL) { | ||
$generate-classes: false; | ||
} | ||
@if list.index($EXCLUDE, $ABSOLUTE) { | ||
$generate-classes: false; | ||
} | ||
@if list.index($INCLUDE, $ABSOLUTE) { | ||
$generate-classes: true; | ||
} | ||
|
||
@return $generate-classes; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,19 @@ | ||
@import '../internal/functions'; | ||
@import '../internal/size'; | ||
@import '../internal/config'; | ||
@import '../internal/flags'; | ||
|
||
$directions: top, left, right, bottom; | ||
$generate-utility: _should-generate-classes($ABSOLUTE); | ||
|
||
@each $direction in $directions { | ||
@include generate-classes-for-viewport-with-map( | ||
$absolute, | ||
$direction, | ||
'u-#{$direction}-', | ||
$generate-viewports: #{get-viewport-flag('ABSOLUTE')} | ||
); | ||
@if $generate-utility { | ||
$directions: top, left, right, bottom; | ||
|
||
@each $direction in $directions { | ||
@include generate-classes-for-viewport-with-map( | ||
$absolute, | ||
$direction, | ||
'u-#{$direction}-', | ||
$generate-viewports: #{get-viewport-flag($ABSOLUTE)} | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,21 @@ | ||
@import '../internal/functions'; | ||
@import '../internal/size'; | ||
@import '../internal/flags'; | ||
|
||
$clears: left, right, both; | ||
$generate-utility: _should-generate-classes($CLEARFIX); | ||
|
||
@include generate-classes-for-viewport($clears, 'clear', 'u-clear-', $generate-viewports: #{get-viewport-flag('CLEARFIX')}); | ||
@if $generate-utility { | ||
$clears: left, right, both; | ||
|
||
/* | ||
When using floats, clearfix allows the container to automatically resize so that | ||
other elements are not blocked by children. | ||
*/ | ||
.u-clearfix:after { | ||
clear: both !important; | ||
content: ' '; | ||
display: table !important; | ||
@include generate-classes-for-viewport($clears, 'clear', 'u-clear-', $generate-viewports: #{get-viewport-flag($CLEARFIX)}); | ||
|
||
/* | ||
When using floats, clearfix allows the container to automatically resize so that | ||
other elements are not blocked by children. | ||
*/ | ||
.u-clearfix:after { | ||
clear: both !important; | ||
content: ' '; | ||
display: table !important; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
@import '../internal/functions'; | ||
@import '../internal/size'; | ||
@import '../internal/flags'; | ||
|
||
$display-utils-config: none, inline, inline-block, block, flex, inline-flex, table, table-row, table-column, table-cell; | ||
$generate-utility: _should-generate-classes($DISPLAY); | ||
|
||
@include generate-classes-for-viewport($display-utils-config, 'display', $generate-viewports: #{get-viewport-flag('DISPLAY')}); | ||
@if $generate-utility { | ||
$display-utils-config: none, inline, inline-block, block, flex, inline-flex, table, table-row, table-column, table-cell; | ||
|
||
@include generate-classes-for-viewport($display-utils-config, 'display', $generate-viewports: #{get-viewport-flag($DISPLAY)}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,58 @@ | ||
@import '../internal/functions'; | ||
@import '../internal/size'; | ||
@import '../internal/flags'; | ||
|
||
$flex-directions: row, row-reverse, column, column-reverse; | ||
|
||
$justify-content: flex-start, center, flex-end, space-between, space-around, space-evenly; | ||
|
||
$align-items: stretch, flex-start, center, flex-end, baseline; | ||
|
||
$flex-grow: 0, 1; | ||
|
||
@include generate-classes-for-viewport( | ||
$flex-directions, | ||
'flex-direction', | ||
'u#{delimitize('flex')}', | ||
$generate-viewports: #{get-viewport-flag('FLEX')} | ||
); | ||
@include generate-classes-for-viewport( | ||
$justify-content, | ||
'justify-content', | ||
'u#{delimitize('justify')}', | ||
$generate-viewports: #{get-viewport-flag('FLEX')} | ||
); | ||
@include generate-classes-for-viewport( | ||
$align-items, | ||
'align-items', | ||
'u#{delimitize('items')}', | ||
$generate-viewports: #{get-viewport-flag('FLEX')} | ||
); | ||
|
||
// Flex grow/shrink utils | ||
@include generate-classes-for-viewport( | ||
$flex-grow, | ||
'flex-grow', | ||
'u#{delimitize('flex-grow')}', | ||
$generate-viewports: #{get-viewport-flag('FLEX')} | ||
); | ||
|
||
// Generate flex gap class map | ||
$flex-gaps-both: (); | ||
// TODO: Consider if we need to generate for row and col only | ||
@each $size in $spacing-system { | ||
$flex-gaps-both: map-merge( | ||
$flex-gaps-both, | ||
( | ||
'gap-#{$size}': calc(#{$space-size} * #{$size}), | ||
) | ||
$generate-utility: _should-generate-classes($FLEX); | ||
|
||
@if $generate-utility { | ||
$flex-directions: row, row-reverse, column, column-reverse; | ||
$justify-content: flex-start, center, flex-end, space-between, space-around, space-evenly; | ||
$align-items: stretch, flex-start, center, flex-end, baseline; | ||
$flex-grow: 0, 1; | ||
|
||
@include generate-classes-for-viewport( | ||
$flex-directions, | ||
'flex-direction', | ||
'u#{delimitize('flex')}', | ||
$generate-viewports: #{get-viewport-flag($FLEX)} | ||
); | ||
@include generate-classes-for-viewport( | ||
$justify-content, | ||
'justify-content', | ||
'u#{delimitize('justify')}', | ||
$generate-viewports: #{get-viewport-flag($FLEX)} | ||
); | ||
@include generate-classes-for-viewport( | ||
$align-items, | ||
'align-items', | ||
'u#{delimitize('items')}', | ||
$generate-viewports: #{get-viewport-flag($FLEX)} | ||
); | ||
|
||
// Flex grow/shrink utils | ||
@include generate-classes-for-viewport( | ||
$flex-grow, | ||
'flex-grow', | ||
'u#{delimitize('flex-grow')}', | ||
$generate-viewports: #{get-viewport-flag($FLEX)} | ||
); | ||
} | ||
|
||
@include generate-classes-for-viewport-with-map($flex-gaps-both, 'gap', $generate-viewports: #{get-viewport-flag('FLEX-GAP')}); | ||
|
||
$generate-utility: _should-generate-classes($FLEX-GAP); | ||
|
||
@if $generate-utility { | ||
// Generate flex gap class map | ||
$flex-gaps-both: (); | ||
// TODO: Consider if we need to generate for row and col only | ||
@each $size in $spacing-system { | ||
$flex-gaps-both: map-merge( | ||
$flex-gaps-both, | ||
( | ||
'gap-#{$size}': calc(#{$space-size} * #{$size}), | ||
) | ||
); | ||
} | ||
|
||
@include generate-classes-for-viewport-with-map($flex-gaps-both, 'gap', $generate-viewports: #{get-viewport-flag($FLEX-GAP)}); | ||
} |
Oops, something went wrong.