@nordcode/ui 1.0.4 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -10,3 +10,15 @@
10
10
 
11
11
  - Fixed Webkit `<detail>` style
12
12
  - Shadows not working using `light-dark`
13
+
14
+ ## v1.0.5 (2024-11-28)
15
+
16
+ ### Fixes
17
+
18
+ Make fieldset-based inputs more accessible by adding legends. This affects:
19
+ - `nc-tag-select`
20
+ - `nc-segmented-control`
21
+ - `nc-radio-field`
22
+ - `nc-checkbox-field`
23
+
24
+ Be sure to checkout the updated markup for these components in the documentation.
package/out/complete.css CHANGED
@@ -1875,24 +1875,18 @@
1875
1875
  }
1876
1876
 
1877
1877
  :where(legend:not([class]), .nc-legend) {
1878
- font-family: var(--font-family-default);
1879
- letter-spacing: var(--tracking-tight);
1880
- font-weight: var(--font-weight-active);
1881
- color: var(--text, var(--color-text-base));
1882
- font-size: var(--font-size-base);
1883
1878
  border: none;
1884
1879
  border-radius: 0;
1885
1880
  inline-size: 100%;
1886
- margin-block-end: .75lh;
1887
1881
  padding: 0;
1888
- display: block;
1889
1882
  }
1890
1883
 
1891
- :where(:is(fieldset:not([class]), .nc-fieldset):has(:is(.nc-legend + .nc-hint, legend:not([class]) + .nc-hint)) > :is(legend:not([class]), .nc-legend)) {
1892
- margin-block-end: 0;
1884
+ :where(legend:not([class]), .nc-legend) + * {
1885
+ margin-block-start: var(--nc-legend-spacing, .75lh);
1893
1886
  }
1894
1887
 
1895
1888
  :where(:is(fieldset:not([class]), .nc-fieldset):has(:is(.nc-legend + .nc-hint, legend:not([class]) + .nc-hint)) > :is(legend:not([class]), .nc-legend)) + .nc-hint {
1889
+ --nc-legend-spacing: 0;
1896
1890
  margin-block-end: .6lh;
1897
1891
  }
1898
1892
  }
@@ -2210,6 +2204,7 @@
2210
2204
  --_tag-select-checked-text-color: var(--tag-select-checked-text-color, var(--color-brand-primary-contrast));
2211
2205
  --_tag-select-checked-surface-color: var(--tag-select-checked-surface-color, var(--color-brand-primary-base));
2212
2206
  --_tag-select-border-radius: var(--tag-select-border-radius, var(--_input-border-radius));
2207
+ --nc-legend-spacing: .25lh;
2213
2208
  }
2214
2209
 
2215
2210
  :where(.nc-tag-select-field):focus-within:has(:focus-visible) {
@@ -2310,43 +2305,45 @@
2310
2305
  background: var(--_input-hover-background);
2311
2306
  }
2312
2307
 
2313
- :where(.nc-radio-field, .nc-checkbox-field) fieldset, :where(.nc-radio-field, .nc-checkbox-field) fieldset > :not(:first-child) {
2308
+ :where(.nc-radio-field, .nc-checkbox-field) {
2309
+ gap: 0;
2310
+ }
2311
+
2312
+ :where(.nc-radio-field, .nc-checkbox-field) > :not(:first-child) {
2314
2313
  margin-block-start: .6lh;
2315
2314
  }
2316
2315
  }
2317
2316
 
