-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Item: Unify focus style and add default font styles #52495
Changes from 9 commits
48a9691
ebe07be
821a377
1194265
5e88060
48b6050
672e399
74cdb6b
9e29aab
51ef2f8
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 | ||||
---|---|---|---|---|---|---|
|
@@ -10,6 +10,7 @@ | |||||
### Bug Fix | ||||||
|
||||||
- `Popover`: Pin `react-dropdown-menu` version to avoid breaking changes in dependency updates. ([52356](https://github.com/WordPress/gutenberg/pull/52356)). | ||||||
- `Item`: Unify focus style and add default font styles. ([52495](https://github.com/WordPress/gutenberg/pull/52495)). | ||||||
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. Not very important because it's just an optional check, but FYI the CI check for the changelog is failing because this is missing a number symbol:
Suggested change
|
||||||
|
||||||
## 25.3.0 (2023-07-05) | ||||||
|
||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,20 +39,25 @@ Default.args = { | |
children: ( | ||
[ | ||
{ | ||
children: 'First item', | ||
children: 'First button item', | ||
// eslint-disable-next-line no-alert | ||
onClick: () => alert( 'First item clicked' ), | ||
}, | ||
{ | ||
children: 'Second item', | ||
children: 'Second button item', | ||
// eslint-disable-next-line no-alert | ||
onClick: () => alert( 'Second item clicked' ), | ||
}, | ||
{ | ||
children: 'Third item', | ||
children: 'Third button item', | ||
// eslint-disable-next-line no-alert | ||
onClick: () => alert( 'Third item clicked' ), | ||
}, | ||
{ | ||
children: 'Anchor item', | ||
as: 'a', | ||
href: 'https://wordpress.org', | ||
}, | ||
Comment on lines
+56
to
+60
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. I added an anchor element to the Storybook, is that ok? |
||
] as ItemProps[] | ||
).map( mapPropsToItem ), | ||
}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,34 +6,45 @@ import { css } from '@emotion/react'; | |
/** | ||
* Internal dependencies | ||
*/ | ||
import { CONFIG, COLORS } from '../utils'; | ||
|
||
export const unstyledButton = css` | ||
appearance: none; | ||
border: 1px solid transparent; | ||
cursor: pointer; | ||
background: none; | ||
text-align: start; | ||
|
||
svg, | ||
path { | ||
fill: currentColor; | ||
} | ||
|
||
&:hover { | ||
color: ${ COLORS.ui.theme }; | ||
} | ||
|
||
&:focus-visible { | ||
box-shadow: 0 0 0 var( --wp-admin-border-width-focus ) | ||
var( | ||
--wp-components-color-accent, | ||
var( --wp-admin-theme-color, ${ COLORS.ui.theme } ) | ||
); | ||
// Windows high contrast mode. | ||
outline: 2px solid transparent; | ||
} | ||
`; | ||
import { CONFIG, COLORS, font } from '../utils'; | ||
|
||
export const unstyledButton = ( as: 'a' | 'button' ) => { | ||
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. Should we also add an explicit font-size to normalize the sizes between button and anchor? (Like this) In Storybook we can see the font sizes will be different due to the user agent styles. 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. Please see: #52495 (comment) |
||
return css` | ||
font-size: ${ font( 'default.fontSize' ) }; | ||
font-family: inherit; | ||
Comment on lines
+13
to
+14
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.
I noticed that in addition to font size, the browser default font family was applied to the button element, so I added an inherited style. |
||
appearance: none; | ||
border: 1px solid transparent; | ||
cursor: pointer; | ||
background: none; | ||
text-align: start; | ||
text-decoration: ${ as === 'a' ? 'none' : undefined }; | ||
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. Add a style that cancels the default underline only for the anchor element. |
||
|
||
svg, | ||
path { | ||
fill: currentColor; | ||
} | ||
|
||
&:hover { | ||
color: ${ COLORS.ui.theme }; | ||
} | ||
|
||
&:focus { | ||
box-shadow: none; | ||
outline: none; | ||
} | ||
|
||
&:focus-visible { | ||
box-shadow: 0 0 0 var( --wp-admin-border-width-focus ) | ||
var( | ||
--wp-components-color-accent, | ||
var( --wp-admin-theme-color, ${ COLORS.ui.theme } ) | ||
); | ||
// Windows high contrast mode. | ||
outline: 2px solid transparent; | ||
outline-offset: 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. The |
||
} | ||
`; | ||
}; | ||
|
||
export const itemWrapper = css` | ||
width: 100%; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,22 +26,6 @@ | |
fill: $gray-600; | ||
} | ||
|
||
&:is(a) { | ||
text-decoration: none; | ||
display: flex; | ||
align-items: center; | ||
|
||
&:focus { | ||
box-shadow: none; | ||
outline: none; | ||
} | ||
Comment on lines
-34
to
-37
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. 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. |
||
|
||
&:focus-visible { | ||
box-shadow: 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color); | ||
outline: 2px solid transparent; | ||
} | ||
} | ||
|
||
&.with-suffix { | ||
padding-right: $grid-unit-20; | ||
} | ||
|
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.
When I merged the trunk, it included an unintended modification, but the indentation should be correct with this change 🙈