Skip to content

Commit d50515b

Browse files
committed
feat(stylelint-rules): introduce component and theme layer restrictions
- Add `require-component-layer` rule to enforce @layer usage in component styles. - Implement `allowed-layer-names` rule to restrict layer names in components. - Create tests for component layer restrictions. - Add `require-global-layer` rule to ensure global styles are within @layer kol-theme-global. - Implement `allowed-layer-names` rule for themes to restrict layer names. - Create tests for theme layer restrictions. - Consolidate rules in index files for components and themes. - Remove deprecated `css-must-be-in-layer` rule and related tests. - Update pnpm workspace to include stylelint-rules package.
1 parent cdc50c6 commit d50515b

File tree

159 files changed

+510
-634
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

159 files changed

+510
-634
lines changed
Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
src/assets/*.css
2-
src/assets/@leanup
3-
src/assets/codicons
4-
src/components.d.ts
5-
*.bak
6-
*.sass
1+
/assets/**
2+
/node_modules/**
3+
/src/components.d.ts

packages/components/src/components/@shared/_collapsible.mixin.scss

Lines changed: 49 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -2,68 +2,66 @@
22

33
/* For animation technique see https://css-tricks.com/css-grid-can-do-auto-height-transitions/ */
44

5-
@layer kol-component {
6-
.collapsible {
7-
@media (prefers-reduced-motion) {
8-
&__wrapper-animation,
9-
&__wrapper {
10-
transition: none !important;
11-
}
5+
.collapsible {
6+
@media (prefers-reduced-motion) {
7+
&__wrapper-animation,
8+
&__wrapper {
9+
transition: none !important;
1210
}
11+
}
1312

14-
/* @see https://github.com/public-ui/kolibri/issues/5952 */
15-
@media print {
16-
:not(.collapsible--open) &__wrapper-animation {
17-
display: none;
18-
}
19-
}
20-
&__wrapper {
21-
/* Forces the element into its own GPU compositing layer (via 3D transform). Helps prevent rendering/layout bugs (e.g. #7511) and may improve animation performance. */
22-
transform: translateZ(0);
23-
display: grid;
24-
grid-template-rows: 0fr;
25-
transition: grid-template-rows 0.3s;
13+
/* @see https://github.com/public-ui/kolibri/issues/5952 */
14+
@media print {
15+
:not(.collapsible--open) &__wrapper-animation {
16+
display: none;
2617
}
18+
}
19+
&__wrapper {
20+
/* Forces the element into its own GPU compositing layer (via 3D transform). Helps prevent rendering/layout bugs (e.g. #7511) and may improve animation performance. */
21+
transform: translateZ(0);
22+
display: grid;
23+
grid-template-rows: 0fr;
24+
transition: grid-template-rows 0.3s;
25+
}
2726

28-
&__wrapper-animation {
29-
opacity: 0;
30-
transform: scaleY(0);
31-
transform-origin: top;
32-
min-height: 0;
27+
&__wrapper-animation {
28+
opacity: 0;
29+
transform: scaleY(0);
30+
transform-origin: top;
31+
min-height: 0;
3332

34-
/* This property is important to keep in sync with the visual transition (template-rows). Without it interactive elements within the accordion would stay focusable. */
35-
visibility: hidden;
33+
/* This property is important to keep in sync with the visual transition (template-rows). Without it interactive elements within the accordion would stay focusable. */
34+
visibility: hidden;
3635

37-
transition:
38-
transform 0.3s,
39-
opacity 0.3s,
40-
visibility 0.3s;
41-
}
36+
transition:
37+
transform 0.3s,
38+
opacity 0.3s,
39+
visibility 0.3s;
40+
}
4241

43-
&--open &__wrapper {
44-
grid-template-rows: 1fr;
45-
}
42+
&--open &__wrapper {
43+
grid-template-rows: 1fr;
44+
}
4645

47-
&--open &__wrapper-animation {
48-
opacity: 1;
49-
transform: scaleY(1);
46+
&--open &__wrapper-animation {
47+
opacity: 1;
48+
transform: scaleY(1);
5049

51-
visibility: visible;
52-
}
50+
visibility: visible;
51+
}
5352

54-
/*
55-
* Inside a button, the caption text is always centered.
56-
* So we have to align the text to the left.
57-
*/
58-
&__heading-button button {
59-
.kol-span {
60-
align-items: flex-start;
61-
}
53+
/*
54+
* Inside a button, the caption text is always centered.
55+
* So we have to align the text to the left.
56+
*/
57+
&__heading-button button {
58+
.kol-span {
59+
align-items: flex-start;
6260
}
6361
}
62+
}
6463

65-
.collapsible--open:focus-within {
66-
position: relative;
67-
z-index: 100;
68-
}
64+
.collapsible--open:focus-within {
65+
position: relative;
66+
z-index: 100;
6967
}

packages/components/src/components/@shared/_field-control.mixin.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
@mixin kol-field-control {
22
.kol-field-control {
3-
$base: &;
43
display: grid;
54

65
min-height: var(--a11y-min-size);

packages/components/src/components/@shared/_form-field.mixin.scss

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,31 @@
22

33
@mixin kol-form-field {
44
.kol-form-field {
5-
$root: &;
6-
75
display: grid;
86

97
&__label {
10-
#{$root}:not(#{$root}--disabled) & {
8+
.kol-form-field:not(.kol-form-field--disabled) & {
119
cursor: pointer;
1210
}
1311

1412
&-text {
1513
display: ruby;
1614
}
1715

18-
#{$root}--disabled & {
16+
.kol-form-field--disabled & {
1917
opacity: 0.5;
2018
}
2119
}
2220

2321
&--required {
24-
#{$root}__label-text:not(:has(> [name]))::after,
25-
#{$root}__tooltip .span-label::after {
22+
.kol-form-field__label-text:not(:has(> [name]))::after,
23+
.kol-form-field__tooltip .span-label::after {
2624
content: '*' / '';
2725
}
2826
}
2927

3028
&__hint {
31-
#{$root}--disabled & {
29+
.kol-form-field--disabled & {
3230
opacity: 0.5;
3331
}
3432
}

packages/components/src/components/@shared/_global.scss

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,8 @@
4040
}
4141

4242
.kol-span {
43-
$spanRoot: &;
44-
4543
&__label {
46-
@at-root #{$spanRoot} &--hide-label & {
44+
.kol-span--hide-label & {
4745
display: none;
4846
}
4947
}

packages/components/src/components/@shared/_input-container.mixin.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
@mixin kol-input-container {
22
.kol-input-container {
3-
$root: &;
43
background-color: transparent;
54
display: grid;
65
width: 100%;

packages/components/src/components/@shared/_link.mixin.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
}
1111

1212
.#{$block-classname} {
13-
$root: &;
1413
display: inline-flex;
1514
max-width: fit-content;
1615

packages/components/src/components/@shared/_table-stateless.mixin.scss

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,14 @@
1111
@include kol-icon-styles();
1212

1313
.kol-table {
14-
$root: &;
15-
1614
--kol-table-selection-col-width: var(--a11y-min-size);
1715

1816
display: block;
1917
position: relative;
2018
max-width: 100%;
2119

2220
&__scroll-container {
23-
@at-root #{$root}:has(#{$root}__focus-element:focus) & {
21+
.kol-table:has(.kol-table__focus-element:focus) & {
2422
/* @see https://remysharp.com/til/css/focus-ring-default-styles */
2523
outline: 5px auto Highlight;
2624
outline: 5px auto -webkit-focus-ring-color;

packages/components/src/components/dialog/style.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
@use '../@shared/mixins' as *;
44
@use '../tooltip/style.scss' as *;
55

6-
@include kol-card;
7-
86
@layer kol-component {
7+
@include kol-card;
8+
99
.kol-dialog,
1010
.kol-modal {
1111
min-height: var(--a11y-min-size);

packages/components/src/components/drawer/style.scss

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
@include kol-card;
88

99
.kol-drawer {
10-
$root: &;
11-
1210
&__dialog {
1311
padding: 0;
1412
border: none;
@@ -24,7 +22,7 @@
2422
max-width: 100vw;
2523
height: 100vh;
2624

27-
#{$root}__content {
25+
.kol-drawer__content {
2826
height: 100%;
2927
}
3028
}
@@ -43,7 +41,7 @@
4341
width: 100vw;
4442
max-height: 100vh;
4543

46-
#{$root}__content {
44+
.kol-drawer__content {
4745
width: 100%;
4846
}
4947
}

0 commit comments

Comments
 (0)