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

fix!: Disallow directional style rules #1245

Merged
Merged
Show file tree
Hide file tree
Changes from 3 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
21 changes: 12 additions & 9 deletions .stylelintrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"extends": ["stylelint-config-standard-scss"],
"plugins": ["stylelint-order"],
"plugins": ["stylelint-order", "stylelint-use-logical"],
"rules": {
"alpha-value-notation": ["percentage"],
"at-rule-empty-line-before": null,
Expand All @@ -9,6 +9,7 @@
"color-function-notation": ["modern"],
"color-no-invalid-hex": true,
"comment-no-empty": true,
"csstools/use-logical": true,
"custom-property-pattern": "^_?(ams|nl|utrecht)-[a-z0-9-]+$",
"declaration-block-no-duplicate-properties": true,
"declaration-block-no-redundant-longhand-properties": null,
Expand Down Expand Up @@ -50,16 +51,18 @@
"order/properties-alphabetical-order": true,
"property-disallowed-list": [
[
"contain-intrinsic-height",
"contain-intrinsic-width",
"margin",
"margin-bottom",
"margin-left",
"margin-right",
"margin-top",
"padding",
"padding-bottom",
"padding-left",
"padding-right",
"padding-top"
"scroll-margin-bottom",
"scroll-margin-left",
"scroll-margin-right",
"scroll-margin-top",
"scroll-padding-bottom",
"scroll-padding-left",
"scroll-padding-right",
"scroll-padding-top"
]
],
"property-no-unknown": true,
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"stylelint": "16.5.0",
"stylelint-config-standard-scss": "13.1.0",
"stylelint-order": "6.0.4",
"stylelint-use-logical": "2.1.2",
"typescript": "5.4.5",
"wait-on": "7.2.0"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/css/src/common/hide-input.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

@mixin hide-input {
appearance: none;
inline-size: 0; // Make sure the input doesn’t take up space on iOS
margin-block: 0;
margin-inline: 0;
width: 0; // Make sure the input doesn’t take up space on iOS
}
2 changes: 1 addition & 1 deletion packages/css/src/components/accordion/accordion.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
font-size: var(--ams-accordion-button-font-size);
font-weight: var(--ams-accordion-button-font-weight);
gap: var(--ams-accordion-button-gap);
inline-size: 100%;
line-height: var(--ams-accordion-button-line-height);
padding-block: var(--ams-accordion-button-padding-block);
padding-inline: var(--ams-accordion-button-padding-inline);
width: 100%;

&:focus {
outline-offset: var(--ams-accordion-button-focus-outline-offset);
Expand Down
4 changes: 2 additions & 2 deletions packages/css/src/components/avatar/avatar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,23 @@
display: inline-flex;
font-family: var(--ams-avatar-font-family);
font-size: var(--ams-avatar-font-size);
inline-size: calc(var(--ams-avatar-line-height) * var(--ams-avatar-font-size));
line-height: var(--ams-avatar-line-height);
padding-block: var(--ams-avatar-padding-block);
padding-inline: var(--ams-avatar-padding-inline);
place-content: center;
width: calc(var(--ams-avatar-line-height) * var(--ams-avatar-font-size));

svg {
fill: currentColor;
}
}

.ams-avatar--has-image {
inline-size: calc(var(--ams-avatar-line-height) * var(--ams-avatar-font-size) + 2 * var(--ams-avatar-padding-inline));
overflow: hidden;
padding-block: 0;
padding-inline: 0;
vertical-align: middle; /* Remove ‘phantom’ white space when image doesn’t load */
width: calc(var(--ams-avatar-line-height) * var(--ams-avatar-font-size) + 2 * var(--ams-avatar-padding-inline));
}

.ams-avatar--blue {
Expand Down
4 changes: 2 additions & 2 deletions packages/css/src/components/breadcrumb/breadcrumb.scss
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@
.ams-breadcrumb__item:not(:last-child)::after {
background-image: var(--ams-breadcrumb-separator-background-image);
background-repeat: no-repeat;
block-size: 1ex;
content: "";
display: inline-block;
height: 1ex;
inline-size: 1ex;
margin-inline: 0.5rem;
width: 1ex;
}

.ams-breadcrumb__link {
Expand Down
8 changes: 4 additions & 4 deletions packages/css/src/components/checkbox/checkbox.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@

.ams-checkbox__checkmark {
align-items: center;
block-size: calc(var(--ams-checkbox-font-size) * var(--ams-checkbox-line-height));
display: flex;
flex-shrink: 0;
height: calc(var(--ams-checkbox-font-size) * var(--ams-checkbox-line-height));
width: 1.5rem;
inline-size: 1.5rem;

&::after {
background-position: center;
background-repeat: no-repeat;
background-size: 1rem;
block-size: 1.5rem;
border-color: var(--ams-checkbox-checkmark-border-color);
border-style: solid;
border-width: var(--ams-checkbox-checkmark-border-width);
box-sizing: border-box;
content: "";
height: 1.5rem;
width: 100%;
inline-size: 100%;
}
}

Expand Down
8 changes: 4 additions & 4 deletions packages/css/src/components/date-input/date-input.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@
font-weight: var(--ams-date-input-font-weight);
line-height: var(--ams-date-input-line-height);

// Set min height for iOS, otherwise an empty box is a lot smaller than a filled one.
min-height: calc(
// Set min block size for iOS, otherwise an empty box is a lot smaller than a filled one.
min-block-size: calc(
(var(--ams-date-input-font-size) * var(--ams-date-input-line-height)) + 2 * var(--ams-date-input-padding-block)
);

// Set min width for iOS, so the width is closer to the filled in width.
min-width: calc(8ch + (2 * var(--ams-date-input-padding-inline)));
// Set min inline size for iOS, so the size is closer to the filled in size.
min-inline-size: calc(8ch + (2 * var(--ams-date-input-padding-inline)));
outline-offset: var(--ams-date-input-outline-offset);
padding-block: var(--ams-date-input-padding-block);
padding-inline: var(--ams-date-input-padding-inline);
Expand Down
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 @@ -25,9 +25,9 @@
}

@mixin reset-legend {
float: left; // [1]
float: inline-start; // [1]
inline-size: 100%; // [1]
padding-inline: 0;
width: 100%; // [1]
}

// [1] This combination allows the fieldset border to go around the legend, instead of through it.
Expand Down
4 changes: 2 additions & 2 deletions packages/css/src/components/header/header.scss
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,16 @@
flex: 1 1 100%;

@media screen and (min-width: $ams-breakpoint-wide) {
min-width: 0;
min-inline-size: 0;
order: 2;

.ams-header__title-heading {
display: block;
inline-size: 100%;
line-height: 1;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
width: 100%;
}
}
}
Expand Down
24 changes: 12 additions & 12 deletions packages/css/src/components/icon/icon.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,37 +18,37 @@
}

.ams-icon--size-3 {
height: calc(var(--ams-icon-size-3-font-size) * var(--ams-icon-size-3-line-height));
block-size: calc(var(--ams-icon-size-3-font-size) * var(--ams-icon-size-3-line-height));
}

.ams-icon--size-3 svg {
height: var(--ams-icon-size-3-font-size);
width: var(--ams-icon-size-3-font-size);
block-size: var(--ams-icon-size-3-font-size);
inline-size: var(--ams-icon-size-3-font-size);
}

.ams-icon--size-4 {
height: calc(var(--ams-icon-size-4-font-size) * var(--ams-icon-size-4-line-height));
block-size: calc(var(--ams-icon-size-4-font-size) * var(--ams-icon-size-4-line-height));
}

.ams-icon--size-4 svg {
height: var(--ams-icon-size-4-font-size);
width: var(--ams-icon-size-4-font-size);
block-size: var(--ams-icon-size-4-font-size);
inline-size: var(--ams-icon-size-4-font-size);
}

.ams-icon--size-5 {
height: calc(var(--ams-icon-size-5-font-size) * var(--ams-icon-size-5-line-height));
block-size: calc(var(--ams-icon-size-5-font-size) * var(--ams-icon-size-5-line-height));
}

.ams-icon--size-5 svg {
height: var(--ams-icon-size-5-font-size);
width: var(--ams-icon-size-5-font-size);
block-size: var(--ams-icon-size-5-font-size);
inline-size: var(--ams-icon-size-5-font-size);
}

.ams-icon--size-6 {
height: calc(var(--ams-icon-size-6-font-size) * var(--ams-icon-size-6-line-height));
block-size: calc(var(--ams-icon-size-6-font-size) * var(--ams-icon-size-6-line-height));
}

.ams-icon--size-6 svg {
height: var(--ams-icon-size-6-font-size);
width: var(--ams-icon-size-6-font-size);
block-size: var(--ams-icon-size-6-font-size);
inline-size: var(--ams-icon-size-6-font-size);
}
6 changes: 3 additions & 3 deletions packages/css/src/components/image/image.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
*/

.ams-image {
block-size: auto; /* [1] */
font-style: italic; /* [3] */
height: auto; /* [1] */
max-width: 100%; /* [1] */
max-inline-size: 100%; /* [1] */
vertical-align: middle; /* [2] */

&--cover {
object-fit: cover;
}
}

// [1] Allow for fluid image sizing while maintaining aspect ratio governed by width/height attributes
// [1] Allow for fluid image sizing while maintaining aspect ratio governed by inline/block size attributes
// [2] Remove ‘phantom’ white space
// [3] Italicise alt text to visually offset it from surrounding copy
// Source: https://x.com/csswizardry/status/1717841334462005661
2 changes: 1 addition & 1 deletion packages/css/src/components/logo/logo.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
*/

.ams-logo {
block-size: var(--ams-logo-block-size);
Copy link
Contributor

Choose a reason for hiding this comment

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

Robbert mentioned that width and height may still be the better options for a logo, as we don’t want to rotate it in top-to-bottom writing modes. Another example is the video player.

On the other hand, “the left-to-right direction has become dominant in all three languages for horizontal writing due to the influence of Western languages and the increased use of computerized typesetting and word-processing software” (adapted from Wikipedia).

So we can probably get away with only supporting horizontal writing modes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm completely fine with making some exceptions for elements where that makes sense. It's probably something we should test on a complete page though. Maybe revisit it later, top-to-bottom writing modes aren't a huge priority at the moment I think?

display: block;
height: var(--ams-logo-height);
}

.ams-logo__emblem {
Expand Down
4 changes: 2 additions & 2 deletions packages/css/src/components/pagination/pagination.scss
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@

// Override for icon size
span.ams-icon svg {
height: 1rem;
width: 1rem;
block-size: 1rem;
inline-size: 1rem;
}

@include text-rendering;
Expand Down
8 changes: 4 additions & 4 deletions packages/css/src/components/radio/radio.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,23 @@

.ams-radio__circle {
align-items: center;
block-size: calc(var(--ams-radio-font-size) * var(--ams-radio-line-height));
display: flex;
flex-shrink: 0;
height: calc(var(--ams-radio-font-size) * var(--ams-radio-line-height));
width: 1.5rem;
inline-size: 1.5rem;

&::after {
background-position: center;
background-repeat: no-repeat;
background-size: 1rem;
block-size: 1.5rem;
border-color: var(--ams-radio-circle-border-color);
border-radius: 100%;
border-style: solid;
border-width: var(--ams-radio-circle-border-width);
box-sizing: border-box;
content: "";
height: 1.5rem;
width: 100%;
inline-size: 100%;
}
}

Expand Down
6 changes: 3 additions & 3 deletions packages/css/src/components/screen/screen.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
}

.ams-screen--full-height {
min-height: 100vh;
min-block-size: 100vh;
}

.ams-screen--wide {
max-width: var(--ams-screen-wide-max-width);
max-inline-size: var(--ams-screen-wide-max-inline-size);
}

.ams-screen--x-wide {
max-width: var(--ams-screen-x-wide-max-width);
max-inline-size: var(--ams-screen-x-wide-max-inline-size);
}
10 changes: 5 additions & 5 deletions packages/css/src/components/switch/switch.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,28 @@
--ams-switch-track-padding: 0.0625rem;

background-color: var(--ams-switch-background-color);
border-radius: calc(var(--ams-switch-thumb-width) * 2);
border-radius: calc(var(--ams-switch-thumb-inline-size) * 2);
cursor: pointer;
display: inline-block;
inline-size: var(--ams-switch-inline-size);
outline-offset: var(--ams-switch-outline-offset);
padding-block: var(--ams-switch-track-padding);
padding-inline: var(--ams-switch-track-padding);
transition: background-color 0.2s ease-in-out;
width: var(--ams-switch-width);

@include reset;
}

.ams-switch__label::before {
background-color: var(--ams-switch-thumb-background-color);
block-size: var(--ams-switch-thumb-block-size);
border-radius: 50%;
content: "";
display: block;
height: var(--ams-switch-thumb-height);
inline-size: var(--ams-switch-thumb-inline-size);
transition-duration: 0.1s;
transition-property: box-shadow, transform;
transition-timing-function: ease-in-out;
width: var(--ams-switch-thumb-width);
}

.ams-switch__input:checked + .ams-switch__label {
Expand All @@ -54,7 +54,7 @@

.ams-switch__input:checked + .ams-switch__label::before {
transform: translate(
calc(var(--ams-switch-width) - var(--ams-switch-thumb-width) - 2 * var(--ams-switch-track-padding))
calc(var(--ams-switch-inline-size) - var(--ams-switch-thumb-inline-size) - 2 * var(--ams-switch-track-padding))
);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/css/src/components/table/table.scss
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

.ams-table__cell,
.ams-table__header-cell {
border-bottom: var(--ams-table-cell-border-bottom);
border-block-end: var(--ams-table-cell-border-block-end);
padding-block: var(--ams-table-cell-padding-block);
padding-inline: var(--ams-table-cell-padding-inline);
text-align: start;
Expand Down
2 changes: 1 addition & 1 deletion packages/css/src/components/tabs/tabs.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

.ams-tabs__list {
background-color: var(--ams-tabs-list-background-color);
border-bottom: var(--ams-tabs-list-border-bottom);
border-block-end: var(--ams-tabs-list-border-block-end);
display: flex;
overflow-x: auto;
}
Expand Down
Loading
Loading