Skip to content

Commit 1f7f11b

Browse files
gwyneplainesophschneider
authored andcommitted
[Filters] consolidate se23 logic and styles (#10178)
<!-- ☝️How to write a good PR title: - Prefix it with [ComponentName] (if applicable), for example: [Button] - Start with a verb, for example: Add, Delete, Improve, Fix… - Give as much context as necessary and as little as possible - Prefix it with [WIP] while it’s a work in progress --> Fixes #9934 <!-- Context about the problem that’s being addressed. --> - consolidate se23 logic - consolidate se23 styles - [Storybook](https://5d559397bae39100201eedc1-avqvvftkub.chromatic.com/?path=/story/all-components-filters--with-a-resource-list) - [Prod storybook](https://storybook.polaris.shopify.com/?path=/story/all-components-filters--with-a-resource-list&globals=polarisSummerEditions2023:true) - [x] Tested on [mobile](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting.md#cross-browser-testing) - [ ] Tested on [multiple browsers](https://help.shopify.com/en/manual/shopify-admin/supported-browsers) - [ ] Tested for [accessibility](https://github.com/Shopify/polaris/blob/main/documentation/Accessibility%20testing.md) - [ ] Updated the component's `README.md` with documentation changes - [ ] [Tophatted documentation](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting%20documentation.md) changes in the style guide
1 parent eb7e258 commit 1f7f11b

File tree

7 files changed

+74
-236
lines changed

7 files changed

+74
-236
lines changed

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

Lines changed: 24 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@
8686
}
8787

8888
.AddFilter {
89-
background: var(--p-color-bg-subdued);
90-
border-radius: var(--p-border-radius-6);
91-
border: var(--p-color-border-subdued) dashed var(--p-border-width-1);
89+
background: var(--p-color-bg);
90+
border-radius: var(--p-border-radius-2);
91+
border: var(--p-color-border) dashed var(--p-border-width-1);
9292
padding: 0 var(--p-space-2) 0 var(--p-space-3);
9393
height: 28px;
9494
cursor: pointer;
@@ -114,22 +114,30 @@
114114

115115
&:hover,
116116
&:focus {
117-
background: var(--p-color-bg-hover);
117+
background: transparent;
118118
border-color: var(--p-color-border-hover);
119119

120120
path {
121121
fill: var(--p-color-icon-hover);
122122
}
123123
}
124124

125+
&:hover {
126+
border-style: solid;
127+
}
128+
129+
&:focus {
130+
outline-offset: var(--p-border-width-2);
131+
}
132+
125133
&:active {
126-
background: var(--p-color-bg-active);
134+
background: var(--p-color-bg-secondary-experimental);
127135
border-color: var(--p-color-border-hover);
128136
}
129137

130138
&[aria-disabled='true'] {
131-
background: var(--p-color-bg-disabled);
132-
border-color: var(--p-color-border-disabled);
139+
background: var(--p-color-bg-transparent-disabled-experimental);
140+
border-color: transparent;
133141
color: var(--p-color-text-disabled);
134142
cursor: default;
135143

@@ -144,7 +152,7 @@
144152
}
145153

146154
&::after {
147-
border-radius: var(--p-border-radius-6);
155+
border-radius: var(--p-border-radius-2);
148156
}
149157

150158
span {
@@ -162,34 +170,6 @@
162170
width: var(--p-space-4);
163171
}
164172
}
165-
166-
#{$se23} & {
167-
background: var(--p-color-bg-secondary-experimental);
168-
border-radius: var(--p-border-radius-2);
169-
border: var(--p-color-border) dashed var(--p-border-width-1);
170-
171-
&:hover {
172-
background: transparent;
173-
border-style: solid;
174-
}
175-
176-
&:focus {
177-
background: transparent;
178-
outline-offset: var(--p-border-width-2);
179-
}
180-
181-
&:active {
182-
background: var(--p-color-bg-subdued);
183-
184-
#{$se23} & {
185-
background: var(--p-color-bg-secondary-experimental);
186-
}
187-
}
188-
189-
&::after {
190-
border-radius: var(--p-border-radius-2);
191-
}
192-
}
193173
}
194174

195175
@media #{$p-breakpoints-md-down} {
@@ -255,32 +235,22 @@
255235
}
256236

257237
.ClearAll {
258-
margin-left: var(--p-space-1);
238+
margin-left: var(--p-space-2);
259239

260-
#{$se23} & {
261-
margin-left: var(--p-space-2);
262-
263-
// stylelint-disable-next-line -- se23 overrides
264-
span {
265-
font-size: var(--p-font-size-75);
266-
font-weight: var(--p-font-weight-medium);
267-
}
240+
span {
241+
font-size: var(--p-font-size-75);
242+
font-weight: var(--p-font-weight-medium);
268243
}
269244
}
270245

