Skip to content

Add ability for compound focus indicator #7479

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 9 commits into from
Jan 28, 2025
Merged

Add ability for compound focus indicator #7479

merged 9 commits into from
Jan 28, 2025

Conversation

taysea
Copy link
Collaborator

@taysea taysea commented Jan 24, 2025

What does this PR do?

Enhances Grommet theme to allow for user to do compound focus style that combines both "outline" and "box-shadow" -- this is useful to enable alignment to WCAG recommendation: https://www.w3.org/WAI/WCAG21/Techniques/css/C40

Previously, Grommet would should outline or shadow, so the caller's theme must "opt-in" via theme.global.focus.twoColor.

Where should the reviewer start?

What testing has been done on this PR?

Locally and added jest test

Screen.Recording.2025-01-23.at.5.21.02.PM.mov

How should this be manually tested?

 focus: {
        // shadow or outline are required for accessibility
        // border: {
        //   // remove to only have shadow
        //   color: 'focus',
        // },
        outline: { color: 'black', size: '2px', offset: '2px' },
        shadow: {
          color: 'skyblue',
          size: '2px',
          blur: '0px',
          // inset: true,
        },
        twoColor: true,
      },

Do Jest tests follow these best practices?

  • screen is used for querying.
  • The correct query is used. (Refer to this list of queries)
  • asFragment() is used for snapshot testing.

Any background context you want to provide?

What are the relevant issues?

Closes #7475

Screenshots (if appropriate)

Do the grommet docs need to be updated?

Should this PR be mentioned in the release notes?

Is this change backwards compatible or is it a breaking change?

@taysea taysea requested review from jcfilben and halocline January 24, 2025 01:22
};
shadow?:
| string
| {
color?: ColorType;
size?: string;
blur?: string;
};
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need to include allowAll here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, thank you. Will add.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

@taysea taysea requested a review from jcfilben January 27, 2025 19:04
jcfilben
jcfilben previously approved these changes Jan 27, 2025
Copy link
Collaborator

@jcfilben jcfilben left a comment

Choose a reason for hiding this comment

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

Looks good!

@jcfilben jcfilben dismissed their stale review January 27, 2025 21:55

Jest test failing

@taysea taysea requested a review from jcfilben January 27, 2025 23:28
Copy link
Collaborator

@halocline halocline left a comment

Choose a reason for hiding this comment

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

Implementation and functionality look good.

One question re: theme property name.

@@ -281,6 +281,7 @@ export const generate = (baseSpacing = 24, scale = 6) => {
color: 'focus',
size: '2px',
},
allowAll: undefined,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Pausing on the name of this property. From a Grommet convention, typically we haven't used verbs, instead use a noun / specific property.

How were we thinking of describing this in the documentation? Something like?:

If true, applies both outline and shadow styles to create a compound focus ring.

OR,

If true, applies both outline and shadow styles to create a two-color focus ring.

A couple naming options:

  • twoColor
  • compound

"Two-color" seemed to be the most common terminology used in search results.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good feedback, let's use the term twoColor since it speaks to the technique this is seeking to enable.

@taysea taysea requested a review from halocline January 28, 2025 21:51
@jcfilben jcfilben merged commit 1f9fa40 into master Jan 28, 2025
16 checks passed
@jcfilben jcfilben deleted the 7475-focus branch January 28, 2025 23:21
@taysea taysea mentioned this pull request Jan 29, 2025
3 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.

Focus indicator -- ability to have outline + shadow
3 participants