diff --git a/cypress/components/button-toggle/button-toggle.cy.tsx b/cypress/components/button-toggle/button-toggle.cy.tsx index 47e4c24c4a..4c2ac7a99e 100644 --- a/cypress/components/button-toggle/button-toggle.cy.tsx +++ b/cypress/components/button-toggle/button-toggle.cy.tsx @@ -94,40 +94,6 @@ context("Testing Button-Toggle component", () => { }); }); - describe("rounded corners", () => { - it("has the expected border-radius styling on a single toggle button", () => { - CypressMountWithProviders( - Foo - ); - - buttonToggleButton().each((el) => - expect(el.css("border-radius")).equals("32px") - ); - }); - - it("should have the expected border-radius styling when the children have the grouped prop set", () => { - CypressMountWithProviders( - - ); - - buttonToggleButton() - .eq(0) - .should("have.css", "border-radius", "32px 0px 0px 32px"); - buttonToggleButton().eq(1).should("have.css", "border-radius", "0px"); - buttonToggleButton() - .eq(2) - .should("have.css", "border-radius", "0px 32px 32px 0px"); - }); - - it("should have the expected border-radius styling when children do not have grouped prop set", () => { - CypressMountWithProviders(); - - buttonToggleButton().eq(0).should("have.css", "border-radius", "32px"); - buttonToggleButton().eq(1).should("have.css", "border-radius", "32px"); - buttonToggleButton().eq(2).should("have.css", "border-radius", "32px"); - }); - }); - it("should render Button-Toggle with aria-label prop", () => { CypressMountWithProviders( diff --git a/src/components/button-toggle/__snapshots__/button-toggle.spec.tsx.snap b/src/components/button-toggle/__snapshots__/button-toggle.spec.tsx.snap index 306174ae3c..def17dae9e 100644 --- a/src/components/button-toggle/__snapshots__/button-toggle.spec.tsx.snap +++ b/src/components/button-toggle/__snapshots__/button-toggle.spec.tsx.snap @@ -26,6 +26,8 @@ exports[`ButtonToggle General styling renders correctly when grouped 1`] = ` text-align: start; color: inherit; border: 1px solid var(--colorsActionMinor500); + color: var(--colorsActionMinor500); + border: 1px solid var(--colorsActionMinor500); } .c2:focus { @@ -56,8 +58,43 @@ exports[`ButtonToggle General styling renders correctly when grouped 1`] = ` color: var(--colorsActionMinor500); } +.c2 .c4 { + color: var(--colorsActionMinor500); +} + +.c2 .c4:not([aria-pressed="true"]):not(:disabled):hover { + color: var(--colorsActionMinorYang100); +} + +.c2:not([aria-pressed="true"]):not(:disabled):hover { + color: var(--colorsActionMinorYang100); + background-color: var(--colorsActionMinor600); +} + +.c2:not([aria-pressed="true"]):not(:disabled):hover .c4 { + color: var(--colorsActionMinorYang100); +} + +.c2:not(:disabled):hover { + background-color: var(--colorsActionMinor600); + color: var(--colorsActionMinorYang100); +} + +.c2:not(:disabled):hover .c4 { + color: var(--colorsActionMinorYang100); +} + +.c2[aria-pressed="true"]:not(:hover) { + box-shadow: inset 0px 0px 0px 3px var(--colorsActionMinor500); + background-color: transparent; +} + +.c2[aria-pressed="true"]:not(:hover):focus { + box-shadow: inset 0px 0px 0px 3px var(--colorsActionMinor500), 0px 0px 0px var(--borderWidth300) var(--colorsSemanticFocus500), 0px 0px 0px var(--borderWidth600) var(--colorsUtilityYin090); +} + .c3.c3.c3.c3 .c1 { - border-radius: var(--borderRadius400); + border-radius: var(--borderRadius050); } .c0 { @@ -66,13 +103,13 @@ exports[`ButtonToggle General styling renders correctly when grouped 1`] = ` } .c0.c0.c0.c0:first-of-type .c1 { - border-top-left-radius: var(--borderRadius400); - border-bottom-left-radius: var(--borderRadius400); + border-top-left-radius: var(--borderRadius050); + border-bottom-left-radius: var(--borderRadius050); } .c0.c0.c0.c0:last-of-type .c1 { - border-top-right-radius: var(--borderRadius400); - border-bottom-right-radius: var(--borderRadius400); + border-top-right-radius: var(--borderRadius050); + border-bottom-right-radius: var(--borderRadius050); } .c0:not(:first-of-type) { diff --git a/src/components/button-toggle/button-toggle-group/button-toggle-group.stories.tsx b/src/components/button-toggle/button-toggle-group/button-toggle-group.stories.tsx index 7e1333d6bb..d3b5e4a357 100644 --- a/src/components/button-toggle/button-toggle-group/button-toggle-group.stories.tsx +++ b/src/components/button-toggle/button-toggle-group/button-toggle-group.stories.tsx @@ -64,6 +64,27 @@ export const Grouped: ComponentStory = () => ( ); +export const GroupedMinor: ComponentStory = () => ( + {}} + > + + Foo + + + Bar + + + Baz + + +); + export const FullWidth: ComponentStory = () => ( { ); }; +export const ButtonToggleGroupMinorStory = () => { + const [value, setValue] = useState("bar"); + function onChangeHandler( + event: React.MouseEvent, + selectedButtonValue?: string + ) { + setValue(selectedButtonValue); + action("value set")(selectedButtonValue); + } + return ( + >>>>>> 8c445eebb (feat(button-toggle): add minor child) +======= +>>>>>>> 71a7991e9 (feat(button-toggle): rm variant prop, tests) +>>>>>>> df20abe7b (feat(button-toggle): rm variant prop) + > + Foo + Bar + Baz + + ); +}; + export const WithoutGroup = (args: Partial) => (
{ buttonRef.current = element; if (childButtonCallbackRef) { diff --git a/src/components/button-toggle/button-toggle.spec.tsx b/src/components/button-toggle/button-toggle.spec.tsx index 061990a31f..13584e53e7 100644 --- a/src/components/button-toggle/button-toggle.spec.tsx +++ b/src/components/button-toggle/button-toggle.spec.tsx @@ -10,7 +10,6 @@ import { StyledButtonToggleIcon, ButtonToggleIconSizes, StyledButtonToggle, - StyledButtonToggleWrapper, } from "./button-toggle.style"; import { InputGroupContext } from "../../__internal__/input-behaviour"; import { ThemeObject } from "../../style/themes/base"; @@ -396,16 +395,4 @@ describe("ButtonToggle", () => { describe("coverage filler for else path", () => { mount(toggle); }); - - it("renders with the expected border radius styling", () => { - assertStyleMatch( - { - borderRadius: "var(--borderRadius400)", - }, - mount(toggle).find( - StyledButtonToggleWrapper - ), - { modifier: `&&&& ${StyledButtonToggle}` } - ); - }); }); diff --git a/src/components/button-toggle/button-toggle.stories.mdx b/src/components/button-toggle/button-toggle.stories.mdx index 2b63e210aa..b82fcf5a80 100644 --- a/src/components/button-toggle/button-toggle.stories.mdx +++ b/src/components/button-toggle/button-toggle.stories.mdx @@ -6,7 +6,7 @@ import { ButtonToggle } from "."; import * as stories from "./button-toggle.stories"; import * as groupStories from "./button-toggle-group/button-toggle-group.stories"; - Product Design System component @@ -35,7 +35,10 @@ Press one of the buttons to make selection. This component should be used when u ## Quick Start ```javascript -import { ButtonToggle, ButtonToggleGroup } from "carbon-react/lib/components/button-toggle"; +import { + ButtonToggle, + ButtonToggleGroup, +} from "carbon-react/lib/components/button-toggle"; ``` - You should use the ButtonToggleGroup component if you need to wrap multiple `ButtonToggle` components together. diff --git a/src/components/button-toggle/button-toggle.stories.tsx b/src/components/button-toggle/button-toggle.stories.tsx index 29d57c7c82..3dc418350b 100644 --- a/src/components/button-toggle/button-toggle.stories.tsx +++ b/src/components/button-toggle/button-toggle.stories.tsx @@ -2,7 +2,6 @@ import React from "react"; import { ComponentStory } from "@storybook/react"; import { ButtonToggle, ButtonToggleGroup } from "."; -import Box from "../box"; export const Default: ComponentStory = () => ( @@ -13,16 +12,14 @@ export const Default: ComponentStory = () => ( ); export const DefaultWrappedText: ComponentStory = () => ( - - - - Some text that wraps - - - FooBar - - - + + + Some text that wraps + + + FooBar + + ); export const DefaultSmallIcon: ComponentStory = () => ( diff --git a/src/components/button-toggle/button-toggle.style.ts b/src/components/button-toggle/button-toggle.style.ts index 18e4f008dc..12b3ffee14 100644 --- a/src/components/button-toggle/button-toggle.style.ts +++ b/src/components/button-toggle/button-toggle.style.ts @@ -136,7 +136,114 @@ const StyledButtonToggle = styled.button` } } cursor: not-allowed; - `}; + `} + +<<<<<<< HEAD + +======= +<<<<<<< HEAD +<<<<<<< HEAD + + & ${StyledIcon} { + color: var(--colorsActionMinor500); + :not([aria-pressed="true"]):not(:disabled):hover { + color: var(--colorsActionMinorYang100); + } + } + + color: var(--colorsActionMinor500); + border: 1px solid var(--colorsActionMinor500); + + :not([aria-pressed="true"]):not(:disabled):hover { + color: var(--colorsActionMinorYang100); + background-color: var(--colorsActionMinor600); + ${StyledIcon} { + color: var(--colorsActionMinorYang100); + } + } + + &:not(:disabled):hover { + background-color: var(--colorsActionMinor600); + color: var(--colorsActionMinorYang100); + + ${StyledIcon} { + color: var(--colorsActionMinorYang100); + } + } + + &[aria-pressed="true"]:not(:hover) { + box-shadow: inset 0px 0px 0px 3px var(--colorsActionMinor500); + background-color: transparent; + :focus { + box-shadow: inset 0px 0px 0px 3px var(--colorsActionMinor500), + 0px 0px 0px var(--borderWidth300) var(--colorsSemanticFocus500), + 0px 0px 0px var(--borderWidth600) var(--colorsUtilityYin090); + } + } +======= + ${({ variant }) => + variant === "minor" && + css` +======= + +>>>>>>> 0a84e5447 (feat(button-toggle): rm variant prop) +>>>>>>> df20abe7b (feat(button-toggle): rm variant prop) + & ${StyledIcon} { + color: var(--colorsActionMinor500); + :not([aria-pressed="true"]):not(:disabled):hover { + color: var(--colorsActionMinorYang100); + } + } + + color: var(--colorsActionMinor500); + border: 1px solid var(--colorsActionMinor500); + + :not([aria-pressed="true"]):not(:disabled):hover { + color: var(--colorsActionMinorYang100); + background-color: var(--colorsActionMinor600); + ${StyledIcon} { + color: var(--colorsActionMinorYang100); + } + } + + &:not(:disabled):hover { + background-color: var(--colorsActionMinor600); + color: var(--colorsActionMinorYang100); + + ${StyledIcon} { + color: var(--colorsActionMinorYang100); + } + } + +<<<<<<< HEAD +======= +<<<<<<< HEAD + &[aria-pressed="true"]:not(:hover) { + box-shadow: inset 0px 0px 0px 3px var(--colorsActionMinor500); + background-color: transparent; + :focus { + box-shadow: inset 0px 0px 0px 3px var(--colorsActionMinor500), + 0px 0px 0px var(--borderWidth300) var(--colorsSemanticFocus500), + 0px 0px 0px var(--borderWidth600) var(--colorsUtilityYin090); + } + } + `} +>>>>>>> 8c445eebb (feat(button-toggle): add minor child) +======= +>>>>>>> df20abe7b (feat(button-toggle): rm variant prop) + &[aria-pressed="true"]:not(:hover) { + box-shadow: inset 0px 0px 0px 3px var(--colorsActionMinor500); + background-color: transparent; + :focus { + box-shadow: inset 0px 0px 0px 3px var(--colorsActionMinor500), + 0px 0px 0px var(--borderWidth300) var(--colorsSemanticFocus500), + 0px 0px 0px var(--borderWidth600) var(--colorsUtilityYin090); + } + } +<<<<<<< HEAD +======= +>>>>>>> 0a84e5447 (feat(button-toggle): rm variant prop) +>>>>>>> df20abe7b (feat(button-toggle): rm variant prop) `; const iconFontSizes = { @@ -188,7 +295,21 @@ const StyledButtonToggleWrapper = styled.div` css` &&&& { ${StyledButtonToggle} { - border-radius: var(--borderRadius400); +<<<<<<< HEAD + border-radius: var(--borderRadius050); +======= +<<<<<<< HEAD +<<<<<<< HEAD + border-radius: var(--borderRadius050); +======= + border-radius: ${variant === "minor" + ? "var(--borderRadius050)" + : "var(--borderRadius400)"}; +>>>>>>> 8c445eebb (feat(button-toggle): add minor child) +======= + border-radius: var(--borderRadius050); +>>>>>>> 0a84e5447 (feat(button-toggle): rm variant prop) +>>>>>>> df20abe7b (feat(button-toggle): rm variant prop) } } `} @@ -198,15 +319,53 @@ const StyledButtonToggleWrapper = styled.div` &&&& { :first-of-type { ${StyledButtonToggle} { - border-top-left-radius: var(--borderRadius400); - border-bottom-left-radius: var(--borderRadius400); +<<<<<<< HEAD + border-top-left-radius: var(--borderRadius050); + border-bottom-left-radius: var(--borderRadius050); +======= +<<<<<<< HEAD +<<<<<<< HEAD + border-top-left-radius: var(--borderRadius050); + border-bottom-left-radius: var(--borderRadius050); +======= + border-top-left-radius: ${variant === "minor" + ? "var(--borderRadius050)" + : "var(--borderRadius400)"}; + border-bottom-left-radius: ${variant === "minor" + ? "var(--borderRadius050)" + : "var(--borderRadius400)"}; +>>>>>>> 8c445eebb (feat(button-toggle): add minor child) +======= + border-top-left-radius: var(--borderRadius050); + border-bottom-left-radius: var(--borderRadius050); +>>>>>>> 0a84e5447 (feat(button-toggle): rm variant prop) +>>>>>>> df20abe7b (feat(button-toggle): rm variant prop) } } :last-of-type { ${StyledButtonToggle} { - border-top-right-radius: var(--borderRadius400); - border-bottom-right-radius: var(--borderRadius400); +<<<<<<< HEAD + border-top-right-radius: var(--borderRadius050); + border-bottom-right-radius: var(--borderRadius050); +======= +<<<<<<< HEAD +<<<<<<< HEAD + border-top-right-radius: var(--borderRadius050); + border-bottom-right-radius: var(--borderRadius050); +======= + border-top-right-radius: ${variant === "minor" + ? "var(--borderRadius050)" + : "var(--borderRadius400)"}; + border-bottom-right-radius: ${variant === "minor" + ? "var(--borderRadius050)" + : "var(--borderRadius400)"}; +>>>>>>> 8c445eebb (feat(button-toggle): add minor child) +======= + border-top-right-radius: var(--borderRadius050); + border-bottom-right-radius: var(--borderRadius050); +>>>>>>> 0a84e5447 (feat(button-toggle): rm variant prop) +>>>>>>> df20abe7b (feat(button-toggle): rm variant prop) } } }