271246
@media #{$p-breakpoints-md-down} {
272247
.ClearAll {
273-
margin-left: var(--p-space-2);
248+
margin-left: 0;
274249
padding-right: var(--p-space-4);
275250

276-
#{$se23} & {
277-
margin-left: 0;
278-
279-
// stylelint-disable-next-line -- se23 overrides
280-
span {
281-
font-size: var(--p-font-size-100);
282-
font-weight: var(--p-font-weight-medium);
283-
}
251+
span {
252+
font-size: var(--p-font-size-100);
253+
font-weight: var(--p-font-weight-medium);
284254
}
285255
}
286256

polaris-react/src/components/Filters/Filters.tsx

Lines changed: 15 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import {Text} from '../Text';
1010
import {UnstyledButton} from '../UnstyledButton';
1111
import {classNames} from '../../utilities/css';
1212
import {useBreakpoints} from '../../utilities/breakpoints';
13-
import {useFeatures} from '../../utilities/features';
1413
import type {
1514
ActionListItemDescriptor,
1615
AppliedFilterInterface,
@@ -139,7 +138,6 @@ export function Filters({
139138
}: FiltersProps) {
140139
const i18n = useI18n();
141140
const {mdDown} = useBreakpoints();
142-
const {polarisSummerEditions2023: se23} = useFeatures();
143141
const [popoverActive, setPopoverActive] = useState(false);
144142
const hasMounted = useRef(false);
145143

@@ -230,8 +228,7 @@ export function Filters({
230228

231229
const hasOneOrMorePinnedFilters = pinnedFilters.length >= 1;
232230

233-
const se23LabelVariant = mdDown && se23 ? 'bodyLg' : 'bodySm';
234-
const labelVariant = mdDown ? 'bodyMd' : 'bodySm';
231+
const labelVariant = mdDown ? 'bodyLg' : 'bodySm';
235232

236233
const addFilterActivator = (
237234
<div>
@@ -246,7 +243,7 @@ export function Filters({
246243
disableFilters
247244
}
248245
>
249-
<Text variant={se23 ? se23LabelVariant : labelVariant} as="span">
246+
<Text variant={labelVariant} as="span">
250247
{i18n.translate('Polaris.Filters.addFilter')}{' '}
251248
</Text>
252249
<PlusMinor />
@@ -272,39 +269,21 @@ export function Filters({
272269
);
273270
}, [loading, children]);
274271

275-
const containerSpacing:
276-
| {
277-
paddingBlockStart: BoxProps['paddingBlockStart'];
278-
paddingBlockEnd: BoxProps['paddingBlockEnd'];
279-
paddingInlineStart: BoxProps['paddingInlineStart'];
280-
paddingInlineEnd: BoxProps['paddingInlineEnd'];
281-
}
282-
| {padding: BoxProps['padding']} = se23
283-
? {
284-
paddingInlineStart: '2',
285-
paddingInlineEnd: '2',
286-
paddingBlockStart: '2',
287-
paddingBlockEnd: '2',
288-
}
289-
: {
290-
paddingBlockStart: {
291-
xs: '3',
292-
md: '2',
293-
},
294-
paddingBlockEnd: {
295-
xs: '3',
296-
md: '2',
297-
},
298-
paddingInlineStart: '2',
299-
paddingInlineEnd: {
300-
xs: '4',
301-
md: '3',
302-
},
303-
};
272+
const containerSpacing: {
273+
paddingBlockStart: BoxProps['paddingBlockStart'];
274+
paddingBlockEnd: BoxProps['paddingBlockEnd'];
275+
paddingInlineStart: BoxProps['paddingInlineStart'];
276+
paddingInlineEnd: BoxProps['paddingInlineEnd'];
277+
} = {
278+
paddingInlineStart: '2',
279+
paddingInlineEnd: '2',
280+
paddingBlockStart: '2',
281+
paddingBlockEnd: '2',
282+
};
304283

305284
const queryFieldMarkup = hideQueryField ? null : (
306285
<div
307-
className={classNames(styles.Container, se23 && styles.ContainerUplift)}
286+
className={classNames(styles.Container, styles.ContainerUplift)}
308287
>
309288
<Box {...containerSpacing}>
310289
<InlineStack
@@ -415,7 +394,7 @@ export function Filters({
415394
size="micro"
416395
onClick={handleClearAllFilters}
417396
removeUnderline
418-
variant="tertiary"
397+
variant="monochromePlain"
419398
>
420399
{i18n.translate('Polaris.Filters.clearFilters')}
421400
</Button>

polaris-react/src/components/Filters/components/FilterPill/FilterPill.scss

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

33
.FilterButton {
4-
background: var(--p-color-bg-subdued);
5-
border-radius: var(--p-border-radius-6);
6-
border: var(--p-color-border-subdued) dashed var(--p-border-width-1);
4+
background: var(--p-color-bg);
5+
border-radius: var(--p-border-radius-2);
6+
border: var(--p-color-border) dashed var(--p-border-width-1);
77
cursor: pointer;
88
color: var(--p-color-text);
99

@@ -26,8 +26,22 @@
2626
}
2727
}
2828

29+
&:hover,
30+
&:active {
31+
border-style: solid;
32+
}
33+
34+
&:hover,
35+
&:focus {
36+
background: transparent;
37+
}
38+
39+
&:active {
40+
background: var(--p-color-bg-subdued);
41+
}
42+
2943
&.disabledFilterButton {
30-
background: var(--p-color-bg-disabled);
44+
background: var(--p-color-bg-transparent-disabled-experimental);
3145
border-color: var(--p-color-border-disabled);
3246
color: var(--p-color-text-disabled);
3347
cursor: default;
@@ -36,58 +50,14 @@
3650
&.ActiveFilterButton {
3751
background: var(--p-color-bg);
3852
border-style: solid;
39-
}
40-
41-
&::after {
42-
border-radius: var(--p-border-radius-6);
43-
}
44-
45-
#{$se23} & {
46-
background: var(--p-color-bg-secondary-experimental);
47-
border-radius: var(--p-border-radius-2);
48-
border: var(--p-color-border) dashed var(--p-border-width-1);
49-
50-
&:hover,
51-
&:active {
52-
border-style: solid;
53-
}
54-
55-
&:hover,
56-
&:focus {
57-
background: transparent;
58-
}
5953

6054
&:active {
6155
background: var(--p-color-bg-subdued);
62-
63-
#{$se23} & {
64-
background: var(--p-color-bg-secondary-experimental);
65-
}
66-
}
67-
68-
&.disabledFilterButton {
69-
background: var(--p-color-bg-disabled);
70-
border-color: var(--p-color-border-disabled);
71-
color: var(--p-color-text-disabled);
72-
cursor: default;
73-
}
74-
75-
&.ActiveFilterButton {
76-
background: var(--p-color-bg);
77-
border-style: solid;
78-
79-
&:active {
80-
background: var(--p-color-bg-subdued);
81-
82-
#{$se23} & {
83-
background: var(--p-color-bg-secondary-experimental);
84-
}
85-
}
8656
}
57+
}
8758

88-
&::after {
89-
border-radius: var(--p-border-radius-2);
90-
}
59+
&::after {
60+
border-radius: var(--p-border-radius-2);
9161
}
9262
}
9363

@@ -161,7 +131,7 @@
161131
}
162132

163133
.ClearButtonWrapper {
164-
#{$se23} & button {
134+
button {
165135
min-height: 0;
166136
padding: 0;
167137
margin: 0;

polaris-react/src/components/Filters/components/FilterPill/FilterPill.tsx

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React, {useState, useEffect, useRef, useCallback} from 'react';
22
import {
33
CancelSmallMinor,
4-
CaretDownMinor,
54
ChevronDownMinor,
65
} from '@shopify/polaris-icons';
76

@@ -15,7 +14,6 @@ import {Text} from '../../../Text';
1514
import {InlineStack} from '../../../InlineStack';
1615
import {UnstyledButton} from '../../../UnstyledButton';
1716
import {useBreakpoints} from '../../../../utilities/breakpoints';
18-
import {useFeatures} from '../../../../utilities/features';
1917
import {classNames} from '../../../../utilities/css';
2018
import type {FilterInterface} from '../../../../types';
2119

@@ -52,7 +50,6 @@ export function FilterPill({
5250
}: FilterPillProps) {
5351
const i18n = useI18n();
5452
const {mdDown} = useBreakpoints();
55-
const {polarisSummerEditions2023} = useFeatures();
5653

5754
const elementRef = useRef<HTMLDivElement>(null);
5855
const {
@@ -120,16 +117,11 @@ export function FilterPill({
120117
styles.ToggleButton,
121118
);
122119

123-
const se23LabelVariant =
124-
mdDown && polarisSummerEditions2023 ? 'bodyLg' : 'bodySm';
125-
const labelVariant = mdDown ? 'bodyMd' : 'bodySm';
120+
const labelVariant = mdDown ? 'bodyLg' : 'bodySm';
126121

127122
const wrappedLabel = (
128123
<div className={styles.Label}>
129-
<Text
130-
variant={polarisSummerEditions2023 ? se23LabelVariant : labelVariant}
131-
as="span"
132-
>
124+
<Text variant={labelVariant} as="span">
133125
{label}
134126
</Text>
135127
</div>
@@ -153,14 +145,7 @@ export function FilterPill({
153145
<>
154146
{wrappedLabel}
155147
<div className={styles.IconWrapper}>
156-
<Icon
157-
source={
158-
polarisSummerEditions2023
159-
? ChevronDownMinor
160-
: CaretDownMinor
161-
}
162-
tone="base"
163-
/>
148+
<Icon source={ChevronDownMinor} tone="base" />
164149
</div>
165150
</>
166151
)}

0 commit comments

Comments
 (0)