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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: remove roundedCornersOptOut feature flag #7070

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
13 changes: 0 additions & 13 deletions .storybook/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,6 @@ const globalTypes = {
],
},
},
roundedCorners: {
name: "Rounded Corners",
description: "Toggle rounded corner opt out",
defaultValue: "on",
toolbar: {
icon: "circlehollow",
title: "Rounded corners",
items: [
{ value: "on", title: "On" },
{ value: "off", title: "Off" },
],
},
},
focusRedesign: {
name: "Double focus style",
description: "Toggle the focus styling redesign",
Expand Down
16 changes: 4 additions & 12 deletions .storybook/withThemeProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,9 @@ if (process.env.STORYBOOK_DEBUG_THEME === "true") {
themes["sage-debug"] = sageDebugTheme;
}

const render = (
Story,
themeName,
roundedCornersOptOut,
focusRedesignOptOut
) => (
const render = (Story, themeName, focusRedesignOptOut) => (
<CarbonProvider
theme={themes[themeName]}
roundedCornersOptOut={roundedCornersOptOut}
focusRedesignOptOut={focusRedesignOptOut}
>
<Story themeName={themeName} />
Expand All @@ -50,7 +44,7 @@ const withThemeProvider = makeDecorator({
fourColumnLayout: false,
},
},
}
},
) => {
const { theme: chromaticTheme, fourColumnLayout } = parameters.chromatic;
const isChromaticBuild = isChromatic();
Expand All @@ -68,8 +62,7 @@ const withThemeProvider = makeDecorator({
{render(
Story,
themeName,
context.globals.roundedCorners === "off",
context.globals.focusRedesign === "off"
context.globals.focusRedesign === "off",
)}
</div>
))}
Expand All @@ -82,8 +75,7 @@ const withThemeProvider = makeDecorator({
isChromaticBuild && chromaticTheme
? chromaticTheme
: context.globals.theme,
context.globals.roundedCorners === "off",
context.globals.focusRedesign === "off"
context.globals.focusRedesign === "off",
);
},
});
Expand Down
3 changes: 0 additions & 3 deletions playwright/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import "../src/style/fonts.css";
import * as dateLocales from "./support/date-fns-locales";

