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

Try: Reduce checkbox size in data views #60475

Merged
merged 11 commits into from
Apr 16, 2024
39 changes: 23 additions & 16 deletions packages/components/src/checkbox-control/style.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
$checkbox-input-size: 20px;
$checkbox-input-size-sm: 24px; // Width & height for small viewports.
$checkbox-input-size: var(--wp-components-checkbox-control-size);
$checkbox-input-size-sm: var(--wp-components-checkbox-control-size-sm);

:root {
--wp-components-checkbox-control-size: 20px;
--wp-components-checkbox-control-size-sm: 24px; // Width & height for small viewports.
}

.components-checkbox-control__input[type="checkbox"] {
@include checkbox-control;
Expand All @@ -14,12 +19,12 @@ $checkbox-input-size-sm: 24px; // Width & height for small viewports.
padding: 0 !important;
text-align: center;
vertical-align: top;
width: $checkbox-input-size-sm;
height: $checkbox-input-size-sm;
width: var(--wp-components-checkbox-control-size-sm);
height: var(--wp-components-checkbox-control-size-sm);

@include break-small() {
height: $checkbox-input-size;
width: $checkbox-input-size;
height: var(--wp-components-checkbox-control-size);
width: var(--wp-components-checkbox-control-size);
}

appearance: none;
Expand Down Expand Up @@ -51,12 +56,12 @@ $checkbox-input-size-sm: 24px; // Width & height for small viewports.
display: inline-block;
margin-right: 12px;
vertical-align: middle;
width: $checkbox-input-size-sm;
height: $checkbox-input-size-sm;
width: var(--wp-components-checkbox-control-size-sm);
height: var(--wp-components-checkbox-control-size-sm);

@include break-small() {
width: $checkbox-input-size;
height: $checkbox-input-size;
width: var(--wp-components-checkbox-control-size);
height: var(--wp-components-checkbox-control-size);
}
}

Expand All @@ -65,15 +70,17 @@ svg.components-checkbox-control__indeterminate {
fill: $white;
cursor: pointer;
position: absolute;
left: 0;
top: 0;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
width: $button-size-small;
height: $button-size-small;
max-width: var(--wp-components-checkbox-control-size-sm);
user-select: none;
pointer-events: none;

@include break-small() {
left: -2px;
top: -2px;
// Ensure icon is never too large for the checkbox
max-width: var(--wp-components-checkbox-control-size);
}
user-select: none;
pointer-events: none;
}
29 changes: 15 additions & 14 deletions packages/dataviews/src/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
overflow: auto;
box-sizing: border-box;
scroll-padding-bottom: $grid-unit-80;

--wp-components-checkbox-control-size: 16px;
}

.dataviews-filters__view-actions {
Expand Down Expand Up @@ -92,10 +94,6 @@
&.dataviews-view-table__checkbox-column {
padding-right: 0;
}

.components-checkbox-control__input-container {
margin: $grid-unit-05;
}
}
tr {
border-bottom: 1px solid $gray-100;
Expand Down Expand Up @@ -532,16 +530,19 @@
justify-content: center;
}

.dataviews-view-table-selection-checkbox label {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap;
border: 0;
.dataviews-view-table-selection-checkbox {
line-height: 0;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Without this the checkbox wrapper renders at 18.58px tall which throws off the horizontal alignment with the smaller checkboxes.

label {
position: absolute;
Comment on lines +539 to +540
Copy link
Member

Choose a reason for hiding this comment

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

Sorry for the pain here, we do eventually want to make this kind of checkbox layout possible without hacks! I'll bump the priority.

Copy link
Member

Choose a reason for hiding this comment

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

@jameskoster I was thinking about this in the context of #60799 and realized it was already possible. Quick fix proposed in #60835.

width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap;
border: 0;
}
}

.dataviews-filters__custom-menu-radio-item-prefix {
Expand Down
6 changes: 2 additions & 4 deletions packages/dataviews/src/view-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,7 @@ function TableRow( {
<td
className="dataviews-view-table__checkbox-column"
style={ {
width: 20,
minWidth: 20,
width: '1%',
t-hamano marked this conversation as resolved.
Show resolved Hide resolved
} }
>
<div className="dataviews-view-table__cell-content-wrapper">
Expand Down Expand Up @@ -426,8 +425,7 @@ function ViewTable( {
<th
className="dataviews-view-table__checkbox-column"
style={ {
width: 20,
minWidth: 20,
width: '1%',
} }
data-field-id="selection"
scope="col"
Expand Down
Loading