Skip to content

feat(fieldlabel)!: core-tokens implementation (CSS-102) #1476

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

Merged
merged 22 commits into from
Oct 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
44a4d50
feat(fieldlabel): wip - begin core tokens migration
pfulton Jun 28, 2022
5304832
fix: temp disable missing font-sizes
bernhard-adobe Jun 29, 2022
f6decfb
fix: temp disabling missing core tokens
bernhard-adobe Jun 29, 2022
fa185e9
fix: fixing t-shirt sizing for fieldlabel
bernhard-adobe Jun 29, 2022
e0ecf8c
fix: more spacing updates
bernhard-adobe Jun 29, 2022
7c0d33a
fix: removing missing tokens
bernhard-adobe Jun 29, 2022
60abe16
feat: more soft-coding of core vars
bernhard-adobe Jun 30, 2022
3ba0c88
feat: all core-tokens for fieldlabel
bernhard-adobe Jul 13, 2022
088985a
chore: removing unused code
bernhard-adobe Jul 13, 2022
91d8b2a
feat: addressing PR review feedback (#1476)
bernhard-adobe Jul 25, 2022
fe02bc9
feat: adding mod modifiers for fieldlabel
bernhard-adobe Jul 26, 2022
c9e2f0c
feat: swapping out top-top-askterisk-small to temp hard-corded tokens
bernhard-adobe Jul 27, 2022
45cdeb7
feat: adding back disabled state and upping package
bernhard-adobe Aug 11, 2022
6db64a0
chore(fieldlabel): use latest versions of dependencies
pfulton Aug 23, 2022
2161d70
chore(fieldlabel): manually bump version number for beta release
pfulton Aug 23, 2022
bb75491
chore(fieldlabel): add empty custom selectors & bump version
pfulton Aug 23, 2022
de05cd7
fix(fieldlabel): resolve syntax error & re-release
pfulton Aug 23, 2022
ea9e71e
feat: correct padding-top for side-label
bernhard-adobe Sep 23, 2022
6e012ba
feat: using core-tokens again for padding-top
bernhard-adobe Sep 27, 2022
8d36860
chore(fieldlabel): manual version bump for beta release
pfulton Sep 28, 2022
0e3f48e
feat: upping core-tokens to v3.0.0
bernhard-adobe Sep 30, 2022
7e534df
chore(tokens): revert files to main state to skip lerna versioning
pfulton Oct 11, 2022
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
2 changes: 1 addition & 1 deletion components/fieldlabel/gulpfile.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = require('@spectrum-css/component-builder');
module.exports = require('@spectrum-css/component-builder-simple');
138 changes: 100 additions & 38 deletions components/fieldlabel/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,47 +10,85 @@ OF ANY KIND, either express or implied. See the License for the specific languag
governing permissions and limitations under the License.
*/

@import "../vars/css/components/spectrum-fieldlabel.css";

/* Component level tokens currently missing in core-tokens as of July 2022 or are simply incorrect */
.spectrum--medium {
--spectrum-field-label-top-to-asterisk-small: 8px;
}

.spectrum--large {
--spectrum-field-label-top-to-asterisk-small: 11px;
}

.spectrum-FieldLabel--sizeS {
@remapvars {
find: --spectrum-fieldlabel-s-;
replace: --spectrum-fieldlabel-;
}
--spectrum-fieldlabel-top-to-text: var(--spectrum-component-top-to-text-75);
--spectrum-fieldlabel-bottom-to-text: var(--spectrum-component-bottom-to-text-75);
--spectrum-fieldlabel-font-size: var(--spectrum-font-size-75);

--spectrum-fieldlabel-line-height: var(--spectrum-line-height-100);
--spectrum-fieldlabel-cjk-line-height: var(--spectrum-cjk-line-height-100);

--spectrum-fieldlabel-asterisk-gap: var(--spectrum-field-label-top-to-asterisk-small);
--spectrum-fieldlabel-side-padding-top: var(--spectrum-component-top-to-text-75);
--spectrum-fieldlabel-side-padding-right: var(--spectrum-spacing-100);
--spectrum-field-label-text-to-asterisk: var(--spectrum-field-label-text-to-asterisk-small);
}

.spectrum-FieldLabel--sizeM {
@remapvars {
find: --spectrum-fieldlabel-m-;
replace: --spectrum-fieldlabel-;
}
--spectrum-fieldlabel-top-to-text: var(--spectrum-component-top-to-text-75);
--spectrum-fieldlabel-bottom-to-text: var(--spectrum-component-bottom-to-text-75);
--spectrum-fieldlabel-font-size: var(--spectrum-font-size-75);

--spectrum-fieldlabel-line-height: var(--spectrum-line-height-200);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Based on the Xd components file, I think the line-height remains the same for all of the t-shirt sizes (as spectrum-line-height-100). If that's correct (perhaps we should check with design), then I think we can move --spectrum-fieldlabel-line-height: var(--spectrum-line-height-100); to the .spectrum-FieldLabel selector.

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 noticed in the inspection of the current docs site that the line-height changes.
size S and M = 15.6px
size L = 18.2px
Size XL = 20.8px

Screen Shot 2022-07-18 at 15 33 00

Screen Shot 2022-07-18 at 15 33 11

Screen Shot 2022-07-18 at 15 33 16

I think from a visual perspective you do want to increase the line-heights for t-shirt sizing to keep the relational "growth" in sizing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@pfulton does this sound correct to you? Check in tomorrows Design Workshop maybe?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@pfulton I added the --mod modifiers. As there is no color-settings here I don't think we need to set --highcontrast

--spectrum-fieldlabel-cjk-line-height: var(--spectrum-cjk-line-height-200);

--spectrum-fieldlabel-asterisk-gap: var(--spectrum-field-label-top-to-asterisk-medium);
--spectrum-fieldlabel-side-padding-top: var(--spectrum-component-top-to-text-75);
--spectrum-fieldlabel-side-padding-right: var(--spectrum-spacing-200);
--spectrum-field-label-text-to-asterisk: var(--spectrum-field-label-text-to-asterisk-medium);
}

.spectrum-FieldLabel--sizeL {
@remapvars {
find: --spectrum-fieldlabel-l-;
replace: --spectrum-fieldlabel-;
}
--spectrum-fieldlabel-top-to-text: var(--spectrum-component-top-to-text-100);
--spectrum-fieldlabel-bottom-to-text: var(--spectrum-component-bottom-to-text-100);
--spectrum-fieldlabel-font-size: var(--spectrum-font-size-100);

--spectrum-fieldlabel-line-height: var(--spectrum-line-height-100);
--spectrum-fieldlabel-cjk-line-height: var(--spectrum-cjk-line-height-100);

--spectrum-fieldlabel-asterisk-gap: var(--spectrum-field-label-top-to-asterisk-large);
--spectrum-fieldlabel-side-padding-top: var(--spectrum-component-top-to-text-100);
--spectrum-fieldlabel-side-padding-right: var(--spectrum-spacing-200);
--spectrum-field-label-text-to-asterisk: var(--spectrum-field-label-text-to-asterisk-large);
}

.spectrum-FieldLabel--sizeXL {
@remapvars {
find: --spectrum-fieldlabel-xl-;
replace: --spectrum-fieldlabel-;
}
--spectrum-fieldlabel-top-to-text: var(--spectrum-component-top-to-text-200);
--spectrum-fieldlabel-bottom-to-text: var(--spectrum-component-bottom-to-text-200);
--spectrum-fieldlabel-font-size: var(--spectrum-font-size-200);

--spectrum-fieldlabel-line-height: var(--spectrum-line-height-200);
--spectrum-fieldlabel-cjk-line-height: var(--spectrum-cjk-line-height-200);


--spectrum-fieldlabel-asterisk-gap: var(--spectrum-field-label-top-to-asterisk-extra-large);
--spectrum-fieldlabel-side-padding-top: var(--spectrum-component-top-to-text-200);
--spectrum-fieldlabel-side-padding-right: var(--spectrum-spacing-200);
--spectrum-field-label-text-to-asterisk: var(--spectrum-field-label-text-to-asterisk-extra-large);
}

.spectrum-FieldLabel {
display: block;

box-sizing: border-box;

padding-block: var(--spectrum-fieldlabel-padding-top) var(--spectrum-fieldlabel-padding-bottom);
padding-block: var(--spectrum-fieldlabel-top-to-text) var(--spectrum-fieldlabel-bottom-to-text);
padding-inline: 0;

font-size: var(--spectrum-fieldlabel-text-size);
font-weight: var(--spectrum-fieldlabel-text-font-weight);
line-height: var(--spectrum-fieldlabel-text-line-height);
font-size: var(--mod-fieldlabel-font-size, var(--spectrum-fieldlabel-font-size));
font-weight: var(--mod-font-weight-regular, var(--spectrum-font-weight-regular));

line-height: var(--mod-fieldlabel-line-height, var(--spectrum-fieldlabel-line-height));

vertical-align: top;

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

/* international lang support */
.spectrum-FieldLabel {

&:lang(ja),
&:lang(zh),
&:lang(ko) {
line-height: var(--mod-fieldlabel-cjk-line-height, var(--spectrum-fieldlabel-cjk-line-height));
}
}

.spectrum-FieldLabel-requiredIcon {
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) */
margin-inline: var(--spectrum-fieldlabel-asterisk-gap) 0;
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) */
margin-inline: var(--mod-fieldlabel-asterisk-gap, var(--spectrum-fieldlabel-asterisk-gap)) 0;
}

