-
Notifications
You must be signed in to change notification settings - Fork 201
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
Changes from all commits
44a4d50
5304832
f6decfb
fa185e9
e0ecf8c
7c0d33a
60abe16
3ba0c88
088985a
91d8b2a
fe02bc9
c9e2f0c
45cdeb7
6db64a0
2161d70
bb75491
de05cd7
ea9e71e
6e012ba
8d36860
0e3f48e
7e534df
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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'); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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); | ||
--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; | ||
|
||
|
@@ -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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
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 */ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; | ||
} | ||
|
@@ -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)); | ||
} | ||
} | ||
} |
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) { | ||
} |
There was a problem hiding this comment.
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 (asspectrum-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.There was a problem hiding this comment.
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
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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