From 4af29befaae0eacad05338dda57b21899cc71a09 Mon Sep 17 00:00:00 2001 From: Jon Rohan Date: Tue, 17 Sep 2024 17:30:47 +0000 Subject: [PATCH 1/2] Removing the css modules feature flag from blankslate --- e2e/components/Blankslate.test.ts | 54 ----- packages/react/src/Blankslate/Blankslate.tsx | 197 ++----------------- 2 files changed, 15 insertions(+), 236 deletions(-) diff --git a/e2e/components/Blankslate.test.ts b/e2e/components/Blankslate.test.ts index c10bd2f4e40..cd6ced7ce44 100644 --- a/e2e/components/Blankslate.test.ts +++ b/e2e/components/Blankslate.test.ts @@ -51,24 +51,6 @@ test.describe('Blankslate', () => { id: story.id, globals: { colorScheme: theme, - featureFlags: { - primer_react_css_modules_ga: true, - }, - }, - }) - - // Default state - expect(await page.screenshot()).toMatchSnapshot(`Blankslate.${story.title}.${theme}.png`) - }) - - test('default (styled-components) @vrt', async ({page}) => { - await visit(page, { - id: story.id, - globals: { - colorScheme: theme, - featureFlags: { - primer_react_css_modules_ga: false, - }, }, }) @@ -77,19 +59,6 @@ test.describe('Blankslate', () => { }) test('axe @aat', async ({page}) => { - await visit(page, { - id: story.id, - globals: { - colorScheme: theme, - featureFlags: { - primer_react_css_modules_ga: true, - }, - }, - }) - await expect(page).toHaveNoViolations() - }) - - test('axe (styled-components) @aat', async ({page}) => { await visit(page, { id: story.id, globals: { @@ -106,29 +75,6 @@ test.describe('Blankslate', () => { test(`${name} @vrt`, async ({page}) => { await visit(page, { id: story.id, - globals: { - featureFlags: { - primer_react_css_modules_ga: true, - }, - }, - }) - const width = viewports[name] - - await page.setViewportSize({ - width, - height: 667, - }) - expect(await page.screenshot()).toMatchSnapshot(`Blankslate.${story.title}.${name}.png`) - }) - - test(`${name} (styled-components) @vrt`, async ({page}) => { - await visit(page, { - id: story.id, - globals: { - featureFlags: { - primer_react_css_modules_ga: false, - }, - }, }) const width = viewports[name] diff --git a/packages/react/src/Blankslate/Blankslate.tsx b/packages/react/src/Blankslate/Blankslate.tsx index 60e1b93e37b..6c756d7fea6 100644 --- a/packages/react/src/Blankslate/Blankslate.tsx +++ b/packages/react/src/Blankslate/Blankslate.tsx @@ -1,12 +1,8 @@ import {clsx} from 'clsx' import React from 'react' -import Box from '../Box' import {Button} from '../Button' import Link from '../Link' -import {get} from '../constants' -import styled from 'styled-components' import classes from './Blankslate.module.css' -import {useFeatureFlag} from '../FeatureFlags' export type BlankslateProps = React.PropsWithChildren<{ /** @@ -27,159 +23,25 @@ export type BlankslateProps = React.PropsWithChildren<{ className?: string }> -const StyledBlankslate = styled.div` - container-type: inline-size; - - .Blankslate { - --blankslate-outer-padding-block: var(--base-size-32, 2rem); - --blankslate-outer-padding-inline: var(--base-size-32, 2rem); - - display: grid; - justify-items: center; - padding: var(--blankslate-outer-padding-block) var(--blankslate-outer-padding-inline); - } - - .Blankslate[data-spacious='true'] { - --blankslate-outer-padding-block: var(--base-size-80, 5rem); - --blankslate-outer-padding-inline: var(--base-size-40, 2.5rem); - } - - .Blankslate[data-border='true'] { - border: var(--borderWidth-thin) solid var(--borderColor-default, ${get('colors.border.default')}); - border-radius: var(--borderRadius-medium); - } - - .Blankslate[data-narrow='true'] { - margin: 0 auto; - max-width: 485px; - } - - .Blankslate-Heading, - .Blankslate-Description { - margin: 0; - margin-bottom: var(--stack-gap-condensed, 0.5rem); - } - - .Blankslate-Heading { - font-size: var(--text-title-size-medium, 1.25rem); - font-weight: var(--text-title-weight-medium, 600); - } - - .Blankslate-Description { - color: var(--fgColor-muted, ${get('colors.fg.muted')}); - font-size: var(--text-body-size-large, 1rem); - line-height: var(--text-body-lineHeight-large, 1.5); - } - - .Blankslate-Action { - margin-top: var(--stack-gap-normal, 1rem); - } - - .Blankslate-Action:first-of-type { - margin-top: var(--stack-gap-spacious, 1.5rem); - } - - .Blankslate-Action:last-of-type { - margin-bottom: var(--stack-gap-condensed, 0.5rem); - } -` - -const BlankslateContainerQuery = ` - /* At the time these styles were written, - 34rem was our "small" breakpoint width */ - @container (max-width: 34rem) { - ${StyledBlankslate} .Blankslate { - --blankslate-outer-padding-block: var(--base-size-20); - --blankslate-outer-padding-inline: var(--base-size-20); - } - - ${StyledBlankslate} .Blankslate[data-spacious='true'] { - --blankslate-outer-padding-block: var(--base-size-44); - --blankslate-outer-padding-inline: var(--base-size-28); - } - - ${StyledBlankslate} .Blankslate-Visual { - margin-bottom: var(--stack-gap-condensed, 0.5rem); - max-width: var(--base-size-24); - } - - ${StyledBlankslate} .Blankslate-Visual svg { - width: 100%; - } - - ${StyledBlankslate} .Blankslate-Heading { - font-size: var(--text-title-size-small); - } - - ${StyledBlankslate} .Blankslate-Description { - font-size: var(--text-body-size-medium); - } - - ${StyledBlankslate} .Blankslate-Action { - margin-top: var(--stack-gap-condensed, 0.5rem); - } - - ${StyledBlankslate} .Blankslate-Action:first-of-type { - margin-top: var(--stack-gap-normal, 1rem); - } - - ${StyledBlankslate} .Blankslate-Action:last-of-type { - margin-bottom: calc(var(--stack-gap-condensed, 0.5rem) / 2); - } -` - function Blankslate({border, children, narrow, spacious, className}: BlankslateProps) { - const enabled = useFeatureFlag('primer_react_css_modules_ga') - - if (enabled) { - return ( -
-
- {children} -
-
- ) - } - return ( - <> - {/* - This is a workaround so we can use `@container` without upgrading `styled-components` to 6.x - See [this comment](https://github.com/primer/react/pull/3869#discussion_r1392523030) for more info - */} -