Skip to content

Commit

Permalink
feat: add utilities to hide and display elements based on screen size
Browse files Browse the repository at this point in the history
  • Loading branch information
tillywoodfield committed Nov 5, 2024
1 parent 2f0c4dc commit 9c7450d
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/scss/components/button/_button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
@use "../../tokens/spacing" as *;

.iati-button {
display: inline-flex;
--display: inline-flex; // Used by .display--* utilities

display: var(--display);
align-items: center;
justify-content: center;
gap: 0.25em;
Expand Down
1 change: 1 addition & 0 deletions src/scss/iati.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
@use "typography";
@use "components";
@use "layout";
@use "utilities";

// Expose tokens as Sass variables
@forward "tokens";
Expand Down
2 changes: 1 addition & 1 deletion src/scss/layout/header/header.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const Header: Story = {
<div class="iati-header__container iati-brand-background__content">
<div class="iati-header__actions">
${CountrySwitcher.render?.call({ ...args })}
<button class="iati-button iati-button--light">
<button class="iati-button iati-button--light hide display--sm">
<span>Help Docs</span>
<img class="iati-button__icon" src="${iconInfoUrl}" alt="" />
</button>
Expand Down
15 changes: 15 additions & 0 deletions src/scss/utilities/_display.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@use "../tokens/screens" as *;

:root {
--display: block;
}

.hide {
display: none;
}

.display--sm {
@media (min-width: $screen-sm) {
display: var(--display);
}
}
1 change: 1 addition & 0 deletions src/scss/utilities/_index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@use "display";

0 comments on commit 9c7450d

Please sign in to comment.