Skip to content

Commit 45802a6

Browse files
bernhard-adobelunarfusionpfulton
authored
feat(fieldlabel)!: migrate to core tokens (CSS-102) (#1476)
BREAKING CHANGE: migrates FieldLabel to core tokens Co-authored-by: Monet Fort <lunarfusion@users.noreply.github.com> Co-authored-by: Patrick Fulton <pfulton@users.noreply.github.com>
1 parent 4b531e8 commit 45802a6

File tree

6 files changed

+234
-166
lines changed

6 files changed

+234
-166
lines changed

components/fieldlabel/gulpfile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
module.exports = require('@spectrum-css/component-builder');
1+
module.exports = require('@spectrum-css/component-builder-simple');

components/fieldlabel/index.css

Lines changed: 100 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -10,47 +10,85 @@ OF ANY KIND, either express or implied. See the License for the specific languag
1010
governing permissions and limitations under the License.
1111
*/
1212

13-
@import "../vars/css/components/spectrum-fieldlabel.css";
13+
14+
/* Component level tokens currently missing in core-tokens as of July 2022 or are simply incorrect */
15+
.spectrum--medium {
16+
--spectrum-field-label-top-to-asterisk-small: 8px;
17+
}
18+
19+
.spectrum--large {
20+
--spectrum-field-label-top-to-asterisk-small: 11px;
21+
}
1422

1523
.spectrum-FieldLabel--sizeS {
16-
@remapvars {
17-
find: --spectrum-fieldlabel-s-;
18-
replace: --spectrum-fieldlabel-;
19-
}
24+
--spectrum-fieldlabel-top-to-text: var(--spectrum-component-top-to-text-75);
25+
--spectrum-fieldlabel-bottom-to-text: var(--spectrum-component-bottom-to-text-75);
26+
--spectrum-fieldlabel-font-size: var(--spectrum-font-size-75);
27+
28+
--spectrum-fieldlabel-line-height: var(--spectrum-line-height-100);
29+
--spectrum-fieldlabel-cjk-line-height: var(--spectrum-cjk-line-height-100);
30+
31+
--spectrum-fieldlabel-asterisk-gap: var(--spectrum-field-label-top-to-asterisk-small);
32+
--spectrum-fieldlabel-side-padding-top: var(--spectrum-component-top-to-text-75);
33+
--spectrum-fieldlabel-side-padding-right: var(--spectrum-spacing-100);
34+
--spectrum-field-label-text-to-asterisk: var(--spectrum-field-label-text-to-asterisk-small);
2035
}
2136

2237
.spectrum-FieldLabel--sizeM {
23-
@remapvars {
24-
find: --spectrum-fieldlabel-m-;
25-
replace: --spectrum-fieldlabel-;
26-
}
38+
--spectrum-fieldlabel-top-to-text: var(--spectrum-component-top-to-text-75);
39+
--spectrum-fieldlabel-bottom-to-text: var(--spectrum-component-bottom-to-text-75);
40+
--spectrum-fieldlabel-font-size: var(--spectrum-font-size-75);
41+
42+
--spectrum-fieldlabel-line-height: var(--spectrum-line-height-200);
43+
--spectrum-fieldlabel-cjk-line-height: var(--spectrum-cjk-line-height-200);
44+
45+
--spectrum-fieldlabel-asterisk-gap: var(--spectrum-field-label-top-to-asterisk-medium);
46+
--spectrum-fieldlabel-side-padding-top: var(--spectrum-component-top-to-text-75);
47+
--spectrum-fieldlabel-side-padding-right: var(--spectrum-spacing-200);
48+
--spectrum-field-label-text-to-asterisk: var(--spectrum-field-label-text-to-asterisk-medium);
2749
}
2850

2951
.spectrum-FieldLabel--sizeL {
30-
@remapvars {
31-
find: --spectrum-fieldlabel-l-;
32-
replace: --spectrum-fieldlabel-;
33-
}
52+
--spectrum-fieldlabel-top-to-text: var(--spectrum-component-top-to-text-100);
53+
--spectrum-fieldlabel-bottom-to-text: var(--spectrum-component-bottom-to-text-100);
54+
--spectrum-fieldlabel-font-size: var(--spectrum-font-size-100);
55+
56+
--spectrum-fieldlabel-line-height: var(--spectrum-line-height-100);
57+
--spectrum-fieldlabel-cjk-line-height: var(--spectrum-cjk-line-height-100);
58+
59+
--spectrum-fieldlabel-asterisk-gap: var(--spectrum-field-label-top-to-asterisk-large);
60+
--spectrum-fieldlabel-side-padding-top: var(--spectrum-component-top-to-text-100);
61+
--spectrum-fieldlabel-side-padding-right: var(--spectrum-spacing-200);
62+
--spectrum-field-label-text-to-asterisk: var(--spectrum-field-label-text-to-asterisk-large);
3463
}
3564

3665
.spectrum-FieldLabel--sizeXL {
37-
@remapvars {
38-
find: --spectrum-fieldlabel-xl-;
39-
replace: --spectrum-fieldlabel-;
40-
}
66+
--spectrum-fieldlabel-top-to-text: var(--spectrum-component-top-to-text-200);
67+
--spectrum-fieldlabel-bottom-to-text: var(--spectrum-component-bottom-to-text-200);
68+
--spectrum-fieldlabel-font-size: var(--spectrum-font-size-200);
69+
70+
--spectrum-fieldlabel-line-height: var(--spectrum-line-height-200);
71+
--spectrum-fieldlabel-cjk-line-height: var(--spectrum-cjk-line-height-200);
72+
73+
74+
--spectrum-fieldlabel-asterisk-gap: var(--spectrum-field-label-top-to-asterisk-extra-large);
75+
--spectrum-fieldlabel-side-padding-top: var(--spectrum-component-top-to-text-200);
76+
--spectrum-fieldlabel-side-padding-right: var(--spectrum-spacing-200);
77+
--spectrum-field-label-text-to-asterisk: var(--spectrum-field-label-text-to-asterisk-extra-large);
4178
}
4279

4380
.spectrum-FieldLabel {
4481
display: block;
4582

4683
box-sizing: border-box;
4784

48-
padding-block: var(--spectrum-fieldlabel-padding-top) var(--spectrum-fieldlabel-padding-bottom);
85+
padding-block: var(--spectrum-fieldlabel-top-to-text) var(--spectrum-fieldlabel-bottom-to-text);
4986
padding-inline: 0;
5087

51-
font-size: var(--spectrum-fieldlabel-text-size);
52-
font-weight: var(--spectrum-fieldlabel-text-font-weight);
53-
line-height: var(--spectrum-fieldlabel-text-line-height);
88+
font-size: var(--mod-fieldlabel-font-size, var(--spectrum-fieldlabel-font-size));
89+
font-weight: var(--mod-font-weight-regular, var(--spectrum-font-weight-regular));
90+
91+
line-height: var(--mod-fieldlabel-line-height, var(--spectrum-fieldlabel-line-height));
5492

5593
vertical-align: top;
5694

@@ -59,50 +97,74 @@ governing permissions and limitations under the License.
5997
font-smoothing: subpixel-antialiased;
6098
}
6199

100+
/* international lang support */
101+
.spectrum-FieldLabel {
102+
103+
&:lang(ja),
104+
&:lang(zh),
105+
&:lang(ko) {
106+
line-height: var(--mod-fieldlabel-cjk-line-height, var(--spectrum-fieldlabel-cjk-line-height));
107+
}
108+
}
109+
62110
.spectrum-FieldLabel-requiredIcon {
63-
margin-block: 0; /* Previously used this improperly, it doesn't reposition asterisk, just increased top margin on the whole field label var(--spectrum-fieldlabel-asterisk-margin-y) */
64-
margin-inline: var(--spectrum-fieldlabel-asterisk-gap) 0;
111+
margin-block: 0;
112+
/* Previously used this improperly, it doesn't reposition asterisk, just increased top margin on the whole field label var(--spectrum-fieldlabel-asterisk-margin-y) */
113+
margin-inline: var(--mod-fieldlabel-asterisk-gap, var(--spectrum-fieldlabel-asterisk-gap)) 0;
65114
}
66115

67116
.spectrum-FieldLabel--left {
68117
display: inline-block;
69-
padding-block: var(--spectrum-fieldlabel-m-side-padding-top) 0;
70-
padding-inline: 0 var(--spectrum-fieldlabel-m-side-padding-right);
118+
padding-block: var(--mod-fieldlabel-side-padding-top, var(--spectrum-fieldlabel-side-padding-top)) 0;
119+
padding-inline: 0 var(--mod-fieldlabel-side-padding-right, var(--spectrum-fieldlabel-side-padding-right));
71120

72121
& .spectrum-FieldLabel-requiredIcon {
73-
margin-block: var(--spectrum-fieldlabel-m-side-asterisk-margin-y) 0;
74-
margin-inline: var(--spectrum-fieldlabel-asterisk-gap) 0;
122+
margin-block: var(--mod-field-label-text-to-asterisk, var(--spectrum-field-label-text-to-asterisk)) 0;
123+
margin-inline: var(--mod-fieldlabel-asterisk-gap, var(--spectrum-fieldlabel-asterisk-gap)) 0;
75124
}
76125
}
77126

78127
.spectrum-FieldLabel--right {
79128
display: inline-block;
80129
text-align: end;
81-
padding-block: var(--spectrum-fieldlabel-m-side-padding-top) 0;
82-
/* todo: correct missing DNA variable */
83-
padding-inline: 0 var(--spectrum-fieldlabel-m-side-padding-right);
130+
padding-block: var(--mod-fieldlabel-side-padding-top, var(--spectrum-fieldlabel-side-padding-top)) 0;
131+
padding-inline: 0 var(--mod-fieldlabel-side-padding-right, var(--spectrum-fieldlabel-side-padding-right));
84132
}
85133

86134
.spectrum-Form {
87-
--spectrum-tableform-border-spacing: 0 var(--spectrum-global-dimension-size-300);
88-
--spectrum-tableform-margin: calc(var(--spectrum-global-dimension-size-250) * -1) 0;
89-
--spectrum-tableform-labelsabove-item-gap: var(--spectrum-global-dimension-size-100);
135+
/* for /docs/form.html to set field-label inside form */
136+
--spectrum-tableform-border-spacing: 0 var(--mod-spacing-300, var(--spectrum-spacing-300));
137+
/* matching 20px, missing global token for 20px */
138+
--spectrum-tableform-margin-calc: calc(var(--spectrum-spacing-300) + var(--spectrum-spacing-200));
139+
--spectrum-tableform-margin: calc(var(--spectrum-tableform-margin-calc) * -1) 0;
90140

91141
display: table;
92142
border-collapse: separate;
93-
border-spacing: var(--spectrum-tableform-border-spacing);
94-
margin: var(--spectrum-tableform-margin);
143+
border-spacing: var(--mod-tableform-border-spacing, var(--spectrum-tableform-border-spacing));
144+
margin: var(--mod-tableform-margin, var(--spectrum-tableform-margin));
95145
}
96146

97147
.spectrum-Form-item {
98148
display: table-row;
99149
}
100150

101151
.spectrum-Form-itemLabel {
102-
@extend .spectrum-FieldLabel;
103152
display: table-cell;
104153
}
105154

155+
/* disabled state */
156+
157+
.spectrum-FieldLabel,
158+
.spectrum-Form-itemLabel {
159+
&.is-disabled {
160+
color: var(--mod-disabled-content-color, var(--spectrum-disabled-content-color));
161+
162+
.spectrum-FieldLabel-requiredIcon {
163+
color: var(--mod-disabled-content-color, var(--spectrum-disabled-content-color));
164+
}
165+
}
166+
}
167+
106168
.spectrum-Form-itemField {
107169
display: table-cell;
108170
}
@@ -116,8 +178,8 @@ governing permissions and limitations under the License.
116178
display: flex;
117179
flex-direction: column;
118180

119-
& + .spectrum-Form-item {
120-
margin-block-start: var(--spectrum-tableform-labelsabove-item-gap);
181+
&+.spectrum-Form-item {
182+
margin-block-start: var(--mod-field-label-top-to-asterisk-small, var(--spectrum-field-label-top-to-asterisk-small));
121183
}
122184
}
123185
}

