-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(common-css): add CSS container quesries to common-css [ci visual]
- Loading branch information
1 parent
c913c4b
commit a9c5268
Showing
9 changed files
with
300 additions
and
50 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
@import 'common-settings'; | ||
@import 'common-mixins'; | ||
|
||
$block: #{$sap-namespace}-container-type; | ||
|
||
.#{$block} { | ||
@include sap-container-type(normal); | ||
|
||
&-normal { | ||
@include sap-container-type(normal); | ||
} | ||
|
||
&-size { | ||
@include sap-container-type(size); | ||
} | ||
|
||
&-inline-size { | ||
@include sap-container-type(inline-size); | ||
} | ||
} |
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
69 changes: 69 additions & 0 deletions
69
packages/common-css/stories/container-queries/container-queries.stories.js
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 |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import containerQueriesExampleExampleHtml from './container-queries.story.description.html?raw'; | ||
|
||
export default { | ||
title: 'Container Queries', | ||
parameters: { | ||
description: `Container queries are similar to media queries, but they allow you to apply styles to an element based on the dimensions of the element's container rather than the device’s viewport. For more information please visit the <a target="_blank" title="MDN documentation website" href="https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_container_queries">MDN website</a>. | ||
<br><br><br> | ||
<h3>Containment Context</h3> | ||
To define a container, you need to specify the <code>container-type</code> property on the element. The container-type can accept three options: size, inline-size, and normal. <br> | ||
<table style="width: 100%; border-collapse: collapse; margin-top: 1rem;"> | ||
<tbody> | ||
<tr> | ||
<td style="padding: 0.25rem;"><b>normal</b></td> | ||
<td style="padding: 0.25rem;">the element is not a query container for any container size, but it can be used to apply styles to the element</td> | ||
<td style="padding: 0.25rem;"><code>.sap-container-type-normal</code></td> | ||
<td style="padding: 0.25rem;"><code>@include sap-container-type(normal)</code></td> | ||
</tr> | ||
<tr> | ||
<td style="padding: 0.25rem;"><b>size</b></td> | ||
<td style="padding: 0.25rem;">the container will not assume the position it has on the viewport, you must explicitly set the height and width of the container</td> | ||
<td style="padding: 0.25rem;"><code>.sap-container-type-size</code></td> | ||
<td style="padding: 0.25rem;"><code>@include sap-container-type(size)</code></td> | ||
</tr> | ||
<tr> | ||
<td style="padding: 0.25rem;"><b>inline-size</b></td> | ||
<td style="padding: 0.25rem;">the element assumes the position it has on the viewport</td> | ||
<td style="padding: 0.25rem;"><code>.sap-container-type-inline-size</code></td> | ||
<td style="padding: 0.25rem;"><code>@include sap-container-type(inline-size)</code></td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
<br> | ||
<h3>Mixins</h3> | ||
<table style="width: 60%; border-collapse: collapse; margin-top: 1rem;text-align: left;"> | ||
<tr> | ||
<th style="padding: 0.25rem;">Mixin</th> | ||
<th style="padding: 0.25rem;">Container width</th> | ||
</tr> | ||
<tr> | ||
<td style="padding: 0.25rem;"><code>@include sap-container-query-sm()</code></td> | ||
<td style="padding: 0.25rem;">max-width: 599px</td> | ||
</tr> | ||
<tr> | ||
<td style="padding: 0.25rem;"><code>@include sap-container-query-md()</code></td> | ||
<td style="padding: 0.25rem;">600px <= width <= 1023px</td> | ||
</tr> | ||
<tr> | ||
<td style="padding: 0.25rem;"><code>@include sap-container-query-lg()</code></td> | ||
<td style="padding: 0.25rem;">1024px <= width <= 1439px</td> | ||
</tr> | ||
<tr> | ||
<td style="padding: 0.25rem;"><code>@include sap-container-query-xl()</code></td> | ||
<td style="padding: 0.25rem;">min-width: 1440px</td> | ||
</tr> | ||
<tr> | ||
<td style="padding: 0.25rem;"><code>@include sap-container-query-from($width)</code></td> | ||
<td style="padding: 0.25rem;">user defined</td> | ||
</tr> | ||
<tr> | ||
<td style="padding: 0.25rem;"><code>@include sap-container-query-until($width)</code></td> | ||
<td style="padding: 0.25rem;">user defined</td> | ||
</tr> | ||
</table> | ||
`, | ||
} | ||
}; | ||
|
||
|
||
export const UsingTheMixins = () => containerQueriesExampleExampleHtml; |
13 changes: 13 additions & 0 deletions
13
packages/common-css/stories/container-queries/container-queries.story.description.html
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<pre> | ||
.article-container { | ||
@include sap-container-type(inline-size); | ||
} | ||
|
||
|
||
@include sap-container-query-from(640px) { | ||
.article { | ||
font-size: 20px; | ||
} | ||
} | ||
|
||
</pre> |
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
Oops, something went wrong.