2318
2317
  @layer components.inputs-segmented {
2319
2318
  :where(.nc-segmented-control-group) {
2319
+ --_segmented-control-border-radius: var(--segmented-control-border-radius, var(--_input-border-radius));
2320
+ --_segmented-control-checked-text-color: var(--segmented-control-checked-text-color, var(--color-brand-primary-contrast));
2321
+ --_segmented-control-checked-surface-color: var(--segmented-control-checked-surface-color, var(--color-brand-primary-base));
2322
+ --nc-legend-spacing: .25lh;
2320
2323
  container: segmented-control / inline-size;
2321
2324
  }
2322
2325
 
2323
2326
  :where(.nc-segmented-control) {
2324
- --_segmented-control-border-radius: var(--segmented-control-border-radius, var(--_input-border-radius));
2325
- --_segmented-control-checked-text-color: var(--segmented-control-checked-text-color, var(--color-brand-primary-contrast));
2326
- --_segmented-control-checked-surface-color: var(--segmented-control-checked-surface-color, var(--color-brand-primary-base));
2327
+ background: var(--_input-background);
2328
+ block-size: auto;
2329
+ inline-size: 100%;
2327
2330
  box-shadow: var(--_input-box-shadow);
2328
2331
  border-radius: var(--_segmented-control-border-radius);
2329
- background: var(--_input-background);
2330
- border: none;
2331
2332
  grid-auto-rows: 1fr;
2332
2333
  grid-auto-flow: row;
2333
- block-size: auto;
2334
- inline-size: 100%;
2335
- margin: 0;
2336
- padding: 0;
2337
2334
  display: grid;
2338
2335
  }
2339
2336
 
2340
- :where(.nc-segmented-control) input {
2341
- opacity: 0;
2342
- position: absolute;
2343
- }
2344
-
2345
2337
  :where(.nc-segmented-control):focus-within {
2346
2338
  outline: var(--_input-outline);
2347
2339
  outline-offset: 0;
2348
2340
  }
2349
2341
 
2342
+ :where(.nc-segmented-control) input {
2343
+ opacity: 0;
2344
+ position: absolute;
2345
+ }
2346
+
2350
2347
  :where(.nc-segmented-control) label {
2351
2348
  padding-inline: var(--_input-padding-inline);
2352
2349
  padding-block: var(--_input-padding-block);
@@ -1625,24 +1625,18 @@
1625
1625
  }
1626
1626
 
1627
1627
  :where(legend:not([class]), .nc-legend) {
1628
- font-family: var(--font-family-default);
1629
- letter-spacing: var(--tracking-tight);
1630
- font-weight: var(--font-weight-active);
1631
- color: var(--text, var(--color-text-base));
1632
- font-size: var(--font-size-base);
1633
1628
  border: none;
1634
1629
  border-radius: 0;
1635
1630
  inline-size: 100%;
1636
- margin-block-end: .75lh;
1637
1631
  padding: 0;
1638
- display: block;
1639
1632
  }
1640
1633
 
1641
- :where(:is(fieldset:not([class]), .nc-fieldset):has(:is(.nc-legend + .nc-hint, legend:not([class]) + .nc-hint)) > :is(legend:not([class]), .nc-legend)) {
1642
- margin-block-end: 0;
1634
+ :where(legend:not([class]), .nc-legend) + * {
1635
+ margin-block-start: var(--nc-legend-spacing, .75lh);
1643
1636
  }
1644
1637
 
1645
1638
  :where(:is(fieldset:not([class]), .nc-fieldset):has(:is(.nc-legend + .nc-hint, legend:not([class]) + .nc-hint)) > :is(legend:not([class]), .nc-legend)) + .nc-hint {
1639
+ --nc-legend-spacing: 0;
1646
1640
  margin-block-end: .6lh;
1647
1641
  }
1648
1642
  }
@@ -1960,6 +1954,7 @@
1960
1954
  --_tag-select-checked-text-color: var(--tag-select-checked-text-color, var(--color-brand-primary-contrast));
1961
1955
  --_tag-select-checked-surface-color: var(--tag-select-checked-surface-color, var(--color-brand-primary-base));
1962
1956
  --_tag-select-border-radius: var(--tag-select-border-radius, var(--_input-border-radius));
1957
+ --nc-legend-spacing: .25lh;
1963
1958
  }
1964
1959
 
1965
1960
  :where(.nc-tag-select-field):focus-within:has(:focus-visible) {
@@ -2060,43 +2055,45 @@
2060
2055
  background: var(--_input-hover-background);
2061
2056
  }
2062
2057
 
2063
- :where(.nc-radio-field, .nc-checkbox-field) fieldset, :where(.nc-radio-field, .nc-checkbox-field) fieldset > :not(:first-child) {
2058
+ :where(.nc-radio-field, .nc-checkbox-field) {
2059
+ gap: 0;
2060
+ }
2061
+
2062
+ :where(.nc-radio-field, .nc-checkbox-field) > :not(:first-child) {
2064
2063
  margin-block-start: .6lh;
2065
2064
  }
2066
2065
  }
2067
2066
 
