Skip to content

feat(fieldlabel): required asterisk vertical alignment #2166

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 3 commits into from
Sep 15, 2023

Conversation

jawinn
Copy link
Collaborator

@jawinn jawinn commented Sep 12, 2023

Description

Update the required asterisk icon (which is set to display: inline-block) to be vertically aligned with the baseline of the text using the vertical-align property, instead of using new snapshot tokens. Removes some margin-block from the asterisk that was not needed.

Also adds stories for required and wrapping + required, and updates the docs.

Note: Per confirmation with design about the original Slack discussion, the asterisk should stay inline at the end of the text. It's not currently achievable in Figma due to container/frame layouts in the tool. Because of that, the asterisk placement in Figma will not match the asterisk placement in code.

CSS-582

How and where has this been tested?

Please tag yourself on the tests you've marked complete to confirm the tests have been run by someone other than the author.

Validation Steps

  1. Design validation:
  • Designer has confirmed that this alignment method looks good @jawinn
  1. Testing site validation:
  • Asterisk is aligned middle in example docs and 2 Storybook stories
  • Spacing between text and asterisk is no longer larger than it should be in examples and Storybook (markup space removed, token value should be only inline margin)
  • No other changes noticed, other than the required asterisk
  1. VRT
  • VRT results are as expected and any changes accepted. There will be two new stories.

Regression testing

Validate:

  1. A legacy documentation page (such as accordion), including:
  • The page renders correctly
  • The page is accessible
  • The page is responsive
  1. A migrated documentation page (such as action group), including:
  • The page renders correctly
  • The page is accessible
  • The page is responsive

Screenshots

To-do list

  • I have read the contribution guidelines.

  • I have updated relevant storybook stories and templates.

  • I have tested these changes in Windows High Contrast mode.

  • If my change impacts other components, I have tested to make sure they don't break.

  • If my change impacts documentation, I have updated the documentation accordingly.

  • ✨ This pull request is ready to merge. ✨

@github-actions
Copy link
Contributor

github-actions bot commented Sep 12, 2023

🚀 Deployed on https://pr-2166--spectrum-css.netlify.app

@github-actions github-actions bot temporarily deployed to pull request September 12, 2023 18:29 Inactive
@jawinn jawinn force-pushed the jawinn/css-582-asterisk-spacing branch from fdd2866 to bfbb60b Compare September 13, 2023 19:27
@github-actions github-actions bot temporarily deployed to pull request September 13, 2023 19:32 Inactive
@jawinn jawinn force-pushed the jawinn/css-582-asterisk-spacing branch from bfbb60b to a026cd8 Compare September 13, 2023 19:35
@github-actions github-actions bot temporarily deployed to pull request September 13, 2023 19:40 Inactive
@jawinn jawinn added the run_vrt For use on PRs looking to kick off VRT label Sep 13, 2023
@github-actions github-actions bot removed the run_vrt For use on PRs looking to kick off VRT label Sep 13, 2023
@@ -176,7 +167,7 @@ governing permissions and limitations under the License.
display: flex;
flex-direction: column;

&+.spectrum-Form-item {
& + .spectrum-Form-item {
margin-block-start: var(--mod-field-label-top-to-asterisk, var(--spectrum-field-label-top-to-asterisk));
Copy link
Collaborator Author

@jawinn jawinn Sep 13, 2023

Choose a reason for hiding this comment

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

Note: all usages of --spectrum-field-label-top-to-asterisk can probably be removed from this file, as this margin within the Labels Above form appears to be using the wrong token and is the last place it's used. I'll make a cleanup update for the .spectrum-Form related styles in a followup PR, as that was starting to escape the bounds of this PR's issue.

Comment on lines +6 to +7
| `--mod-field-label-top-to-asterisk` |
| `--mod-fieldlabel-font-size` |
Copy link
Collaborator

Choose a reason for hiding this comment

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

I hadn't noticed it before, but our naming is inconsistent here, and I'm on the fence as to whether we should leave it alone or update it so that things are consistent. I think we might just want to leave it alone.

- Update the inline-block required icon to be vertically aligned at the
  baseline using the vertical-align property
- Consolidate some repeated styles
- Remove non-existant font-smoothing property
- Include note in docs about not adding extra space in markup for
  required icon. Previously, extra inline space was appearing in
  examples that was in addition to the defined margin-inline token.
- Storybook fix: Add missing required class
Use isRequired field in stories, so the required asterisk is represented
in VRTs. Along with wrapping label text.
@pfulton pfulton force-pushed the jawinn/css-582-asterisk-spacing branch from a026cd8 to 7afa5e1 Compare September 15, 2023 18:19
@github-actions github-actions bot temporarily deployed to pull request September 15, 2023 18:26 Inactive
@pfulton pfulton merged commit de7599e into main Sep 15, 2023
@pfulton pfulton deleted the jawinn/css-582-asterisk-spacing branch September 15, 2023 19:00
mlogsdon18 pushed a commit that referenced this pull request Sep 18, 2023
* feat(fieldlabel): required icon vertical-align

- Update the inline-block required icon to be vertically aligned at the
  baseline using the vertical-align property
- Consolidate some repeated styles
- Remove non-existant font-smoothing property

* docs(fieldlabel): note and change regarding extra inline space

- Include note in docs about not adding extra space in markup for
  required icon. Previously, extra inline space was appearing in
  examples that was in addition to the defined margin-inline token.
- Storybook fix: Add missing required class

* docs(fieldlabel): add stories for required asterisk

Use isRequired field in stories, so the required asterisk is represented
in VRTs. Along with wrapping label text.
@jawinn jawinn mentioned this pull request Feb 28, 2024
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants