Repository navigation
Components: Migrate ItemGroup to SCSS module #80797
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
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
3fbb28d
Components: Migrate ItemGroup to SCSS module
shail-mehta 15be7a5
Components: Migrate ItemGroup to SCSS module
shail-mehta 51006ce
Added Changelog Entry
shail-mehta 32147aa
Merge branch 'trunk' into migrate/itemgroup-scss-module
shail-mehta 6417712
Merge branch 'trunk' into migrate/itemgroup-scss-module
shail-mehta 3e9510e
Merge branch 'trunk' into migrate/itemgroup-scss-module
shail-mehta 15958e2
Merge branch 'trunk' into migrate/itemgroup-scss-module
shail-mehta a39a6b0
Apply Feedback Changes
shail-mehta 8884f99
Fix conflict
shail-mehta 02c59e6
Merge branch 'trunk' into migrate/itemgroup-scss-module
shail-mehta c177b21
Merge branch 'trunk' into migrate/itemgroup-scss-module
shail-mehta ce69c1b
Apply Feedback changes
shail-mehta a6132b6
Merge branch 'trunk' into migrate/itemgroup-scss-module
shail-mehta 4bd0942
Merge branch 'trunk' into migrate/itemgroup-scss-module
shail-mehta File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,9 @@ | ||
| /** | ||
| * Internal dependencies | ||
| */ | ||
| import clsx from 'clsx'; | ||
|
|
||
| import type { WordPressComponentProps } from '../../context'; | ||
| import { useContextSystem } from '../../context'; | ||
|
|
||
| /** | ||
| * Internal dependencies | ||
| */ | ||
| import * as styles from '../styles'; | ||
| import { useCx } from '../../utils/hooks/use-cx'; | ||
| import type { ItemGroupProps } from '../types'; | ||
| import styles from '../style.module.scss'; | ||
|
|
||
| export function useItemGroup( | ||
| props: WordPressComponentProps< ItemGroupProps, 'div' > | ||
|
|
@@ -23,12 +17,13 @@ export function useItemGroup( | |
| ...otherProps | ||
| } = useContextSystem( props, 'ItemGroup' ); | ||
|
|
||
| const cx = useCx(); | ||
|
|
||
| const classes = cx( | ||
| isBordered && styles.bordered, | ||
| isSeparated && styles.separated, | ||
| isRounded && styles.rounded, | ||
| const classes = clsx( | ||
| styles[ 'item-group' ], | ||
| { | ||
| [ styles[ 'is-bordered' ] ]: isBordered, | ||
| [ styles[ 'is-separated' ] ]: isSeparated, | ||
| [ styles[ 'is-rounded' ] ]: isRounded, | ||
| }, | ||
|
Comment on lines
+20
to
+26
Member
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. These are also modifier classes. I'd probably add a |
||
| className | ||
| ); | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| @use "../utils/theme-variables" as *; | ||
|
|
||
| // Matches CONFIG.surfaceBorderColor — not the WPDS stroke token (#dbdbdb). | ||
| $surface-border-color: rgba(0, 0, 0, 0.1); | ||
|
|
||
| // Matches CONFIG.controlHeight. | ||
| $control-height: 36px; | ||
| $base-font-height: calc(13px * 1.4); | ||
|
|
||
| /* | ||
| * Math: | ||
| * - Use the desired height as the base value | ||
| * - Subtract the computed height of (default) text | ||
| * - Subtract the effects of border | ||
| * - Divide the calculated number by 2, in order to get an individual top/bottom padding | ||
| */ | ||
| $padding-y: calc((#{$control-height} - #{$base-font-height} - 2px) / 2); | ||
| $padding-y-small: calc((calc(#{$control-height} * 0.8) - #{$base-font-height} - 2px) / 2); | ||
| $padding-y-large: calc((calc(#{$control-height} * 1.2) - #{$base-font-height} - 2px) / 2); | ||
|
|
||
| .item-group { | ||
| &.is-bordered { | ||
| border: 1px solid $surface-border-color; | ||
| } | ||
|
|
||
| &.is-separated { | ||
| > *:not(marquee) > * { | ||
| border-block-end: 1px solid $surface-border-color; | ||
| } | ||
|
|
||
| > *:last-of-type > * { | ||
| border-block-end-color: transparent; | ||
| } | ||
| } | ||
|
|
||
| &.is-rounded { | ||
| border-radius: var(--wpds-border-radius-sm); | ||
|
|
||
| > *:first-of-type > * { | ||
| border-start-start-radius: var(--wpds-border-radius-sm); | ||
| border-start-end-radius: var(--wpds-border-radius-sm); | ||
| } | ||
|
|
||
| > *:last-of-type > * { | ||
| border-end-start-radius: var(--wpds-border-radius-sm); | ||
| border-end-end-radius: var(--wpds-border-radius-sm); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| .item-wrapper { | ||
| width: 100%; | ||
| display: block; | ||
| } | ||
|
|
||
| .item { | ||
| box-sizing: border-box; | ||
| width: 100%; | ||
| display: block; | ||
| margin: 0; | ||
| color: inherit; | ||
|
|
||
| &.is-unstyled-button, | ||
| &.is-unstyled-link { | ||
| font-size: 13px; | ||
| font-family: inherit; | ||
| appearance: none; | ||
| border: 1px solid transparent; | ||
| cursor: var(--wpds-cursor-control); | ||
| background: none; | ||
| text-align: start; | ||
|
|
||
| svg, | ||
| path { | ||
| fill: currentColor; | ||
| } | ||
|
|
||
| &:hover { | ||
| color: $components-color-accent; | ||
| } | ||
|
|
||
| &:focus { | ||
| box-shadow: none; | ||
| outline: none; | ||
| } | ||
|
|
||
| &:focus-visible { | ||
| box-shadow: 0 0 0 var(--wp-admin-border-width-focus) $components-color-accent; | ||
| // Windows high contrast mode. | ||
| outline: 2px solid transparent; | ||
| outline-offset: 0; | ||
| } | ||
| } | ||
|
|
||
| &.is-unstyled-link { | ||
| text-decoration: none; | ||
| } | ||
|
|
||
| &.is-spaced-around { | ||
| border-radius: var(--wpds-border-radius-sm); | ||
| } | ||
|
|
||
| &.is-size-small { | ||
| padding: $padding-y-small 8px; | ||
| } | ||
|
|
||
| &.is-size-medium { | ||
| padding: $padding-y 12px; | ||
| } | ||
|
|
||
| &.is-size-large { | ||
| // Matches CONFIG.controlPaddingXLarge (`12 * 1.3334`). | ||
| padding: $padding-y-large 16.0008px; | ||
| } | ||
| } |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 also needs to be in the breaking change section, like the other PR. Anything that replaces a
cxcall.