Skip to content

Commit 49f5763

Browse files
kyledurandchazdean
authored andcommitted
[ResourceItem] Use layout components (#7784)
Closes: #7580 This slightly moves the checkbox handle 2px to the left. This means it now lines up with our 20px padding instead of 22px from the card edge. Also improves vertical alignment of the checkboxes and bulk select on xs screens Before | After ---|--- ![image](https://screenshot.click/24-12-z59dz-bpdqu.png) | ![image](https://screenshot.click/24-12-viiqs-efiaf.png) The only CSS that remains is for interactive elements, interactive behavior (hover, focus), and transitions (which are being removed in https://github.com/Shopify/polaris/pull/7290/files).
1 parent 2e4d7ec commit 49f5763

File tree

7 files changed

+189
-257
lines changed

7 files changed

+189
-257
lines changed

.changeset/nine-worms-sip.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@shopify/polaris': patch
3+
---
4+
5+
Rebuilt `ResourceItem` with layout components

polaris-react/src/components/BulkActions/BulkActions.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ $bulk-actions-button-stacking-order: (
7575
width: auto;
7676
justify-content: flex-start;
7777
margin-right: var(--p-space-2);
78+
margin-left: calc(-1 * var(--p-space-05));
7879
}
7980

8081
.Group-measuring & {
@@ -89,6 +90,7 @@ $bulk-actions-button-stacking-order: (
8990

9091
.CheckableContainer {
9192
flex: 1 1 0;
93+
margin-left: calc(-1 * (var(--p-space-05) + var(--p-space-1)));
9294
}
9395

9496
.disabled {

polaris-react/src/components/ResourceItem/ResourceItem.scss

Lines changed: 11 additions & 150 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,31 @@
11
@import '../../styles/common';
22

33
@mixin action-hide {
4-
clip: rect(1px, 1px, 1px, 1px);
4+
clip: rect(0, 0, 0, 0);
55
overflow: hidden;
6-
height: 1px;
76
}
87

98
@mixin action-unhide {
109
clip: auto;
1110
overflow: visible;
12-
height: 100%;
13-
}
14-
15-
.CheckboxWrapper {
16-
display: flex;
1711
}
1812

1913
.ResourceItem {
2014
--pc-resource-item-min-height: 44px;
2115
--pc-resource-item-disclosure-width: 48px;
22-
// Offset equals handle width + handle margin-left + handle margin-right
23-
--pc-resource-item-offset: 40px;
16+
--pc-resource-item-offset: 38px;
2417
--pc-resource-item-clickable-stacking-order: 1;
2518
--pc-resource-item-content-stacking-order: 2;
26-
position: relative;
2719
outline: none;
2820
cursor: pointer;
2921

30-
&:not(.persistActions) {
31-
.Actions {
32-
right: var(--p-space-4);
33-
}
34-
}
35-
3622
&:hover {
3723
background-color: var(--p-surface-hovered);
3824

39-
&:not(.persistActions) {
40-
// stylelint-disable-next-line selector-max-specificity
41-
.Actions {
25+
.Actions {
26+
/* stylelint-disable-next-line selector-max-combinators */
27+
> * {
4228
@include action-unhide;
43-
44-
// stylelint-disable-next-line max-nesting-depth
45-
@media #{$p-breakpoints-lg-down} {
46-
display: none;
47-
}
4829
}
4930
}
5031
}
@@ -82,67 +63,6 @@
8263
border: none;
8364
}
8465

85-
// Item inner container
86-
.Container {
87-
position: relative;
88-
z-index: var(--pc-resource-item-content-stacking-order);
89-
padding: var(--p-space-3) var(--p-space-4);
90-
min-height: var(--pc-resource-item-min-height);
91-
display: flex;
92-
align-items: flex-start;
93-
94-
@media #{$p-breakpoints-sm-up} {
95-
padding: var(--p-space-3) var(--p-space-5);
96-
}
97-
}
98-
99-
.alignmentLeading {
100-
align-items: flex-start;
101-
}
102-
103-
.alignmentTrailing {
104-
align-items: flex-end;
105-
}
106-
107-
.alignmentCenter {
108-
align-items: center;
109-
}
110-
111-
.alignmentFill {
112-
align-items: stretch;
113-
}
114-
115-
.alignmentBaseline {
116-
align-items: baseline;
117-
}
118-
119-
.Owned {
120-
display: flex;
121-
}
122-
123-
.OwnedNoMedia {
124-
padding-top: var(--p-space-1);
125-
}
126-
127-
// Item handle
128-
.Handle {
129-
width: 48px;
130-
min-height: var(--pc-resource-item-min-height);
131-
justify-content: center;
132-
align-items: center;
133-
margin: calc(-1 * var(--p-space-3)) var(--p-space-1)
134-
calc(-1 * var(--p-space-3)) calc(-1 * var(--p-space-3));
135-
display: flex;
136-
137-
@media #{$p-breakpoints-sm-down} {
138-
visibility: hidden;
139-
140-
.selectMode & {
141-
visibility: visible;
142-
}
143-
}
144-
}
145-
14666
.selectable {
14767
width: calc(100% + var(--pc-resource-item-offset));
14868
transform: translateX(calc(-1 * var(--pc-resource-item-offset)));
@@ -160,78 +80,20 @@
16080
}
16181
}
16282

163-
.Media {
164-
flex: 0 0 auto;
165-
margin-right: var(--p-space-5);
166-
color: inherit;
167-
text-decoration: none;
168-
}
169-
170-
// Item content
171-
.Content {
172-
@include layout-flex-fix;
173-
flex: 1 1 auto;
174-
}
175-
17683
// Item actions
17784
.Actions {
178-
position: absolute;
179-
top: 0;
180-
display: flex;
181-
pointer-events: initial;
182-
height: 100%;
183-
max-height: 56px;
184-
185-
@include action-hide;
186-
187-
.focused & {
188-
@include action-unhide;
85+
> * {
86+
@include action-hide;
18987
}
19088

191-
@media #{$p-breakpoints-lg-down} {
192-
display: none;
193-
}
194-
}
195-
196-
.persistActions {
197-
.Actions {
198-
position: relative;
199-
display: flex;
200-
flex: 0 0 auto;
201-
flex-basis: auto;
202-
align-items: center;
203-
margin-top: 0;
204-
margin-left: var(--p-space-4);
205-
pointer-events: initial;
206-
height: 100%;
207-
208-
@media #{$p-breakpoints-lg-down} {
209-
display: none;
89+
.focused & {
90+
// stylelint-disable-next-line selector-max-combinators
91+
> * {
92+
@include action-unhide;
21093
}
21194
}
21295
}
21396

214-
.Disclosure {
215-
position: relative;
216-
top: calc(-1 * var(--p-space-3));
217-
right: calc(-1 * var(--p-space-4));
218-
display: none;
219-
width: var(--pc-resource-item-disclosure-width);
220-
min-height: var(--pc-resource-item-min-height);
221-
pointer-events: initial;
222-
223-
.selectMode & {
224-
display: none;
225-
}
226-
227-
@media #{$p-breakpoints-lg-down} {
228-
display: flex;
229-
flex: 0 0 var(--pc-resource-item-disclosure-width);
230-
justify-content: center;
231-
align-items: center;
232-
}
233-
}
234-
23597
.selected {
23698
background-color: var(--p-surface-selected);
23799

@@ -245,7 +107,6 @@
245107
}
246108

247109
.ListItem {
248-
position: relative;
249110
@include focus-ring($border-width: -1px);
250111

251112
.ListItem + & {

0 commit comments

Comments
 (0)