Skip to content

Commit eacb1fe

Browse files
authored
[IndexFilters] consolidate se23 styles and logic (#10230)
<!-- ☝️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 --> ### WHY are these changes introduced? Fixes #9938 ### WHAT is this pull request doing? * Consolidate se23 styles * Consolidate se23 logic * Remove custom `FilterButton` and replace it with direct invocations of the Polaris Button instead. This seems safe to do because: * even though we export `FilterButton` from the root of `IndexFilters`, we do not actually expose it directly from the `polaris-react` [entrypoint](https://github.com/Shopify/polaris/blob/0151ec04e4a72a657fc4f3ca53e8990c58a47cfa/polaris-react/src/index.ts#L190). * AFAIK, noone is reaching into our cjs/esm builds to grab`FilterButton` (see [grokt](https://grokt.shopify.io/results?q=%40shopify%2Fpolaris%2F.*%2Fcomponents%2FIndexFilters)) * Just to be sure, also doesn't look like anyone is importing `FilterButton` from @shopify/polaris either. (see [grokt](https://grokt.shopify.io/results?q=FilterButton)) * That said I can see an argument being made for providing convenience wrappers to alleviate repetitive config, so deferring to the team. 👍 Happy to revert if necessary 👍 ### How to 🎩 🖥 [Local development instructions](https://github.com/Shopify/polaris/blob/main/README.md#local-development) 🗒 [General tophatting guidelines](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting.md) 📄 [Changelog guidelines](https://github.com/Shopify/polaris/blob/main/.github/CONTRIBUTING.md#changelog) <!-- Give as much information as needed to experiment with the component in the playground. --> <details> <summary>Copy-paste this code in <code>playground/Playground.tsx</code>:</summary> ```jsx import React from 'react'; import {Page} from '../src'; export function Playground() { return ( <Page title="Playground"> {/* Add the code you want to test in here */} </Page> ); } ``` </details> ### 🎩 checklist - [ ] 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 c1e36bc commit eacb1fe

File tree

15 files changed

+56
-203
lines changed

15 files changed

+56
-203
lines changed

.changeset/wild-dodos-refuse.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+
`IndexFilter` remove custom `FilterButton` in favor of directly invoking the Polaris `Button` component.

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

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,17 @@ $spinner-size: 20px;
3030

3131
.TabsWrapper {
3232
flex: 1;
33-
height: var(--p-space-12);
33+
height: 44px;
3434

35-
#{$se23} & {
36-
height: 44px;
37-
38-
@media #{$p-breakpoints-md-down} {
39-
height: var(--p-space-12);
40-
}
35+
@media #{$p-breakpoints-md-down} {
36+
height: var(--p-space-12);
4137
}
4238
}
4339

4440
.SmallScreenTabsWrapper {
4541
overflow: hidden;
4642
padding: var(--p-space-1) var(--p-space-0) var(--p-space-2) var(--p-space-3);
4743
padding: 0;
48-
height: auto;
4944

5045
&.TabsWrapperLoading {
5146
position: relative;
@@ -90,11 +85,12 @@ $spinner-size: 20px;
9085
gap: var(--p-space-2);
9186
align-items: center;
9287
justify-content: flex-start;
93-
padding: var(--p-space-2) var(--p-space-3) var(--p-space-2) 0;
88+
padding: var(--p-space-1_5-experimental) var(--p-space-2);
9489

9590
@media #{$p-breakpoints-md-down} {
9691
position: relative;
9792
padding: var(--p-space-3) var(--p-space-4);
93+
height: 3rem;
9894
border-left: var(--p-border-width-1) solid var(--p-color-border-subdued);
9995
gap: var(--p-space-2);
10096

@@ -115,14 +111,6 @@ $spinner-size: 20px;
115111
// stylelint-enable
116112
}
117113
}
118-
119-
#{$se23} & {
120-
padding: var(--p-space-1_5-experimental) var(--p-space-2);
121-
122-
@media #{$p-breakpoints-md-down} {
123-
height: 3rem;
124-
}
125-
}
126114
}
127115

