Skip to content
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

Update spacing in CircularOptionPicker #36014

Merged
merged 3 commits into from
Oct 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,14 @@
// @wordpress/components/src/circular-option-picker/style.scss
$swatch-size: 28px;
Comment on lines 23 to 24
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This could be removed if we're okay with the spacing not being justified as space-between. We can still keep the 6 columns, and I think it looks okay that way.


// Optimize fit of six swatches per line using calc() to create variable
// spacing that mimics a "justified/space-between" layout and works with
// or without scrollbars
@media screen and (min-width: $break-medium) {
// Overrides the default negative margin
.components-circular-option-picker__swatches {
margin-right: 0;
}
// Figures the spacing
.components-circular-option-picker__option-wrapper {
margin-right: calc((100% - (#{$swatch-size} * 6)) / 5);
}
// Removes the right margin on every sixth swatch
.components-circular-option-picker__option-wrapper:nth-child(6n + 6) {
margin-right: 0;
display: grid;
grid-template-columns: repeat(6, $swatch-size);
justify-content: space-between;
}
}


// This shouldn't be needed but there's a rule in the inspector controls
// overriding this causing too much spacing.
// That generic rule should ideally be removed.
Expand Down
8 changes: 3 additions & 5 deletions packages/components/src/circular-option-picker/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,17 @@ $color-palette-circle-spacing: 12px;
justify-content: flex-end;
}

// Effectively negates the end swatch spacing to keep the swatches
// from wrapping before necessary.
.components-circular-option-picker__swatches {
margin-right: -$color-palette-circle-spacing;
display: flex;
flex-wrap: wrap;
gap: $color-palette-circle-spacing;
Copy link
Contributor

Choose a reason for hiding this comment

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

As noted, if you add justify-content: space-between; here, in my testing it appears to space things out more nicely.

Copy link
Contributor Author

@ajlende ajlende Oct 28, 2021

Choose a reason for hiding this comment

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

The problem with space-between is that when you have few swatches in your palette, the spacing for the swatches is too much.

duotone-space-between

I think it's best to leave it as-is here. And in #36018, since we know the number of columns, we can use display: grid and use space-between like is done for the gradient picker.

}
}

.components-circular-option-picker__option-wrapper {
display: inline-block;
height: $color-palette-circle-size;
width: $color-palette-circle-size;
margin-right: $color-palette-circle-spacing;
margin-bottom: $color-palette-circle-spacing;
vertical-align: top;
transform: scale(1);
transition: 100ms transform ease;
Expand Down