.spectrum-FieldLabel--left {
display: inline-block;
padding-block: var(--spectrum-fieldlabel-m-side-padding-top) 0;
padding-inline: 0 var(--spectrum-fieldlabel-m-side-padding-right);
padding-block: var(--mod-fieldlabel-side-padding-top, var(--spectrum-fieldlabel-side-padding-top)) 0;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This seems to be a problem for Web components, the padding might be too small.
2022-09-22_14-50-55 (1)

padding-inline: 0 var(--mod-fieldlabel-side-padding-right, var(--spectrum-fieldlabel-side-padding-right));

& .spectrum-FieldLabel-requiredIcon {
margin-block: var(--spectrum-fieldlabel-m-side-asterisk-margin-y) 0;
margin-inline: var(--spectrum-fieldlabel-asterisk-gap) 0;
margin-block: var(--mod-field-label-text-to-asterisk, var(--spectrum-field-label-text-to-asterisk)) 0;
margin-inline: var(--mod-fieldlabel-asterisk-gap, var(--spectrum-fieldlabel-asterisk-gap)) 0;
}
}

.spectrum-FieldLabel--right {
display: inline-block;
text-align: end;
padding-block: var(--spectrum-fieldlabel-m-side-padding-top) 0;
/* todo: correct missing DNA variable */
padding-inline: 0 var(--spectrum-fieldlabel-m-side-padding-right);
padding-block: var(--mod-fieldlabel-side-padding-top, var(--spectrum-fieldlabel-side-padding-top)) 0;
padding-inline: 0 var(--mod-fieldlabel-side-padding-right, var(--spectrum-fieldlabel-side-padding-right));
}

.spectrum-Form {
--spectrum-tableform-border-spacing: 0 var(--spectrum-global-dimension-size-300);
--spectrum-tableform-margin: calc(var(--spectrum-global-dimension-size-250) * -1) 0;
--spectrum-tableform-labelsabove-item-gap: var(--spectrum-global-dimension-size-100);
/* for /docs/form.html to set field-label inside form */
--spectrum-tableform-border-spacing: 0 var(--mod-spacing-300, var(--spectrum-spacing-300));
/* matching 20px, missing global token for 20px */
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@pfulton We are missing 20px from the core-tokens. Is it ok to get 20px with a core-tokens addition?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, I think so. This will be something we'll need to keep an eye on, as I think I'd much rather have it coming as a definition from core tokens, but in the meantime (or if we have to), let's do this for now with an eye on possibly defining it ourselves in the custom-* files at some future point.

Copy link
Member

Choose a reason for hiding this comment

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

If we're missing 20px in spacing values, then perhaps the component was designed wrong (or core tokens needs to have a new spacing value). We shouldn't be calcing this.

--spectrum-tableform-margin-calc: calc(var(--spectrum-spacing-300) + var(--spectrum-spacing-200));
--spectrum-tableform-margin: calc(var(--spectrum-tableform-margin-calc) * -1) 0;

display: table;
border-collapse: separate;
border-spacing: var(--spectrum-tableform-border-spacing);
margin: var(--spectrum-tableform-margin);
border-spacing: var(--mod-tableform-border-spacing, var(--spectrum-tableform-border-spacing));
margin: var(--mod-tableform-margin, var(--spectrum-tableform-margin));
}

