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

feat: Rename reset mixins to include element name #1738

Merged
merged 6 commits into from
Nov 8, 2024
Merged
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
6 changes: 5 additions & 1 deletion packages/css/documentation/coding-conventions.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,13 @@ Still, we define its thickness and offset for the initial state.
## Use mixins for patterns and resets

We use Sass mixins to extract common patterns, especially if they need more than 1 declaration.
We collect reset styles in mixins as well.
Both the name of the mixins and their documentation help explain the approach.

We collect reset styles in mixins as well.
These are named after the element they reset, e.g. `@mixin reset-ul`.
This helps reusing reset styles per element, and reminds to update the mixin if the element type changes.
The declarations in the mixin must override default user agent styling; otherwise it is not a reset.

## Form validation styling

We style both the native invalid state (`:invalid`) as the invalid state you can set manually, using `aria-invalid`.
Expand Down
6 changes: 3 additions & 3 deletions packages/css/src/components/blockquote/blockquote.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
@import "../../common/hyphenation";
@import "../../common/text-rendering";

@mixin reset {
alimpens marked this conversation as resolved.
Show resolved Hide resolved
box-sizing: border-box;
@mixin reset-blockquote {
margin-block: 0;
margin-inline: 0;
}

.ams-blockquote {
box-sizing: border-box;
break-inside: avoid;
color: var(--ams-blockquote-color);
font-family: var(--ams-blockquote-font-family);
Expand All @@ -23,7 +23,7 @@

@include hyphenation;
@include text-rendering;
@include reset;
@include reset-blockquote;

&::before {
content: open-quote;
Expand Down
6 changes: 3 additions & 3 deletions packages/css/src/components/breadcrumb/breadcrumb.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@

@import "../../common/text-rendering";

@mixin reset {
box-sizing: border-box;
@mixin reset-ol {
margin-block: 0;
padding-inline: 0;
}
Expand All @@ -19,11 +18,12 @@
}

.ams-breadcrumb__list {
box-sizing: border-box;
break-after: avoid;
break-inside: avoid;

@include text-rendering;
@include reset;
@include reset-ol;
}

.ams-breadcrumb__item {
Expand Down
6 changes: 3 additions & 3 deletions packages/css/src/components/date-input/date-input.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@

@import "../../common/text-rendering";

@mixin reset {
@mixin reset-input {
-webkit-appearance: none; // Reset appearance for Safari < 15.4
appearance: none; // Reset native appearance, this causes issues on iOS and Android devices
border: 0;
border-radius: 0; // Reset rounded borders on iOS devices
box-sizing: border-box;
margin-block: 0;
}

.ams-date-input {
background-color: var(--ams-date-input-background-color);
box-shadow: var(--ams-date-input-box-shadow);
box-sizing: border-box;
color: var(--ams-date-input-color);
font-family: var(--ams-date-input-font-family);
font-size: var(--ams-date-input-font-size);
Expand All @@ -36,7 +36,7 @@
touch-action: manipulation;

@include text-rendering;
@include reset;
@include reset-input;

&:hover {
box-shadow: var(--ams-date-input-hover-box-shadow);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
@import "../../common/breakpoint";
@import "../../common/text-rendering";

@mixin reset {
box-sizing: border-box;
@mixin reset-dl {
margin-block: 0;
}

.ams-description-list {
box-sizing: border-box;
color: var(--ams-description-list-color);
column-gap: var(--ams-description-list-column-gap);
display: grid;
Expand All @@ -20,7 +20,7 @@
line-height: var(--ams-description-list-line-height);
row-gap: var(--ams-description-list-row-gap);

@include reset;
@include reset-dl;
@include text-rendering;
}

Expand Down Expand Up @@ -54,15 +54,15 @@
}
}

@mixin reset-description {
@mixin reset-dd {
margin-inline: 0;
}

.ams-description-list__description {
font-weight: var(--ams-description-list-description-font-weight);
padding-inline-start: var(--ams-description-list-description-padding-inline-start);

@include reset-description;
@include reset-dd;

@media screen and (min-width: $ams-breakpoint-medium) {
grid-column-start: 2;
Expand Down
2 changes: 1 addition & 1 deletion packages/css/src/components/dialog/dialog.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
*/

@mixin reset-dialog {
box-sizing: border-box;
inset-block: 0;
}

Expand All @@ -13,6 +12,7 @@ so do not apply these styles without an `open` attribute. */
.ams-dialog:not(dialog:not([open])) {
background-color: var(--ams-dialog-background-color);
border: var(--ams-dialog-border);
box-sizing: border-box;
display: flex; // Using flex here, because grid works strangely in Safari
flex-direction: column;
gap: var(--ams-dialog-gap);
Expand Down
6 changes: 3 additions & 3 deletions packages/css/src/components/error-message/error-message.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

@import "../../common/text-rendering";

@mixin reset {
box-sizing: border-box;
@mixin reset-p {
margin-block: 0;
}

.ams-error-message {
box-sizing: border-box;
color: var(--ams-error-message-color);
display: inline-flex;
font-family: var(--ams-error-message-font-family);
Expand All @@ -20,5 +20,5 @@
line-height: var(--ams-error-message-line-height);

@include text-rendering;
@include reset;
@include reset-p;
}
4 changes: 2 additions & 2 deletions packages/css/src/components/field-set/field-set.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
@import "../../common/hyphenation";
@import "../../common/text-rendering";

@mixin reset {
@mixin reset-fieldset {
border: 0;
margin-inline: 0;
padding-block: 0;
Expand All @@ -16,7 +16,7 @@
.ams-field-set {
break-inside: avoid;

@include reset;
@include reset-fieldset;
}

.ams-field-set--invalid {
Expand Down
2 changes: 1 addition & 1 deletion packages/css/src/components/file-input/file-input.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
@mixin reset-button {
border: 0;
border-radius: 0; // Reset rounded borders on iOS devices
box-sizing: border-box;
}

.ams-file-input {
Expand Down Expand Up @@ -39,6 +38,7 @@
appearance: none; // Reset native appearance, this causes issues on iOS and Android devices
background-color: var(--ams-file-input-file-selector-button-background-color);
box-shadow: var(--ams-file-input-file-selector-button-box-shadow);
box-sizing: border-box;
color: var(--ams-file-input-file-selector-button-color);
cursor: var(--ams-file-input-file-selector-button-cursor);
font-family: inherit;
Expand Down
6 changes: 3 additions & 3 deletions packages/css/src/components/heading/heading.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
@import "../../common/hyphenation";
@import "../../common/text-rendering";

@mixin reset {
box-sizing: border-box;
@mixin reset-hx {
margin-block: 0;
}

.ams-heading {
box-sizing: border-box;
break-after: avoid;
break-inside: avoid;
color: var(--ams-heading-color);
Expand All @@ -20,7 +20,7 @@

@include hyphenation;
@include text-rendering;
@include reset;
@include reset-hx;
}

.ams-heading--level-1 {
Expand Down
4 changes: 2 additions & 2 deletions packages/css/src/components/icon-button/icon-button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Copyright Gemeente Amsterdam
*/

@mixin reset {
@mixin reset-button {
border: 0;
margin-block: 0; // [1]
margin-inline: 0; // [1]
Expand All @@ -20,7 +20,7 @@
outline-offset: var(--ams-icon-button-outline-offset);
touch-action: manipulation;

@include reset;
@include reset-button;

&:hover {
background-color: var(--ams-icon-button-hover-background-color);
Expand Down
6 changes: 3 additions & 3 deletions packages/css/src/components/link-list/link-list.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@
@import "../../common/hyphenation";
@import "../../common/text-rendering";

@mixin reset-list {
box-sizing: border-box;
@mixin reset-ul {
list-style: none;
margin-block: 0;
padding-inline-start: 0;
}

.ams-link-list {
box-sizing: border-box;
display: grid;
gap: var(--ams-link-list-gap);

@include text-rendering;
@include reset-list;
@include reset-ul;
}

.ams-link-list__link {
Expand Down
6 changes: 3 additions & 3 deletions packages/css/src/components/ordered-list/ordered-list.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@

@import "../../common/text-rendering";

@mixin reset {
box-sizing: border-box;
@mixin reset-ol {
list-style-type: none;
margin-block: 0;
padding-inline-start: 0;
}

.ams-ordered-list {
box-sizing: border-box;
display: grid;
gap: var(--ams-ordered-list-gap);

@include text-rendering;
@include reset;
@include reset-ol;
}

.ams-ordered-list:not(.ams-ordered-list--no-markers) {
Expand Down
6 changes: 3 additions & 3 deletions packages/css/src/components/page-heading/page-heading.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
@import "../../common/hyphenation";
@import "../../common/text-rendering";

@mixin reset {
box-sizing: border-box;
@mixin reset-h1 {
margin-block: 0;
}

.ams-page-heading {
box-sizing: border-box;
break-after: avoid;
break-inside: avoid;
color: var(--ams-page-heading-color);
Expand All @@ -22,7 +22,7 @@

@include hyphenation;
@include text-rendering;
@include reset;
@include reset-h1;
}

.ams-page-heading--inverse-color {
Expand Down
13 changes: 5 additions & 8 deletions packages/css/src/components/page-menu/page-menu.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,22 @@

@import "../../common/text-rendering";

@mixin reset-list {
box-sizing: border-box;
@mixin reset-ul {
margin-block: 0;
padding-inline: 0;
}

@mixin reset-item {
box-sizing: border-box;
}

.ams-page-menu {
align-items: center;
box-sizing: border-box;
column-gap: var(--ams-page-menu-column-gap);
display: flex;
flex-direction: row;
flex-wrap: wrap;
list-style: none;
row-gap: var(--ams-page-menu-row-gap);

@include reset-list;
@include reset-ul;
}

.ams-page-menu--align-end {
Expand Down Expand Up @@ -54,9 +50,10 @@
}

.ams-page-menu__link {
box-sizing: border-box;

@include page-menu-item;
@include text-rendering;
@include reset-item;
}

.ams-page-menu__link:hover,
Expand Down
6 changes: 3 additions & 3 deletions packages/css/src/components/pagination/pagination.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

@import "../../common/text-rendering";

@mixin reset-list {
@mixin reset-ol {
list-style-type: none;
margin-block: 0;
padding-inline-start: 0;
Expand All @@ -21,12 +21,11 @@
justify-content: center;
line-height: var(--ams-pagination-line-height);

@include reset-list;
@include reset-ol;
}

@mixin reset-button {
all: unset;
box-sizing: border-box;
outline: revert;
}

Expand All @@ -35,6 +34,7 @@
at the bottom `all: unset` overrides the `gap` property. */
@include reset-button;

box-sizing: border-box;
cursor: pointer;
display: flex;
gap: var(--ams-pagination-button-gap);
Expand Down
Loading