2068
2067
  @layer components.inputs-segmented {
2069
2068
  :where(.nc-segmented-control-group) {
2069
+ --_segmented-control-border-radius: var(--segmented-control-border-radius, var(--_input-border-radius));
2070
+ --_segmented-control-checked-text-color: var(--segmented-control-checked-text-color, var(--color-brand-primary-contrast));
2071
+ --_segmented-control-checked-surface-color: var(--segmented-control-checked-surface-color, var(--color-brand-primary-base));
2072
+ --nc-legend-spacing: .25lh;
2070
2073
  container: segmented-control / inline-size;
2071
2074
  }
2072
2075
 
2073
2076
  :where(.nc-segmented-control) {
2074
- --_segmented-control-border-radius: var(--segmented-control-border-radius, var(--_input-border-radius));
2075
- --_segmented-control-checked-text-color: var(--segmented-control-checked-text-color, var(--color-brand-primary-contrast));
2076
- --_segmented-control-checked-surface-color: var(--segmented-control-checked-surface-color, var(--color-brand-primary-base));
2077
+ background: var(--_input-background);
2078
+ block-size: auto;
2079
+ inline-size: 100%;
2077
2080
  box-shadow: var(--_input-box-shadow);
2078
2081
  border-radius: var(--_segmented-control-border-radius);
2079
- background: var(--_input-background);
2080
- border: none;
2081
2082
  grid-auto-rows: 1fr;
2082
2083
  grid-auto-flow: row;
2083
- block-size: auto;
2084
- inline-size: 100%;
2085
- margin: 0;
2086
- padding: 0;
2087
2084
  display: grid;
2088
2085
  }
2089
2086
 
2090
- :where(.nc-segmented-control) input {
2091
- opacity: 0;
2092
- position: absolute;
2093
- }
2094
-
2095
2087
  :where(.nc-segmented-control):focus-within {
2096
2088
  outline: var(--_input-outline);
2097
2089
  outline-offset: 0;
2098
2090
  }
2099
2091
 
2092
+ :where(.nc-segmented-control) input {
2093
+ opacity: 0;
2094
+ position: absolute;
2095
+ }
2096
+
2100
2097
  :where(.nc-segmented-control) label {
2101
2098
  padding-inline: var(--_input-padding-inline);
2102
2099
  padding-block: var(--_input-padding-block);
package/package.json CHANGED
@@ -12,7 +12,7 @@
12
12
  "type": "git",
13
13
  "url": "https://github.com/nordcode-agency/nordcode/tree/main/packages/ui"
14
14
  },
15
- "version": "1.0.4",
15
+ "version": "1.0.5",
16
16
  "publishConfig": {
17
17
  "access": "public"
18
18
  },
@@ -24,23 +24,19 @@
24
24
  }
25
25
 
26
26
  :where(legend:not([class]), .nc-legend) {
27
- font-family: var(--font-family-default);
28
- letter-spacing: var(--tracking-tight);
29
- font-weight: var(--font-weight-active);
30
- color: var(--text, var(--color-text-base));
31
- display: block;
32
- font-size: var(--font-size-base);
33
27
  padding: 0;
34
28
  border: none;
35
29
  border-radius: 0;
36
30
  inline-size: 100%;
37
- margin-block-end: 0.75lh;
31
+
32
+ &+* {
33
+ margin-block-start: var(--nc-legend-spacing, 0.75lh);
34
+ }
38
35
  }
39
36
 
40
37
  :where( :is(fieldset:not([class]), .nc-fieldset):has( :is(.nc-legend + .nc-hint, legend:not([class]) + .nc-hint)) > :is(legend:not([class]), .nc-legend)) {
41
- margin-block-end: 0;
42
-
43
38
  &+.nc-hint {
39
+ --nc-legend-spacing: 0;
44
40
  margin-block-end: 0.6lh;
45
41
  }
46
42
  }
@@ -8,13 +8,13 @@
8
8
  max-inline-size: var(--input-field-max-inline-size);
9
9
  place-items: start;
10
10
 
