-
Notifications
You must be signed in to change notification settings - Fork 839
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
[Emotion] Convert euiFocusRing()
mixin
#5855
Conversation
Updated ThemeExamples code snippets to scroll horizontally
{finalSnippet && ( | ||
<EuiCodeBlock | ||
whiteSpace="pre" |
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'm now forcing these snippets to scroll horizontally because the wrapping causes weird line-breaks making it hard to read.
@@ -58,6 +59,7 @@ export const ThemeValue: FunctionComponent<ThemeValue> = ({ | |||
numberProps, | |||
stringProps, | |||
colorProps, | |||
forceUpdateType, |
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.
The theme value customizing component now accepts a forced type
for rendering the update form component. For instance, the type for focus.color
is your typical ColorModeSwitch
but we're just setting it to a simple string currentColor
so I'm forcing the updating form element to render a text input instead of the color picker.
&.euiSplitPanel-isResponsive.euiPanel--#{$modifier} > .euiSplitPanel__inner, | ||
&.euiPanel--#{$modifier} > .euiSplitPanel__inner { |
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.
Aside fix:
I needed to fix the scope of the border radius' for nested split panels.
// 👉 Safari and Firefox innately respect only showing the outline with keyboard only | ||
// 💔 But they don't allow coloring of the 'auto'/default outline, so contrast is no good in dark mode. | ||
// 👉 For these browsers we use the solid type in order to match with \`currentColor\`. | ||
// 😦 Which does means the outline will be square |
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.
All these comments moved to the function.
@@ -11,7 +11,7 @@ import { CSSProperties } from 'react'; | |||
|
|||
/** | |||
* NOTE: These were quick conversions of their Sass counterparts. | |||
* They have yet to be used/tested. | |||
* The commented out keys have not been established as necessary yet. |
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.
Keeping unused but already "converted" values in these files til I can get to them.
* This re-applies the same default outline with a couple parameters | ||
* @param euiTheme UseEuiTheme.euiTheme | ||
* @param offset Accepts a specific measurement or 'inset' or 'outset' or 'center' to adjust outline position | ||
* @param color Accepts any CSS color, **Note: only works in -webkit-** |
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.
Note to reviewers too: Firefox does not support the color
parameter on outline
.
Preview documentation changes for this PR: https://eui.elastic.co/pr_5855/ |
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.
Thanks, @cchaos. Tested locally in Chrome, Firefox, and Safari. LGTM! 🎉
<p> | ||
By default, all interactable elements will inherit the{' '} | ||
<EuiCode>outline</EuiCode> property from the reset file. However, | ||
some instances require adjustment to the <EuiCode>offset</EuiCode>{' '} | ||
and <EuiCode>color</EuiCode> of this outline. This helper function | ||
allows that customization of the focus outline. | ||
</p> |
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.
Maybe you should list what are the available offset options: 'inset' | 'outset' | 'center' | CSSProperties['outlineOffset']
. I'm just thinking what if I'm using this hook without TS?
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.
Yeah it starts getting into the territory of having to duplicate prop types. I wonder if there's a way we can do this programmatically instead.
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 went ahead and added this one in manually, making space for it in the re-used component ThemeExample
. I'm hoping someone smarter than me will be able to create a re-usable service 😸
Co-authored-by: Elizabet Oliveira <elizabet.oliveira@elastic.co>
Preview documentation changes for this PR: https://eui.elastic.co/pr_5855/ |
Preview documentation changes for this PR: https://eui.elastic.co/pr_5855/ |
Preview documentation changes for this PR: https://eui.elastic.co/pr_5855/ |
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.
Code changes LGTM!
* Commented out some unused (yet) properties and updated the Focus docs section * Make `focus` global token required * Updated ThemeExamples code snippets to scroll horizontally * [EuiSplitPanel] Fix border-radius of nested split panels # Conflicts: # src/global_styling/mixins/index.ts
My general thought process here is that we want to limit the variances in focus states across components, but we know that there are some places where we at least need to adjust the position (inset/outset) of the outline or better control the
color
. This is mainly a component driven and therefore, will can be adjusted through the new function.At the global level, however, I can see a consumer (and eventually user) wanting to adjust some of the settings more broadly like making the outline thicker or making them all a specific color. These are the only tokens that can be adjusted.
Since we "pride" ourselves in accessibility, this pattern enforces consumers to use the standard
outline
property for focus rings and standardizes them across all components for consistency.Global token
I've re-instated the top-level
focus
token on EuiTheme but reduced the original type to justcolor
andwidth
. I've left in the comments from the other keys for now as I'll revisit background colors and transparency later.Mixin -> Function
The new
euiFocusRing()
/useEuiFocusRing()
function/hook returns a full css`` block of styles necessary to customize focus outlines with the ability to adjustcolor
and `offset`.Basic usage:
You can also apply it un-scoped to
:focus
since outlines only apply to focus state anyway.Global reset
The reset file has been updated to use the function directly so that we're only creating these styles once. It also fixed the current
offset
in the reset which was not get calculated correctly. The following screenshot compares the style output based on the 3 usages (none, without:focus
, with:focus
):Checklist
[ ] Checked in mobile[ ] Checked Code Sandbox works for any docs examples[ ] Checked for breaking changes and labeled appropriately[ ] Updated the Figma library counterpart