.spectrum-Form-item {
display: table-row;
}

.spectrum-Form-itemLabel {
@extend .spectrum-FieldLabel;
display: table-cell;
}

/* disabled state */

.spectrum-FieldLabel,
.spectrum-Form-itemLabel {
&.is-disabled {
color: var(--mod-disabled-content-color, var(--spectrum-disabled-content-color));

.spectrum-FieldLabel-requiredIcon {
color: var(--mod-disabled-content-color, var(--spectrum-disabled-content-color));
}
}
}

.spectrum-Form-itemField {
display: table-cell;
}
Expand All @@ -116,8 +178,8 @@ governing permissions and limitations under the License.
display: flex;
flex-direction: column;

& + .spectrum-Form-item {
margin-block-start: var(--spectrum-tableform-labelsabove-item-gap);
&+.spectrum-Form-item {
margin-block-start: var(--mod-field-label-top-to-asterisk-small, var(--spectrum-field-label-top-to-asterisk-small));
}
}
}
14 changes: 7 additions & 7 deletions components/fieldlabel/package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "@spectrum-css/fieldlabel",
"version": "4.0.29",
"version": "5.0.0-beta.3",
"description": "The Spectrum CSS fieldlabel component",
"license": "Apache-2.0",
"main": "dist/index-vars.css",
"main": "dist/index.css",
"repository": {
"type": "git",
"url": "https://github.com/adobe/spectrum-css.git",
Expand All @@ -17,22 +17,22 @@
},
"peerDependencies": {
"@spectrum-css/icon": "^3.0.21",
"@spectrum-css/vars": "^8.0.0"
"@spectrum-css/tokens": "^3.0.0"
},
"devDependencies": {
"@spectrum-css/checkbox": "^3.1.3",
"@spectrum-css/component-builder": "^3.2.0",
"@spectrum-css/component-builder-simple": "^1.0.0-beta",
"@spectrum-css/fieldgroup": "^3.1.4",
"@spectrum-css/icon": "^3.0.23",
"@spectrum-css/picker": "^1.2.12",
"@spectrum-css/radio": "^3.0.24",
"@spectrum-css/radio": "^4.0.0",
"@spectrum-css/stepper": "^3.0.26",
"@spectrum-css/textfield": "^3.2.4",
"@spectrum-css/vars": "^8.0.0",
"@spectrum-css/tokens": "^3.0.0",
"gulp": "^4.0.0"
},
"publishConfig": {
"access": "public"
},
"homepage": "https://opensource.adobe.com/spectrum-css/"
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2019 Adobe. All rights reserved.
Copyright 2022 Adobe. All rights reserved.
This file is licensed to you under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. You may obtain a copy
of the License at http://www.apache.org/licenses/LICENSE-2.0
Expand All @@ -10,18 +10,5 @@ OF ANY KIND, either express or implied. See the License for the specific languag
governing permissions and limitations under the License.
*/

.spectrum-FieldLabel,
.spectrum-Form-itemLabel {
color: var(--spectrum-fieldlabel-m-text-color);

&.is-disabled {
color: var(--spectrum-fieldlabel-m-text-color-disabled);

.spectrum-FieldLabel-requiredIcon {
color: var(--spectrum-fieldlabel-m-asterisk-color-disabled);
}
}
}
.spectrum-FieldLabel-requiredIcon {
color: var(--spectrum-fieldlabel-m-asterisk-color);
@container (--system: express) {
}
14 changes: 14 additions & 0 deletions components/fieldlabel/themes/spectrum.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
Copyright 2022 Adobe. All rights reserved.
This file is licensed to you under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. You may obtain a copy
of the License at http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
OF ANY KIND, either express or implied. See the License for the specific language
governing permissions and limitations under the License.
*/

@container (--system: spectrum) {
}
Loading