export type HooksConfig = {
roundedCornersOptOut?: boolean;
focusRedesignOptOut?: boolean;
validationRedesignOptIn?: boolean;
theme?: string;
Expand Down Expand Up @@ -43,7 +42,6 @@ const mountedTheme = (theme: string) => {
// Setup required providers on mounted component before running test. See https://playwright.dev/docs/test-components#hooks
beforeMount<HooksConfig>(async ({ App, hooksConfig }) => {
const {
roundedCornersOptOut,
focusRedesignOptOut,
theme = "sage",
localeName,
Expand All @@ -52,7 +50,6 @@ beforeMount<HooksConfig>(async ({ App, hooksConfig }) => {
return (
<CarbonProvider
theme={mountedTheme(theme)}
roundedCornersOptOut={roundedCornersOptOut}
focusRedesignOptOut={focusRedesignOptOut}
validationRedesignOptIn={validationRedesignOptIn}
>
Expand Down
7 changes: 2 additions & 5 deletions src/components/box/box.style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,8 @@ const StyledBox = styled.div<BoxProps>`
${grid}
${calculatePosition}

${({ theme, borderRadius = "borderRadius000" }) =>
!theme.roundedCornersOptOut &&
css`
border-radius: var(--${borderRadius});
`}
${({ borderRadius = "borderRadius000" }) =>
`border-radius: var(--${borderRadius});`}

${({ color, bg, backgroundColor, ...rest }) =>
styledColor({ color, bg, backgroundColor, ...rest })}
Expand Down
13 changes: 1 addition & 12 deletions src/components/button-minor/button-minor.pw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,25 +91,14 @@ test.describe("check Focus Outline & Border Radius for Button Minor Component",
await expect(outlined).toHaveCSS("outline", "rgb(255, 188, 25) solid 3px");
});

test("should have the expected styling when roundedCornersOptOut is false", async ({
test("should have the expected border radius styling", async ({
mount,
page,
}) => {
await mount(<ButtonMinor>Foo</ButtonMinor>);

await expect(buttonMinorComponent(page)).toHaveCSS("border-radius", "4px");
});

test("should have the expected styling when roundedCornersOptOut is true", async ({
mount,
page,
}) => {
await mount<HooksConfig>(<ButtonMinor>Foo</ButtonMinor>, {
hooksConfig: { roundedCornersOptOut: true },
});

await expect(buttonMinorComponent(page)).toHaveCSS(`border-radius`, "0px");
});
});

test.describe("Check props for Button Minor component", () => {
Expand Down
24 changes: 6 additions & 18 deletions src/components/button/button.pw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -294,24 +294,12 @@ test.describe("When focused", () => {
});
});

test.describe("Border radius", () => {
test("should have the expected styling when roundedCornersOptOut is false", async ({
mount,
page,
}) => {
await mount(<Button>Foo</Button>);
await expect(buttonDataComponent(page)).toHaveCSS(`border-radius`, "32px");
});

test("should have the expected styling when roundedCornersOptOut is true", async ({
mount,
page,
}) => {
await mount<HooksConfig>(<Button>Foo</Button>, {
hooksConfig: { roundedCornersOptOut: true },
});
await expect(buttonDataComponent(page)).toHaveCSS(`border-radius`, "0px");
});
test("should have the expected border radius styling", async ({
mount,
page,
}) => {
await mount(<Button>Foo</Button>);
await expect(buttonDataComponent(page)).toHaveCSS(`border-radius`, "32px");
});

test.describe("Accessibility tests for Button", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ export interface NewValidationContextProps {
*
* NOTE - Will eventually be set to `true` by default in the future. */
validationRedesignOptIn?: boolean;
/** (Deprecated) Feature flag for opting out of styling components to have rounded corners.
*
* NOTE - This feature flag will soon be removed, along with the legacy styling. */
roundedCornersOptOut?: boolean;
/** (Deprecated) Feature flag for opting out of the focus redesign.
*
* NOTE - This feature flag will soon be removed, along with the legacy styling. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ const meta: Meta<typeof CarbonProvider> = {
validationRedesignOptIn: {
control: false,
},
roundedCornersOptOut: {
control: false,
},
},
parameters: {
themeProvider: { chromatic: { theme: "sage" } },
Expand Down
20 changes: 2 additions & 18 deletions src/components/carbon-provider/carbon-provider.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,34 +18,20 @@ export interface CarbonProviderProps extends NewValidationContextProps {
theme?: Partial<ThemeObject>;
}

let deprecatedRoundedCornersOptOut = false;
let deprecatedFocusRedesignOptOut = false;

export const CarbonProvider = ({
children,
theme = sageTheme,
validationRedesignOptIn = false,
roundedCornersOptOut = false,
focusRedesignOptOut = false,
}: CarbonProviderProps) => {
const {
roundedCornersOptOut: existingRoundedCornersOptOut,
focusRedesignOptOut: existingFocusRedesignOptOut,
} = useContext(NewValidationContext);
const { focusRedesignOptOut: existingFocusRedesignOptOut } =
useContext(NewValidationContext);

const roundedCornersOptOutValue =
existingRoundedCornersOptOut || roundedCornersOptOut;
const focusRedesignOptOutValue =
existingFocusRedesignOptOut || focusRedesignOptOut;

if (!deprecatedRoundedCornersOptOut && roundedCornersOptOutValue) {
deprecatedRoundedCornersOptOut = true;
Logger.deprecate(
"The `roundedCornersOptOut` feature flag has been deprecated and will soon be removed. " +
"Along with this feature flag, the legacy pre-rounded corners styling will also be removed. ",
);
}

if (!deprecatedFocusRedesignOptOut && focusRedesignOptOutValue) {
deprecatedFocusRedesignOptOut = true;
Logger.deprecate(
Expand All @@ -58,15 +44,13 @@ export const CarbonProvider = ({
<ThemeProvider
theme={{
...theme,
roundedCornersOptOut: roundedCornersOptOutValue,
focusRedesignOptOut: focusRedesignOptOutValue,
}}
>
<CarbonScopedTokensProvider>
<NewValidationContext.Provider
value={{
validationRedesignOptIn,
roundedCornersOptOut: roundedCornersOptOutValue,
}}
>
<TopModalProvider>{children}</TopModalProvider>
Expand Down
24 changes: 0 additions & 24 deletions src/components/carbon-provider/carbon-provider.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,6 @@ import { render } from "@testing-library/react";
import CarbonProvider from ".";
import Logger from "../../__internal__/utils/logger";

test("logs a deprecation warning once when the `roundedCornersOptOut` feature flag is `true`", () => {
const loggerSpy = jest
.spyOn(Logger, "deprecate")
.mockImplementation(() => {});

render(
<>
<CarbonProvider roundedCornersOptOut>
<CarbonProvider>Hello World!</CarbonProvider>
</CarbonProvider>
<CarbonProvider roundedCornersOptOut>
<CarbonProvider>Hello World!</CarbonProvider>
</CarbonProvider>
</>,
);

expect(loggerSpy).toHaveBeenCalledWith(
"The `roundedCornersOptOut` feature flag has been deprecated and will soon be removed. " +
"Along with this feature flag, the legacy pre-rounded corners styling will also be removed. ",
);
expect(loggerSpy).toHaveBeenCalledTimes(1);
loggerSpy.mockRestore();
});

test("logs a deprecation warning once when the `focusRedesignOptOut` feature flag is `true`", () => {
const loggerSpy = jest
.spyOn(Logger, "deprecate")
Expand Down
11 changes: 3 additions & 8 deletions src/components/loader/loader-square.style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,7 @@ const loaderAnimation = keyframes`
}
`;

type RoundedCornersOptOut = boolean;

const getDimentions = (
size: StyledLoaderSquareProps["size"],
roundedCornersOptOut: RoundedCornersOptOut,
) => {
const getDimentions = (size: StyledLoaderSquareProps["size"]) => {
let width;
let marginRight;

Expand All @@ -50,7 +45,6 @@ const getDimentions = (
width: ${width};
height: ${width};
margin-right: ${marginRight};
${!roundedCornersOptOut && "border-radius: var(--borderRadiusCircle);"}
`;
};

Expand All @@ -59,7 +53,8 @@ const StyledLoaderSquare = styled.div<StyledLoaderSquareProps>`
animation: ${loaderAnimation} 1s infinite ease-in-out both;
background-color: ${backgroundColor};
display: inline-block;
${getDimentions(size, theme.roundedCornersOptOut)}
${getDimentions(size)}
border-radius: var(--borderRadiusCircle);

${isInsideButton &&
css`
Expand Down
4 changes: 1 addition & 3 deletions src/components/loader/loader.pw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,7 @@ test.describe("check props for Loader component test", () => {
mount,
page,
}) => {
await mount<HooksConfig>(<Loader />, {
hooksConfig: { roundedCornersOptOut: false },
});
await mount(<Loader />);

const borderRadius = await getStyle(loader(page, 0), "border-radius");

Expand Down
Loading
Loading