-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
ToggleGroupControl: Add size variants #42008
Changes from all commits
38b4537
e4a1085
39750d4
3129622
b52d7e3
f8ba70c
45694d1
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 |
---|---|---|
|
@@ -47,6 +47,7 @@ function ToggleGroupControl( | |
hideLabelFromVision = false, | ||
help, | ||
onChange = noop, | ||
size = 'default', | ||
value, | ||
children, | ||
...otherProps | ||
|
@@ -83,12 +84,11 @@ function ToggleGroupControl( | |
const classes = useMemo( | ||
() => | ||
cx( | ||
styles.ToggleGroupControl, | ||
styles.ToggleGroupControl( { size } ), | ||
isBlock && styles.block, | ||
Comment on lines
+87
to
88
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 kind of wanted to refactor this so these styles go in the |
||
'medium', | ||
Comment on lines
+87
to
-88
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. This was adding a 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. It would be interesting to see if using 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 are no specific mentions of it in the original PR, but looking at the component in G2 we can surmise that the |
||
className | ||
), | ||
[ className, cx, isBlock ] | ||
[ className, cx, isBlock, size ] | ||
); | ||
return ( | ||
<BaseControl help={ help }> | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -8,19 +8,26 @@ import styled from '@emotion/styled'; | |||||||||||
* Internal dependencies | ||||||||||||
*/ | ||||||||||||
import { CONFIG, COLORS, reduceMotion } from '../../utils'; | ||||||||||||
import type { ToggleGroupControlProps } from '../types'; | ||||||||||||
|
||||||||||||
export const ToggleGroupControl = css` | ||||||||||||
export const ToggleGroupControl = ( { | ||||||||||||
size, | ||||||||||||
}: { | ||||||||||||
size: NonNullable< ToggleGroupControlProps[ 'size' ] >; | ||||||||||||
} ) => css` | ||||||||||||
background: ${ COLORS.ui.background }; | ||||||||||||
border: 1px solid; | ||||||||||||
border-color: ${ COLORS.ui.border }; | ||||||||||||
border-radius: ${ CONFIG.controlBorderRadius }; | ||||||||||||
display: inline-flex; | ||||||||||||
min-height: ${ CONFIG.controlHeight }; | ||||||||||||
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. It looks like the CONFIG holds a few values for controls height: gutenberg/packages/components/src/utils/config-values.js Lines 23 to 27 in e4252e4
As we work on standardizing the size variants, we should either:
What do you think? 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.
Yes 🙈 I think this level of Logic & Order™ is hard to sustain unless they are accounted for at the design stage. Based on our current priorities, we can keep it simple for now. 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. Even though I believe that updating the config and using across components would have have been a more clear way to enforce a common height across controls, I'm also ok with deleting the common config and using "local" styles in control components for their heights. I had a quick look and there aren't too many usages left of |
||||||||||||
min-width: 0; | ||||||||||||
padding: 2px; | ||||||||||||
position: relative; | ||||||||||||
transition: transform ${ CONFIG.transitionDurationFastest } linear; | ||||||||||||
${ reduceMotion( 'transition' ) } | ||||||||||||
|
||||||||||||
${ toggleGroupControlSize( size ) } | ||||||||||||
|
||||||||||||
&:hover { | ||||||||||||
border-color: ${ COLORS.ui.borderHover }; | ||||||||||||
} | ||||||||||||
|
@@ -33,6 +40,19 @@ export const ToggleGroupControl = css` | |||||||||||
} | ||||||||||||
`; | ||||||||||||
|
||||||||||||
export const toggleGroupControlSize = ( | ||||||||||||
size: NonNullable< ToggleGroupControlProps[ 'size' ] > | ||||||||||||
) => { | ||||||||||||
const heights = { | ||||||||||||
default: '36px', | ||||||||||||
'__unstable-large': '40px', | ||||||||||||
}; | ||||||||||||
|
||||||||||||
return css` | ||||||||||||
min-height: ${ heights[ size ] }; | ||||||||||||
`; | ||||||||||||
}; | ||||||||||||
|
||||||||||||
export const block = css` | ||||||||||||
display: flex; | ||||||||||||
width: 100%; | ||||||||||||
|
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.
This doesn't look like it's being used anywhere.