11
- & > label,
12
- & > .nc-stack {
11
+ &>label,
12
+ &>.nc-stack {
13
13
  gap: 0.125lh;
14
14
  line-height: var(--line-height-small);
15
15
  }
16
16
 
17
- & > .nc-cluster {
17
+ &>.nc-cluster {
18
18
  gap: 1ch;
19
19
  }
20
20
  }
@@ -49,7 +49,7 @@
49
49
  place-items: start;
50
50
  gap: 0;
51
51
 
52
- & > [data-label] {
52
+ &>[data-label] {
53
53
  grid-area: label;
54
54
  padding-inline-start: 1ch;
55
55
  }
@@ -58,7 +58,7 @@
58
58
  min-block-size: var(--line-height-base);
59
59
  }
60
60
 
61
- & > [data-input] {
61
+ &>[data-input] {
62
62
  grid-area: checkbox;
63
63
  }
64
64
 
@@ -68,12 +68,9 @@
68
68
  }
69
69
 
70
70
  :where(.nc-radio-field, .nc-checkbox-field) {
71
- & fieldset {
72
- margin-block-start: 0.6lh;
73
- }
71
+ gap: 0;
74
72
 
75
- & fieldset > *:not(:first-child) {
73
+ >*:not(:first-child) {
76
74
  margin-block-start: 0.6lh;
77
75
  }
78
76
  }
79
- }
@@ -1,43 +1,38 @@
1
1
  @layer components.inputs-segmented {
2
2
  :where(.nc-segmented-control-group) {
3
+ --_segmented-control-border-radius: var(--segmented-control-border-radius,
4
+ var(--_input-border-radius));
5
+ --_segmented-control-checked-text-color: var(--segmented-control-checked-text-color,
6
+ var(--color-brand-primary-contrast));
7
+ --_segmented-control-checked-surface-color: var(--segmented-control-checked-surface-color,
8
+ var(--color-brand-primary-base));
9
+
3
10
  container: segmented-control / inline-size;
11
+
12
+ --nc-legend-spacing: 0.25lh;
4
13
  }
5
14
 
6
15
  :where(.nc-segmented-control) {
7
- --_segmented-control-border-radius: var(
8
- --segmented-control-border-radius,
9
- var(--_input-border-radius)
10
- );
11
- --_segmented-control-checked-text-color: var(
12
- --segmented-control-checked-text-color,
13
- var(--color-brand-primary-contrast)
14
- );
15
- --_segmented-control-checked-surface-color: var(
16
- --segmented-control-checked-surface-color,
17
- var(--color-brand-primary-base)
18
- );
19
16
  display: grid;
20
17
  grid-auto-rows: 1fr;
21
18
  grid-auto-flow: row;
22
- padding: 0;
23
- margin: 0;
24
- border: none;
25
- box-shadow: var(--_input-box-shadow);
26
- border-radius: var(--_segmented-control-border-radius);
27
- background: var(--_input-background);
19
+
28
20
  block-size: auto;
29
21
  inline-size: 100%;
30
-
31
- & input {
32
- opacity: 0;
33
- position: absolute;
34
- }
22
+ background: var(--_input-background);
23
+ box-shadow: var(--_input-box-shadow);
24
+ border-radius: var(--_segmented-control-border-radius);
35
25
 
36
26
  &:focus-within {
37
27
  outline: var(--_input-outline);
38
28
  outline-offset: 0;
39
29
  }
40
30
 
31
+ & input {
32
+ opacity: 0;
33
+ position: absolute;
34
+ }
35
+
41
36
  & label {
42
37
  display: flex;
43
38
  padding-inline: var(--_input-padding-inline);
@@ -48,7 +43,7 @@
48
43
  align-items: center;
49
44
  justify-content: center;
50
45
 
51
- > .nc-input-label {
46
+ >.nc-input-label {
52
47
  color: inherit;
53
48
  }
54
49
 
@@ -58,13 +53,11 @@
58
53
  }
59
54
 
60
55
  &:first-child {
61
- border-radius: var(--_segmented-control-border-radius)
62
- var(--_segmented-control-border-radius) 0 0;
56
+ border-radius: var(--_segmented-control-border-radius) var(--_segmented-control-border-radius) 0 0;
63
57
  }
64
58
 
65
59
  &:last-child {
66
- border-radius: 0 0 var(--_segmented-control-border-radius)
67
- var(--_segmented-control-border-radius);
60
+ border-radius: 0 0 var(--_segmented-control-border-radius) var(--_segmented-control-border-radius);
68
61
  }
69
62
 
70
63
  &:not(:last-child) {
@@ -97,15 +90,13 @@
97
90
  grid-auto-columns: 1fr;
98
91
  grid-auto-flow: column;
99
92
 
100
- > label {
93
+ >label {
101
94
  &:first-child {
102
- border-radius: var(--_segmented-control-border-radius) 0 0
103
- var(--_segmented-control-border-radius);
95
+ border-radius: var(--_segmented-control-border-radius) 0 0 var(--_segmented-control-border-radius);
104
96
  }
105
97
 
106
98
  &:last-child {
107
- border-radius: 0 var(--_segmented-control-border-radius)
108
- var(--_segmented-control-border-radius) 0;
99
+ border-radius: 0 var(--_segmented-control-border-radius) var(--_segmented-control-border-radius) 0;
109
100
  }
110
101
 
111
102
  &:not(:last-child) {
@@ -1,14 +1,11 @@
1
1
  @layer components.inputs {
2
2
  :where(.nc-tag-select-field) {
3
- --_tag-select-checked-text-color: var(
4
- --tag-select-checked-text-color,
5
- var(--color-brand-primary-contrast)
6
- );
7
- --_tag-select-checked-surface-color: var(
8
- --tag-select-checked-surface-color,
9
- var(--color-brand-primary-base)
10
- );
3
+ --_tag-select-checked-text-color: var(--tag-select-checked-text-color,
4
+ var(--color-brand-primary-contrast));
5
+ --_tag-select-checked-surface-color: var(--tag-select-checked-surface-color,
6
+ var(--color-brand-primary-base));
11
7
  --_tag-select-border-radius: var(--tag-select-border-radius, var(--_input-border-radius));
8
+ --nc-legend-spacing: 0.25lh;
12
9
 
13
10
  &:focus-within:has(:focus-visible) {
14
11
  outline-offset: 1ch;