From 29bd5e32186b2d56b7b35a09597bfed6636d66c9 Mon Sep 17 00:00:00 2001 From: Mark Otto Date: Tue, 18 Sep 2018 19:54:56 -0700 Subject: [PATCH] Add overflow-auto and overflow-hidden utilities --- scss/_utilities.scss | 1 + scss/_variables.scss | 6 ++++++ scss/utilities/_overflow.scss | 5 +++++ scss/utilities/_position.scss | 5 ----- site/_data/nav.yml | 1 + site/docs/4.1/utilities/overflow.md | 25 +++++++++++++++++++++++++ 6 files changed, 38 insertions(+), 5 deletions(-) create mode 100644 scss/utilities/_overflow.scss create mode 100644 site/docs/4.1/utilities/overflow.md diff --git a/scss/_utilities.scss b/scss/_utilities.scss index 6c7a7cdd34..913fb852d5 100644 --- a/scss/_utilities.scss +++ b/scss/_utilities.scss @@ -6,6 +6,7 @@ @import "utilities/embed"; @import "utilities/flex"; @import "utilities/float"; +@import "utilities/overflow"; @import "utilities/position"; @import "utilities/screenreaders"; @import "utilities/shadows"; diff --git a/scss/_variables.scss b/scss/_variables.scss index 9ac52e3d32..79169319bf 100644 --- a/scss/_variables.scss +++ b/scss/_variables.scss @@ -1001,6 +1001,12 @@ $pre-color: $gray-900 !default; $pre-scrollable-max-height: 340px !default; +// Utilities + +$overflows: auto, hidden !default; +$positions: static, relative, absolute, fixed, sticky !default; + + // Printing $print-page-size: a3 !default; diff --git a/scss/utilities/_overflow.scss b/scss/utilities/_overflow.scss new file mode 100644 index 0000000000..8326c30641 --- /dev/null +++ b/scss/utilities/_overflow.scss @@ -0,0 +1,5 @@ +// stylelint-disable declaration-no-important + +@each $value in $overflows { + .overflow-#{$value} { overflow: $value !important; } +} diff --git a/scss/utilities/_position.scss b/scss/utilities/_position.scss index 9ecdeeb9be..cdf6c115f3 100644 --- a/scss/utilities/_position.scss +++ b/scss/utilities/_position.scss @@ -1,11 +1,6 @@ // stylelint-disable declaration-no-important // Common values - -// Sass list not in variables since it's not intended for customization. -// stylelint-disable-next-line scss/dollar-variable-default -$positions: static, relative, absolute, fixed, sticky; - @each $position in $positions { .position-#{$position} { position: $position !important; } } diff --git a/site/_data/nav.yml b/site/_data/nav.yml index 99cb90f849..7aa92bd288 100644 --- a/site/_data/nav.yml +++ b/site/_data/nav.yml @@ -62,6 +62,7 @@ - title: Flex - title: Float - title: Image replacement + - title: Overflow - title: Position - title: Screenreaders - title: Shadows diff --git a/site/docs/4.1/utilities/overflow.md b/site/docs/4.1/utilities/overflow.md new file mode 100644 index 0000000000..33f6d757f1 --- /dev/null +++ b/site/docs/4.1/utilities/overflow.md @@ -0,0 +1,25 @@ +--- +layout: docs +title: Overflow +description: Use these shorthand utilities for quickly configuring how content overflows an element. +group: utilities +toc: true +--- + +Barebones `overflow` functionality is provided for two values by default, and they are not responsive. + +
+
+ This is an example of using .overflow-auto on an element with set width and height dimensions. By design, this content will vertically scroll. +
+
+ This is an example of using .overflow-hidden on an element with set width and height dimensions. +
+
+ +{% highlight html %} +
...
+
...
+{% endhighlight %} + +Using Sass variables, you may customize the overflow utilities by changing the `$overflows` variable in `_variables.scss`.