@utrecht/form-fieldset-css 1.0.0 → 1.2.0

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 ADDED
@@ -0,0 +1,19 @@
1
+ # @utrecht/form-fieldset-css
2
+
3
+ ## 1.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - dae106c: Added metadata for form-fieldset tokens.
8
+
9
+ ## 1.1.0
10
+
11
+ ### Minor Changes
12
+
13
+ - 62f1157: Add SCSS files to `src/` directory of CSS component packages.
14
+
15
+ ## 1.0.0
16
+
17
+ ### Major Changes
18
+
19
+ - 856d996: Switch from alpha releases to semantic versioning.
package/dist/index.css ADDED
@@ -0,0 +1,74 @@
1
+ /**
2
+ * @license EUPL-1.2
3
+ * Copyright (c) 2021 Robbert Broersma
4
+ */
5
+ /**
6
+ * @license EUPL-1.2
7
+ * Copyright (c) 2021 Robbert Broersma
8
+ */
9
+ /**
10
+ * @license EUPL-1.2
11
+ * Copyright (c) 2021 Robbert Broersma
12
+ */
13
+ /* stylelint-disable-next-line block-no-empty */
14
+ .utrecht-form-fieldset {
15
+ margin-block-end: calc(var(--utrecht-space-around, 0) * var(--utrecht-form-fieldset-margin-block-end, 0));
16
+ margin-block-start: calc(var(--utrecht-space-around, 0) * var(--utrecht-form-fieldset-margin-block-start, 0));
17
+ }
18
+
19
+ .utrecht-form-fieldset--html-fieldset,
20
+ .utrecht-form-fieldset__fieldset--html-fieldset {
21
+ /* `all: revert` unfortunately has as side-effect that the `hidde` attribute has no effect */
22
+ all: revert;
23
+ border: 0;
24
+ margin-inline-end: 0;
25
+ margin-inline-start: 0;
26
+ min-inline-size: 0;
27
+ padding-block-end: 0;
28
+ padding-block-start: 0.01em;
29
+ padding-inline-end: 0;
30
+ padding-inline-start: 0;
31
+ }
32
+
33
+ .utrecht-form-fieldset__legend--html-legend {
34
+ display: table;
35
+ inline-size: 100%;
36
+ padding-inline-end: 0;
37
+ padding-inline-start: 0;
38
+ }
39
+
40
+ .utrecht-form-fieldset--distanced {
41
+ --utrecht-space-around: 1;
42
+ }
43
+
44
+ .utrecht-form-fieldset--section {
45
+ background-color: var(--utrecht-form-fieldset-section-background-color);
46
+ color: var(--utrecht-form-fieldset-section-color);
47
+ }
48
+
49
+ .utrecht-form-fieldset__legend {
50
+ break-inside: avoid;
51
+ color: var(--utrecht-form-fieldset-legend-color, var(--utrecht-document-color, inherit));
52
+ font-family: var(--utrecht-form-fieldset-legend-font-family, var(--utrecht-document-font-family));
53
+ font-size: var(--utrecht-form-fieldset-legend-font-size);
54
+ font-weight: var(--utrecht-form-fieldset-legend-font-weight);
55
+ line-height: var(--utrecht-form-fieldset-legend-line-height);
56
+ page-break-after: avoid;
57
+ page-break-inside: avoid;
58
+ }
59
+
60
+ .utrecht-form-fieldset__legend--disabled {
61
+ color: var(--utrecht-form-fieldset-legend-disabled-color, var(--utrecht-form-fieldset-legend-color, var(--utrecht-document-color, inherit)));
62
+ }
63
+
64
+ .utrecht-form-fieldset__legend--distanced {
65
+ margin-block-end: calc(var(--utrecht-space-around, 0) * var(--utrecht-form-fieldset-legend-margin-block-end, 0));
66
+ margin-block-start: calc(var(--utrecht-space-around, 0) * var(--utrecht-form-fieldset-legend-margin-block-start, 0));
67
+ }
68
+
69
+ .utrecht-form-fieldset--invalid {
70
+ border-inline-start-color: var(--utrecht-form-fieldset-invalid-border-inline-start-color, var(--utrecht-form-field-invalid-border-inline-start-color));
71
+ border-inline-start-style: solid;
72
+ border-inline-start-width: var(--utrecht-form-fieldset-invalid-border-inline-start-width, var(--utrecht-form-field-invalid-border-inline-start-width));
73
+ padding-inline-start: var(--utrecht-form-fieldset-invalid-padding-inline-start, var(--utrecht-form-field-invalid-padding-inline-start));
74
+ }
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ var undefined$1 = undefined;export{undefined$1 as default};
package/package.json CHANGED
@@ -1,18 +1,32 @@
1
1
  {
2
- "version": "1.0.0",
2
+ "version": "1.2.0",
3
3
  "author": "Community for NL Design System",
4
4
  "description": "Form fieldset component for the Municipality of Utrecht based on the NL Design System architecture",
5
5
  "license": "EUPL-1.2",
6
6
  "name": "@utrecht/form-fieldset-css",
7
7
  "files": [
8
- "dist/"
8
+ "dist/",
9
+ "docs/",
10
+ "src/",
11
+ "*.md"
9
12
  ],
10
- "devDependencies": {},
13
+ "main": "dist/index.css",
14
+ "devDependencies": {
15
+ "rollup": "4.18.0"
16
+ },
11
17
  "keywords": [
12
18
  "nl-design-system"
13
19
  ],
14
20
  "publishConfig": {
15
21
  "access": "public"
16
22
  },
17
- "scripts": {}
23
+ "repository": {
24
+ "type": "git+ssh",
25
+ "url": "git@github.com:nl-design-system/utrecht.git",
26
+ "directory": "components/form-fieldset"
27
+ },
28
+ "scripts": {
29
+ "build": "rollup -c ../rollup.config.mjs",
30
+ "clean": "rimraf dist"
31
+ }
18
32
  }
