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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AppProvider] Consolidate se23 logic #10635

Merged
merged 4 commits into from
Sep 22, 2023
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
5 changes: 5 additions & 0 deletions .changeset/short-kids-buy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/polaris': major
---

Removed `polarisSummerEditions2023` feature flag from AppProvider context
8 changes: 1 addition & 7 deletions polaris-react/.storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,7 @@ function AppProviderDecorator(Story, context) {
if (context.args.omitAppProvider) return <Story {...context} />;

return (
<AppProvider
theme={context.globals.theme}
features={{
polarisSummerEditions2023: true,
}}
i18n={enTranslations}
>
<AppProvider theme={context.globals.theme} i18n={enTranslations}>
<FrameContext.Provider value={{}}>
<Story {...context} />
</FrameContext.Provider>
Expand Down
14 changes: 1 addition & 13 deletions polaris-react/src/components/AppProvider/AppProvider.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ export function Default(_, context) {
},
},
}}
features={{
polarisSummerEditions2023: true,
}}
>
<Page>
<LegacyCard>
Expand Down Expand Up @@ -97,9 +94,6 @@ export function WithI18n(_, context) {
},
},
}}
features={{
polarisSummerEditions2023: true,
}}
>
<Page>
<LegacyCard>
Expand Down Expand Up @@ -155,13 +149,7 @@ export function WithLinkComponent(_, context) {
};

return (
<AppProvider
linkComponent={CustomLinkComponent}
i18n={{}}
features={{
polarisSummerEditions2023: true,
}}
>
<AppProvider linkComponent={CustomLinkComponent} i18n={{}}>
<Page
backAction={{content: 'Products', url: '#'}}
title="Jar With Lock-Lid"
Expand Down
12 changes: 1 addition & 11 deletions polaris-react/src/components/AppProvider/AppProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,20 +148,10 @@ export class AppProvider extends Component<AppProviderProps, State> {
document.documentElement.classList.add(classNamePolarisSummerEditions2023);
};

getFeatures = () => {
const {features} = this.props;

return {
...features,
polarisSummerEditions2023: features?.polarisSummerEditions2023 ?? true,
};
};

getThemeName = (): ThemeName => this.props.theme ?? themeNameDefault;

render() {
const {children} = this.props;
const features = this.getFeatures();
const {children, features} = this.props;
const themeName = this.getThemeName();

const {intl, link} = this.state;
Expand Down
3 changes: 0 additions & 3 deletions polaris-react/src/components/Frame/Frame.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,6 @@ function InAnApplicationComponent() {
},
},
}}
features={{polarisSummerEditions2023: true}}
>
<Frame
logo={logo}
Expand Down Expand Up @@ -701,7 +700,6 @@ function WithAnOffsetComponent() {
},
},
}}
features={{polarisSummerEditions2023: true}}
>
<Frame
logo={logo}
Expand Down Expand Up @@ -1060,7 +1058,6 @@ function WithSidebarEnabled() {
},
},
}}
features={{polarisSummerEditions2023: true}}
>
<Frame
logo={logo}
Expand Down
8 changes: 4 additions & 4 deletions polaris-react/src/components/IndexTable/IndexTable.scss
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ $loading-panel-height: 53px;

// This is to bust specificity with .Table-scrolling and TableCell:first-child or TableCell:first-child + TableCell bg color above.
.TableRow-subdued {
// stylelint-disable-next-line selector-max-class, selector-max-combinators, selector-max-specificity, selector-max-compound-selectors -- se23 overrides
// stylelint-disable-next-line selector-max-class, selector-max-combinators, selector-max-specificity, selector-max-compound-selectors -- bg color overrides
.TableCell-first,
.TableCell-first + .TableCell {
background-color: var(--p-color-bg-subdued);
Expand Down Expand Up @@ -209,7 +209,7 @@ $loading-panel-height: 53px;

// NOTE: `-hovered` must come after `-selected` so elements don't appear to lose their interactivity when selected.
&.TableRow-hovered {
// stylelint-disable selector-max-class, selector-max-specificity, selector-max-combinators -- se23 status hover styles
// stylelint-disable selector-max-class, selector-max-specificity, selector-max-combinators -- status hover styles
&,
.TableCell-first,
.TableCell-first + .TableCell {
Expand Down Expand Up @@ -247,7 +247,7 @@ $loading-panel-height: 53px;
background-color: var(--p-color-bg-subdued-hover);
}
}
// stylelint-enable selector-max-class, selector-max-specificity, selector-max-combinators -- se23 status hover styles
// stylelint-enable selector-max-class, selector-max-specificity, selector-max-combinators -- status hover styles
}

// stylelint-disable-next-line selector-max-class -- generated by polaris-migrator DO NOT COPY
Expand Down Expand Up @@ -653,7 +653,7 @@ $loading-panel-height: 53px;
}
// This is to bust specificity with Table-unselectable and TableCel:first-child bg color above.
.TableRow-subdued:not(.TableRow-hovered) {
// stylelint-disable-next-line selector-max-class, selector-max-combinators, selector-max-specificity -- se23 override
// stylelint-disable-next-line selector-max-class, selector-max-combinators, selector-max-specificity -- bg color override
.TableCell:first-child {
background-color: var(--p-color-bg-subdued);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,6 @@ describe('<Pagination />', () => {
label="Hello, world!"
type="page"
/>,
{features: {polarisSummerEditions2023: false}},
);

expect(pagination).toContainReactComponent(ButtonGroup, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,21 +65,13 @@ export function PolarisTestProvider({

const stickyManager = useMemo(() => new StickyManager(), []);

const featuresConfig = useMemo(
() => ({
polarisSummerEditions2023: true,
...features,
}),
[features],
);

const mergedFrame = createFrameContext(frame);

const mergedMediaQuery = merge(defaultMediaQuery, mediaQuery);

return (
<Wrapper>
<FeaturesContext.Provider value={featuresConfig}>
<FeaturesContext.Provider value={features}>
<I18nContext.Provider value={intl}>
<ScrollLockManagerContext.Provider value={scrollLockManager}>
<StickyManagerContext.Provider value={stickyManager}>
Expand Down
2 changes: 2 additions & 0 deletions polaris-react/src/styles/_common.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@
// tag+attribute selector.
// However, we're still supporting iOS 12 for embedded web views in some apps, which
// unfortunately doesn't support :where https://caniuse.com/?search=%3Awhere

// 馃毃 WARNING: Refrain from using the `se23` flag, this will be deprecated post v12.
$se23: 'html[class~="Polaris-Summer-Editions-2023"]';
1 change: 0 additions & 1 deletion polaris-react/src/utilities/features/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export interface FeaturesConfig {
polarisSummerEditions2023?: boolean;
[key: string]: boolean | undefined;
}

Expand Down
11 changes: 2 additions & 9 deletions polaris-react/tests/utilities/react-testing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,9 @@ export const mountWithApp = createMount<
return options;
},
render(element, context) {
const {features, ...rest} = context;
const {...rest} = context;
return (
<PolarisTestProvider
i18n={translations}
features={{
polarisSummerEditions2023: true,
...features,
}}
{...rest}
>
<PolarisTestProvider i18n={translations} {...rest}>
{element}
</PolarisTestProvider>
);
Expand Down