128116
.ActionWrap svg {

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import type {FiltersProps} from '../Filters';
1313
import {Tabs} from '../Tabs';
1414
import type {TabsProps} from '../Tabs';
1515
import {useBreakpoints} from '../../utilities/breakpoints';
16-
import {useFeatures} from '../../utilities/features';
1716

1817
import {useIsSticky} from './hooks';
1918
import {
@@ -145,7 +144,6 @@ export function IndexFilters({
145144
setFalse: setFiltersUnFocused,
146145
setTrue: setFiltersFocused,
147146
} = useToggle(false);
148-
const {polarisSummerEditions2023} = useFeatures();
149147

150148
useOnValueChange(mode, (newMode) => {
151149
if (newMode === IndexFiltersMode.Filtering) {
@@ -435,11 +433,7 @@ export function IndexFilters({
435433
borderlessQueryField
436434
closeOnChildOverlayClick={closeOnChildOverlayClick}
437435
>
438-
<InlineStack
439-
gap={polarisSummerEditions2023 ? '2' : '3'}
440-
align="start"
441-
blockAlign="center"
442-
>
436+
<InlineStack gap="2" align="start" blockAlign="center">
443437
<div
444438
style={{
445439
...defaultStyle,

polaris-react/src/components/IndexFilters/components/Container/Container.scss

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
@import '../../../../styles/common';
22

33
.Container {
4-
border-bottom: var(--p-border-width-1) solid var(--p-color-border-subdued);
4+
border-bottom: var(--p-border-width-1) solid var(--p-color-border);
55
border-top-left-radius: var(--p-border-radius-2);
66
border-top-right-radius: var(--p-border-radius-2);
77
background: var(--p-color-bg);
8-
9-
#{$se23} & {
10-
border-bottom: var(--p-border-width-1) solid var(--p-color-border);
11-
}
128
}
139

1410
@media #{$p-breakpoints-sm-down} {

polaris-react/src/components/IndexFilters/components/FilterButton/FilterButton.scss

Lines changed: 0 additions & 29 deletions
This file was deleted.

polaris-react/src/components/IndexFilters/components/FilterButton/FilterButton.tsx

Lines changed: 0 additions & 50 deletions
This file was deleted.

polaris-react/src/components/IndexFilters/components/FilterButton/index.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

polaris-react/src/components/IndexFilters/components/SearchFilterButton/SearchFilterButton.tsx

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ import {Icon} from '../../../Icon';
66
import {Tooltip} from '../../../Tooltip';
77
import {Text} from '../../../Text';
88
import {InlineStack} from '../../../InlineStack';
9-
import {FilterButton} from '../FilterButton';
10-
import {useFeatures} from '../../../../utilities/features';
9+
import {Button} from '../../../Button';
1110

1211
export interface SearchFilterButtonProps {
1312
onClick: () => void;
@@ -28,27 +27,22 @@ export function SearchFilterButton({
2827
hideFilters,
2928
hideQueryField,
3029
}: SearchFilterButtonProps) {
31-
const {polarisSummerEditions2023: se23} = useFeatures();
32-
3330
const iconMarkup = (
3431
<InlineStack gap="0">
3532
{hideQueryField ? null : <Icon source={SearchMinor} tone="base" />}
3633
{hideFilters ? null : <Icon source={FilterMinor} tone="base" />}
3734
</InlineStack>
3835
);
3936

40-
const childMarkup = !se23 ? iconMarkup : null;
41-
4237
const activator = (
4338
<div style={style}>
44-
<FilterButton
39+
<Button
40+
size="slim"
4541
onClick={onClick}
46-
label={label}
4742
disabled={disabled}
48-
icon={se23 ? iconMarkup : undefined}
49-
>
50-
{childMarkup}
51-
</FilterButton>
43+
icon={iconMarkup}
44+
accessibilityLabel={label}
45+
/>
5246
</div>
5347
);
5448

polaris-react/src/components/IndexFilters/components/SortButton/SortButton.tsx

Lines changed: 16 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@ import React, {useState, useMemo} from 'react';
22
import {SortMinor} from '@shopify/polaris-icons';
33

44
import {useI18n} from '../../../../utilities/i18n';
5-
import {Icon} from '../../../Icon';
65
import {Popover} from '../../../Popover';
76
import {ChoiceList} from '../../../ChoiceList';
87
import type {ChoiceListProps} from '../../../ChoiceList';
98
import {Tooltip} from '../../../Tooltip';
109
import {Box} from '../../../Box';
1110
import type {SortButtonChoice} from '../../types';
12-
import {FilterButton} from '../FilterButton';
13-
import {useFeatures} from '../../../../utilities/features';
11+
import {Button} from '../../../Button';
1412

1513
import {DirectionButton} from './components';
1614

@@ -37,7 +35,6 @@ export function SortButton({
3735
onChangeDirection,
3836
}: SortButtonProps) {
3937
const i18n = useI18n();
40-
const {polarisSummerEditions2023} = useFeatures();
4138

4239
const [active, setActive] = useState(false);
4340
const [selectedValueKey, selectedDirection] = selected[0].split(' ');
@@ -97,25 +94,21 @@ export function SortButton({
9794
return currentKey === selectedValueKey;
9895
});
9996

100-
const iconMarkup = polarisSummerEditions2023 ? SortMinor : undefined;
101-
const childMarkup = !polarisSummerEditions2023 ? (
102-
<Icon source={SortMinor} tone="base" />
103-
) : null;
104-
10597
const sortButton = (
10698
<Tooltip
10799
content={i18n.translate('Polaris.IndexFilters.SortButton.tooltip')}
108100
preferredPosition="above"
109101
hoverDelay={400}
110102
>
111-
<FilterButton
112-
icon={iconMarkup}
103+
<Button
104+
size="slim"
105+
icon={SortMinor}
113106
onClick={handleClick}
114-
label={i18n.translate('Polaris.IndexFilters.SortButton.ariaLabel')}
115107
disabled={disabled}
116-
>
117-
{childMarkup}
118-
</FilterButton>
108+
accessibilityLabel={i18n.translate(
109+
'Polaris.IndexFilters.SortButton.ariaLabel',
110+
)}
111+
/>
119112
</Tooltip>
120113
);
121114

@@ -130,11 +123,10 @@ export function SortButton({
130123
>
131124
<Box
132125
minWidth="148px"
133-
padding={polarisSummerEditions2023 ? undefined : '4'}
134-
paddingInlineStart={polarisSummerEditions2023 ? '3' : undefined}
135-
paddingInlineEnd={polarisSummerEditions2023 ? '3' : undefined}
136-
paddingBlockStart={polarisSummerEditions2023 ? '2' : undefined}
137-
paddingBlockEnd={polarisSummerEditions2023 ? '2' : undefined}
126+
paddingInlineStart="3"
127+
paddingInlineEnd="3"
128+
paddingBlockStart="2"
129+
paddingBlockEnd="2"
138130
borderBlockEndWidth="1"
139131
borderColor="border-subdued"
140132
>
@@ -146,15 +138,10 @@ export function SortButton({
146138
/>
147139
</Box>
148140
<Box
149-
padding={polarisSummerEditions2023 ? undefined : '4'}
150-
paddingInlineStart={
151-
polarisSummerEditions2023 ? '1_5-experimental' : undefined
152-
}
153-
paddingInlineEnd={
154-
polarisSummerEditions2023 ? '1_5-experimental' : undefined
155-
}
156-
paddingBlockStart={polarisSummerEditions2023 ? '2' : undefined}
157-
paddingBlockEnd={polarisSummerEditions2023 ? '2' : undefined}
141+
paddingInlineStart="1_5-experimental"
142+
paddingInlineEnd="1_5-experimental"
143+
paddingBlockStart="2"
144+
paddingBlockEnd="2"
158145
>
159146
<DirectionButton
160147
direction="asc"

polaris-react/src/components/IndexFilters/components/SortButton/components/DirectionButton/DirectionButton.scss

Lines changed: 12 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
.DirectionButton {
44
// stylelint-disable-next-line -- This mixin cannot be replaced with a single token
5-
@include focus-ring;
6-
border-radius: var(--p-border-radius-1);
7-
padding: var(--p-space-05);
5+
@include focus-ring($size: 'wide');
6+
border-radius: var(--p-border-radius-2);
7+
padding: var(--p-space-1) var(--p-space-3) var(--p-space-1) var(--p-space-2);
88
font-size: var(--p-font-size-100);
99
display: flex;
1010
align-items: center;
@@ -15,14 +15,7 @@
1515
background: none;
1616
text-align: left;
1717

18-
#{$se23} & {
19-
// stylelint-disable-next-line -- se23 overrides
20-
@include focus-ring($size: 'wide');
21-
border-radius: var(--p-border-radius-2);
22-
padding: var(--p-space-1) var(--p-space-3) var(--p-space-1) var(--p-space-2);
23-
}
24-
25-
#{$se23} &:hover {
18+
&:hover {
2619
background-color: var(--p-color-bg-transparent-hover-experimental);
2720
}
2821

@@ -34,34 +27,20 @@
3427
outline: 0;
3528

3629
// stylelint-disable-next-line -- This mixin cannot be replaced with a single token
37-
@include focus-ring($style: 'focused');
38-
39-
#{$se23} & {
40-
// stylelint-disable-next-line -- se23 overrides
41-
@include focus-ring($size: 'wide', $style: 'focused');
42-
}
30+
@include focus-ring($size: 'wide', $style: 'focused');
4331
}
4432
}
4533

4634
.DirectionButton-active {
47-
background: var(--p-color-bg-interactive-selected);
48-
color: var(--p-color-text-interactive);
49-
50-
#{$se23} & {
51-
color: var(--p-color-text);
52-
background: var(--p-color-bg-transparent-active-experimental);
53-
}
35+
color: var(--p-color-text);
36+
background: var(--p-color-bg-transparent-active-experimental);
5437
}
5538

5639
.Label {
5740
flex: 1;
58-
margin-left: var(--p-space-1);
59-
60-
#{$se23} & {
61-
color: var(--p-color-text);
62-
margin-left: var(--p-space-05);
63-
font-size: var(--p-font-size-75);
64-
font-weight: var(--p-font-weight-medium);
65-
line-height: var(--p-font-line-height-1);
66-
}
41+
color: var(--p-color-text);
42+
margin-left: var(--p-space-05);
43+
font-size: var(--p-font-size-75);
44+
font-weight: var(--p-font-weight-medium);
45+
line-height: var(--p-font-line-height-1);
6746
}

0 commit comments

Comments
 (0)