@@ -0,0 +1,71 @@
1
+ /**
2
+ * @license EUPL-1.2
3
+ * Copyright (c) 2021 Robbert Broersma
4
+ */
5
+
6
+ @import "./reset";
7
+
8
+ @mixin utrecht-form-fieldset {
9
+ margin-block-end: calc(var(--utrecht-space-around, 0) * var(--utrecht-form-fieldset-margin-block-end, 0));
10
+ margin-block-start: calc(var(--utrecht-space-around, 0) * var(--utrecht-form-fieldset-margin-block-start, 0));
11
+ }
12
+
13
+ @mixin utrecht-form-fieldset--html-fieldset {
14
+ @include reset-fieldset;
15
+ }
16
+
17
+ @mixin utrecht-form-fieldset--distanced {
18
+ --utrecht-space-around: 1;
19
+ }
20
+
21
+ @mixin utrecht-form-fieldset--invalid {
22
+ border-inline-start-color: var(
23
+ --utrecht-form-fieldset-invalid-border-inline-start-color,
24
+ var(--utrecht-form-field-invalid-border-inline-start-color)
25
+ );
26
+ border-inline-start-style: solid;
27
+ border-inline-start-width: var(
28
+ --utrecht-form-fieldset-invalid-border-inline-start-width,
29
+ var(--utrecht-form-field-invalid-border-inline-start-width)
30
+ );
31
+ padding-inline-start: var(
32
+ --utrecht-form-fieldset-invalid-padding-inline-start,
33
+ var(--utrecht-form-field-invalid-padding-inline-start)
34
+ );
35
+ }
36
+
37
+ @mixin utrecht-form-fieldset--section {
38
+ background-color: var(--utrecht-form-fieldset-section-background-color);
39
+ color: var(--utrecht-form-fieldset-section-color);
40
+ }
41
+
42
+ /* stylelint-disable-next-line block-no-empty */
43
+ @mixin utrecht-form-fieldset__fieldset {
44
+ }
45
+
46
+ @mixin utrecht-form-fieldset__legend {
47
+ break-inside: avoid;
48
+ color: var(--utrecht-form-fieldset-legend-color, var(--utrecht-document-color, inherit));
49
+ font-family: var(--utrecht-form-fieldset-legend-font-family, var(--utrecht-document-font-family));
50
+ font-size: var(--utrecht-form-fieldset-legend-font-size);
51
+ font-weight: var(--utrecht-form-fieldset-legend-font-weight);
52
+ line-height: var(--utrecht-form-fieldset-legend-line-height);
53
+ page-break-after: avoid;
54
+ page-break-inside: avoid;
55
+ }
56
+
57
+ @mixin utrecht-form-fieldset__legend--disabled {
58
+ color: var(
59
+ --utrecht-form-fieldset-legend-disabled-color,
60
+ var(--utrecht-form-fieldset-legend-color, var(--utrecht-document-color, inherit))
61
+ );
62
+ }
63
+
64
+ @mixin utrecht-form-fieldset__legend--html-legend {
65
+ @include reset-legend;
66
+ }
67
+
68
+ @mixin utrecht-form-fieldset__legend--distanced {
69
+ margin-block-end: calc(var(--utrecht-space-around, 0) * var(--utrecht-form-fieldset-legend-margin-block-end, 0));
70
+ margin-block-start: calc(var(--utrecht-space-around, 0) * var(--utrecht-form-fieldset-legend-margin-block-start, 0));
71
+ }
@@ -0,0 +1,24 @@
1
+ /**
2
+ * @license EUPL-1.2
3
+ * Copyright (c) 2021 Robbert Broersma
4
+ */
5
+
6
+ @mixin reset-fieldset {
7
+ /* `all: revert` unfortunately has as side-effect that the `hidde` attribute has no effect */
8
+ all: revert;
9
+ border: 0;
10
+ margin-inline-end: 0;
11
+ margin-inline-start: 0;
12
+ min-inline-size: 0;
13
+ padding-block-end: 0;
14
+ padding-block-start: 0.01em;
15
+ padding-inline-end: 0;
16
+ padding-inline-start: 0;
17
+ }
18
+
19
+ @mixin reset-legend {
20
+ display: table;
21
+ inline-size: 100%;
22
+ padding-inline-end: 0;
23
+ padding-inline-start: 0;
24
+ }
@@ -0,0 +1,34 @@
1
+ /**
2
+ * @license EUPL-1.2
3
+ * Copyright (c) 2021 Robbert Broersma
4
+ */
5
+
6
+ @import "../mixin";
7
+
8
+ @mixin utrecht-html-fieldset {
9
+ fieldset {
10
+ @include utrecht-form-fieldset;
11
+ @include utrecht-form-fieldset--html-fieldset;
12
+ @include utrecht-form-fieldset--distanced;
13
+ }
14
+
15
+ fieldset[hidden] {
16
+ display: none;
17
+ }
18
+ }
19
+
20
+ @mixin utrecht-html-legend {
21
+ legend {
22
+ @include utrecht-form-fieldset__legend;
23
+ @include utrecht-form-fieldset__legend--html-legend;
24
+ @include utrecht-form-fieldset__legend--distanced;
25
+ }
26
+
27
+ legend[hidden] {
28
+ display: none;
29
+ }
30
+
31
+ fieldset:disabled > legend {
32
+ @include utrecht-form-fieldset__legend--disabled;
33
+ }
34
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @license EUPL-1.2
3
+ * Copyright (c) 2021 Robbert Broersma
4
+ */
5
+
6
+ @import "./mixin";
7
+
8
+ @include utrecht-html-fieldset;
9
+ @include utrecht-html-legend;
package/src/index.scss ADDED
@@ -0,0 +1,47 @@
1
+ /**
2
+ * @license EUPL-1.2
3
+ * Copyright (c) 2021 Robbert Broersma
4
+ */
5
+
6
+ @import "./mixin";
7
+
8
+ .utrecht-form-fieldset {
9
+ @include utrecht-form-fieldset;
10
+ }
11
+
12
+ .utrecht-form-fieldset__fieldset {
13
+ @include utrecht-form-fieldset__fieldset;
14
+ }
15
+
16
+ .utrecht-form-fieldset--html-fieldset,
17
+ .utrecht-form-fieldset__fieldset--html-fieldset {
18
+ @include utrecht-form-fieldset--html-fieldset;
19
+ }
20
+
21
+ .utrecht-form-fieldset__legend--html-legend {
22
+ @include utrecht-form-fieldset__legend--html-legend;
23
+ }
24
+
25
+ .utrecht-form-fieldset--distanced {
26
+ @include utrecht-form-fieldset--distanced;
27
+ }
28
+
29
+ .utrecht-form-fieldset--section {
30
+ @include utrecht-form-fieldset--section;
31
+ }
32
+
33
+ .utrecht-form-fieldset__legend {
34
+ @include utrecht-form-fieldset__legend;
35
+ }
36
+
37
+ .utrecht-form-fieldset__legend--disabled {
38
+ @include utrecht-form-fieldset__legend--disabled;
39
+ }
40
+
41
+ .utrecht-form-fieldset__legend--distanced {
42
+ @include utrecht-form-fieldset__legend--distanced;
43
+ }
44
+
45
+ .utrecht-form-fieldset--invalid {
46
+ @include utrecht-form-fieldset--invalid;
47
+ }
@@ -0,0 +1,140 @@
1
+ /*
2
+ * @license EUPL-1.2
3
+ * Copyright (c) 2020-2022 Gemeente Utrecht
4
+ * Copyright (c) 2020-2022 Frameless B.V.
5
+ */
6
+
7
+ import clsx from 'clsx';
8
+ import parse from 'html-react-parser';
9
+ import React from 'react';
10
+
11
+ export const argTypes = {
12
+ disabled: {
13
+ description: 'Disabled',
14
+ control: 'boolean',
15
+ },
16
+ div: {
17
+ description: 'Use div elements instead of semantic HTML',
18
+ type: 'boolean',
19
+ },
20
+ innerHTML: {
21
+ description: 'Set the content of the fieldset',
22
+ control: 'text',
23
+ },
24
+ invalid: {
25
+ description: 'Invalid',
26
+ control: 'boolean',
27
+ },
28
+ legend: {
29
+ description: 'Set the content of the legend',
30
+ control: 'text',
31
+ },
32
+ role: {
33
+ control: { type: 'select' },
34
+ options: ['', 'group', 'radiogroup'],
35
+ },
36
+ section: {
37
+ description: 'Section appearance',
38
+ type: 'boolean',
39
+ },
40
+ };
41
+
42
+ export const defaultArgs = {
43
+ div: false,
44
+ disabled: false,
45
+ innerHTML: '',
46
+ invalid: false,
47
+ legend: '',
48
+ role: '',
49
+ section: false,
50
+ };
51
+
52
+ export const exampleArgs = {
53
+ disabled: false,
54
+ id: '4f8af453-db3f-4261-b103-5086dcd01b98',
55
+ innerHTML: '<p>Fieldset body</p>',
56
+ legend: 'Fieldset legend',
57
+ };
58
+
59
+ export const FormFieldsetLegend = ({ children, disabled = false, div = defaultArgs.div, id }) =>
60
+ div ? (
61
+ <div
62
+ className={clsx('utrecht-form-fieldset__legend', {
63
+ 'utrecht-form-fieldset__legend--disabled': disabled,
64
+ })}
65
+ id={id}
66
+ >
67
+ {children}
68
+ </div>
69
+ ) : (
70
+ <legend
71
+ className={clsx('utrecht-form-fieldset__legend', 'utrecht-form-fieldset__legend--html-legend', {
72
+ 'utrecht-form-fieldset__legend--disabled': disabled,
73
+ })}
74
+ >
75
+ {children}
76
+ </legend>
77
+ );
78
+
79
+ export const FormFieldset = ({
80
+ className,
81
+ children,
82
+ disabled = false,
83
+ div = defaultArgs.div,
84
+ id,
85
+ innerHTML = defaultArgs.innerHTML,
86
+ invalid = defaultArgs.invalid,
87
+ legend = defaultArgs.legend,
88
+ role = defaultArgs.role,
89
+ section = defaultArgs.section,
90
+ ...restProps
91
+ }) => {
92
+ const labelId = id && `${id}-legend`;
93
+ const content = (
94
+ <>
95
+ {legend && (
96
+ <FormFieldsetLegend div={div} id={labelId}>
97
+ {legend}
98
+ </FormFieldsetLegend>
99
+ )}
100
+ {children}
101
+ {parse(innerHTML)}
102
+ </>
103
+ );
104
+ return div ? (
105
+ <div
106
+ className={clsx('utrecht-form-fieldset', {
107
+ 'utrecht-form-fieldset--invalid': invalid,
108
+ 'utrecht-form-fieldset--section': section,
109
+ className,
110
+ })}
111
+ aria-disabled={disabled ? 'true' : undefined}
112
+ aria-invalid={invalid ? 'true' : undefined}
113
+ role={role || 'group'}
114
+ aria-labelledby={labelId}
115
+ {...restProps}
116
+ >
117
+ {content}
118
+ </div>
119
+ ) : (
120
+ <div
121
+ className={clsx('utrecht-form-fieldset', {
122
+ 'utrecht-form-fieldset--invalid': invalid,
123
+ 'utrecht-form-fieldset--section': section,
124
+ className,
125
+ })}
126
+ >
127
+ <fieldset
128
+ className={clsx('utrecht-form-fieldset__fieldset', 'utrecht-form-fieldset__fieldset--html-fieldset')}
129
+ aria-invalid={invalid ? 'true' : undefined}
130
+ disabled={disabled}
131
+ role={role || undefined}
132
+ {...restProps}
133
+ >
134
+ {content}
135
+ </fieldset>
136
+ </div>
137
+ );
138
+ };
139
+
140
+ export default FormFieldset;
@@ -0,0 +1,166 @@
1
+ {
2
+ "utrecht": {
3
+ "form-fieldset": {
4
+ "margin-block-end": {
5
+ "$extensions": {
6
+ "nl.nldesignsystem.css.property": {
7
+ "syntax": "<length>",
8
+ "inherits": true
9
+ },
10
+ "nl.nldesignsystem.figma.supports-token": false
11
+ },
12
+ "type": "spacing"
13
+ },
14
+ "margin-block-start": {
15
+ "$extensions": {
16
+ "nl.nldesignsystem.css.property": {
17
+ "syntax": "<length>",
18
+ "inherits": true
19
+ },
20
+ "nl.nldesignsystem.figma.supports-token": false
21
+ },
22
+ "type": "spacing"
23
+ },
24
+ "invalid": {
25
+ "border-inline-start-color": {
26
+ "color": {
27
+ "$extensions": {
28
+ "nl.nldesignsystem.css.property": {
29
+ "syntax": "<color>",
30
+ "inherits": true
31
+ },
32
+ "nl.nldesignsystem.figma.supports-token": false
33
+ },
34
+ "type": "color"
35
+ }
36
+ },
37
+ "border-inline-start-width": {
38
+ "$extensions": {
39
+ "nl.nldesignsystem.css.property": {
40
+ "syntax": "<length>",
41
+ "inherits": true
42
+ },
43
+ "nl.nldesignsystem.figma.supports-token": false
44
+ },
45
+ "type": "borderWidth"
46
+ },
47
+ "padding-inline-start": {
48
+ "$extensions": {
49
+ "nl.nldesignsystem.css.property": {
50
+ "syntax": "<length>",
51
+ "inherits": true
52
+ },
53
+ "nl.nldesignsystem.figma.supports-token": false
54
+ },
55
+ "type": "spacing"
56
+ }
57
+ },
58
+ "section": {
59
+ "background-color": {
60
+ "$extensions": {
61
+ "nl.nldesignsystem.css.property": {
62
+ "syntax": "<color>",
63
+ "inherits": true
64
+ },
65
+ "nl.nldesignsystem.figma.supports-token": false
66
+ },
67
+ "type": "color"
68
+ },
69
+ "color": {
70
+ "$extensions": {
71
+ "nl.nldesignsystem.css.property": {
72
+ "syntax": "<color>",
73
+ "inherits": true
74
+ },
75
+ "nl.nldesignsystem.figma.supports-token": false
76
+ },
77
+ "type": "color"
78
+ }
79
+ },
80
+ "legend": {
81
+ "color": {
82
+ "$extensions": {
83
+ "nl.nldesignsystem.css.property": {
84
+ "syntax": "<color>",
85
+ "inherits": true
86
+ },
87
+ "nl.nldesignsystem.figma.supports-token": false
88
+ },
89
+ "type": "color"
90
+ },
91
+ "font-family": {
92
+ "$extensions": {
93
+ "nl.nldesignsystem.css.property": {
94
+ "syntax": "*",
95
+ "inherits": true
96
+ },
97
+ "nl.nldesignsystem.figma.supports-token": false
98
+ },
99
+ "type": "fontFamilies"
100
+ },
101
+ "font-size": {
102
+ "$extensions": {
103
+ "nl.nldesignsystem.css.property": {
104
+ "syntax": "<length>",
105
+ "inherits": true
106
+ },
107
+ "nl.nldesignsystem.figma.supports-token": false
108
+ },
109
+ "type": "fontSizes"
110
+ },
111
+ "font-weight": {
112
+ "$extensions": {
113
+ "nl.nldesignsystem.css.property": {
114
+ "syntax": "<number>",
115
+ "inherits": true
116
+ },
117
+ "nl.nldesignsystem.figma.supports-token": false
118
+ },
119
+ "type": "fontWeights"
120
+ },
121
+ "line-height": {
122
+ "$extensions": {
123
+ "nl.nldesignsystem.css.property": {
124
+ "syntax": "<length> | <number>",
125
+ "inherits": true
126
+ },
127
+ "nl.nldesignsystem.figma.supports-token": false
128
+ },
129
+ "type": "lineHeights"
130
+ },
131
+ "margin-block-end": {
132
+ "$extensions": {
133
+ "nl.nldesignsystem.css.property": {
134
+ "syntax": "<length>",
135
+ "inherits": true
136
+ },
137
+ "nl.nldesignsystem.figma.supports-token": false
138
+ },
139
+ "type": "spacing"
140
+ },
141
+ "margin-block-start": {
142
+ "$extensions": {
143
+ "nl.nldesignsystem.css.property": {
144
+ "syntax": "<length>",
145
+ "inherits": true
146
+ },
147
+ "nl.nldesignsystem.figma.supports-token": false
148
+ },
149
+ "type": "spacing"
150
+ },
151
+ "disabled": {
152
+ "color": {
153
+ "$extensions": {
154
+ "nl.nldesignsystem.css.property": {
155
+ "syntax": "<color>",
156
+ "inherits": true
157
+ },
158
+ "nl.nldesignsystem.figma.supports-token": false
159
+ },
160
+ "type": "color"
161
+ }
162
+ }
163
+ }
164
+ }
165
+ }
166
+ }