components/fieldlabel/package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"name": "@spectrum-css/fieldlabel",
3-
"version": "4.0.29",
3+
"version": "5.0.0-beta.3",
44
"description": "The Spectrum CSS fieldlabel component",
55
"license": "Apache-2.0",
6-
"main": "dist/index-vars.css",
6+
"main": "dist/index.css",
77
"repository": {
88
"type": "git",
99
"url": "https://github.com/adobe/spectrum-css.git",
@@ -17,22 +17,22 @@
1717
},
1818
"peerDependencies": {
1919
"@spectrum-css/icon": "^3.0.21",
20-
"@spectrum-css/vars": "^8.0.0"
20+
"@spectrum-css/tokens": "^3.0.0"
2121
},
2222
"devDependencies": {
2323
"@spectrum-css/checkbox": "^3.1.3",
24-
"@spectrum-css/component-builder": "^3.2.0",
24+
"@spectrum-css/component-builder-simple": "^1.0.0-beta",
2525
"@spectrum-css/fieldgroup": "^3.1.4",
2626
"@spectrum-css/icon": "^3.0.23",
2727
"@spectrum-css/picker": "^1.2.12",
28-
"@spectrum-css/radio": "^3.0.24",
28+
"@spectrum-css/radio": "^4.0.0",
2929
"@spectrum-css/stepper": "^3.0.26",
3030
"@spectrum-css/textfield": "^3.2.4",
31-
"@spectrum-css/vars": "^8.0.0",
31+
"@spectrum-css/tokens": "^3.0.0",
3232
"gulp": "^4.0.0"
3333
},
3434
"publishConfig": {
3535
"access": "public"
3636
},
3737
"homepage": "https://opensource.adobe.com/spectrum-css/"
38-
}
38+
}
Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2019 Adobe. All rights reserved.
2+
Copyright 2022 Adobe. All rights reserved.
33
This file is licensed to you under the Apache License, Version 2.0 (the "License");
44
you may not use this file except in compliance with the License. You may obtain a copy
55
of the License at http://www.apache.org/licenses/LICENSE-2.0
@@ -10,18 +10,5 @@ OF ANY KIND, either express or implied. See the License for the specific languag
1010
governing permissions and limitations under the License.
1111
*/
1212

13-
.spectrum-FieldLabel,
14-
.spectrum-Form-itemLabel {
15-
color: var(--spectrum-fieldlabel-m-text-color);
16-
17-
&.is-disabled {
18-
color: var(--spectrum-fieldlabel-m-text-color-disabled);
19-
20-
.spectrum-FieldLabel-requiredIcon {
21-
color: var(--spectrum-fieldlabel-m-asterisk-color-disabled);
22-
}
23-
}
24-
}
25-
.spectrum-FieldLabel-requiredIcon {
26-
color: var(--spectrum-fieldlabel-m-asterisk-color);
13+
@container (--system: express) {
2714
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*
2+
Copyright 2022 Adobe. All rights reserved.
3+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License. You may obtain a copy
5+
of the License at http://www.apache.org/licenses/LICENSE-2.0
6+
7+
Unless required by applicable law or agreed to in writing, software distributed under
8+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9+
OF ANY KIND, either express or implied. See the License for the specific language
10+
governing permissions and limitations under the License.
11+
*/
12+
13+
@container (--system: spectrum) {
14+
}

0 commit comments

Comments
 (0)