Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial Version of Switcher Object #22

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ pageTitle: Changelog
* [breaking] breaking change
* [fix] Bugfix

## unreleased
* [new] Switcher Object

## 0.2.1
* [fix] Renamed `styles.scss` to `_styles.scss` to prevent `src/style.css` from
being generated in development mode.
Expand Down
17 changes: 17 additions & 0 deletions docs/objects/10-switcher.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
pageTitle: Switcher Object
sinceVersion: unreleased
---

{% codeSample %}
<div class="o-switcher" data-limit="5">
<div>
<div class="o-box u-bg-white"></div>
<div class="o-box u-bg-white"></div>
<div class="o-box u-bg-white"></div>
<div class="o-box u-bg-white"></div>
<div class="o-box u-bg-white"></div>
<div class="o-box u-bg-white"></div>
</div>
</div>
{% endcodeSample %}
1 change: 1 addition & 0 deletions src/_styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
@import "objects/media.object";
@import "objects/pack.object";
@import "objects/site.object";
@import "objects/switcher.object";
Copy link
Collaborator Author

@lucasdinonolte lucasdinonolte Jan 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Needs alphabetical order

@import "objects/stack.object";
@import "objects/wrapper.object";

Expand Down
37 changes: 37 additions & 0 deletions src/objects/_switcher.object.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
$o-switcher--limits: 2, 3, 4, 5, 6, 7, 8, 9, 10 !default;

.#{$objects--prefix}switcher {
--o-switcher--spacing: var(--layout-spacing--default);
--o-switcher--threshold: 30rem;

& > * {
display: flex;
flex-wrap: wrap;
margin: calc(var(--o-switcher--spacing) / 2 * -1);
}

& > * > * {
flex-grow: 1;
flex-basis: calc((var(--o-switcher--threshold) - (100% - var(--o-switcher--spacing))) * 999);
margin: calc(var(--o-switcher--spacing) / 2);
}

@each $spacing-name, $spacing-value in $layout-spacing--variants {
&[data-spacing='#{$spacing-name}'] {
--o-switcher--spacing: var(--layout-spacing--#{$spacing-name});
}
}

@each $measure-name, $measure-value in $typography--measures {
&[data-measure='#{$measure-name}'] {
--o-switcher--threshold: var(--typography-measure--#{$measure-name});
}
}

@each $limit in $o-switcher--limits {
&[data-limit='#{$limit}'] > * > :nth-last-child(n + #{$limit + 1}),
&[data-limit='#{$limit}'] > * > :nth-last-child(n + #{$limit + 1}) ~ * {
flex-basis: 100%;
}
}
}