Skip to content

Commit

Permalink
feat(accordion): change buttonWidth prop type to string
Browse files Browse the repository at this point in the history
closes #5897

BREAKING CHANGE: buttonWidth type changed from number to string
  • Loading branch information
grabkowski committed Mar 13, 2023
1 parent e01478a commit 046dbf3
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 17 deletions.
8 changes: 4 additions & 4 deletions src/components/accordion/accordion-test.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ export const AccordionOpeningButton = () => {
borders="none"
iconAlign="left"
buttonHeading
buttonWidth={200}
buttonWidth="200px"
error="hello"
>
<div>Content</div>
Expand All @@ -378,7 +378,7 @@ export const AccordionOpeningButton = () => {
borders="none"
iconAlign="right"
buttonHeading
buttonWidth={200}
buttonWidth="200px"
>
<div>Content</div>
<div>Content</div>
Expand All @@ -394,7 +394,7 @@ export const AccordionOpeningButton = () => {
headerSpacing={{
px: 0,
}}
buttonWidth={96}
buttonWidth="96px"
>
<div>Content</div>
<div>Content</div>
Expand All @@ -408,7 +408,7 @@ export const AccordionOpeningButton = () => {
openTitle="Less info"
iconAlign="left"
buttonHeading
buttonWidth={120}
buttonWidth="120px"
headerSpacing={{
px: 1,
}}
Expand Down
4 changes: 2 additions & 2 deletions src/components/accordion/accordion.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export interface AccordionProps
extends StyledAccordionContainerProps,
SpaceProps {
/** Width of the buttonHeading when it's set, defaults to 150px */
buttonWidth?: number;
buttonWidth?: string;
/** Content of the Accordion component */
children?: React.ReactNode;
/** Set the default state of expansion of the Accordion if component is meant to be used as uncontrolled */
Expand Down Expand Up @@ -95,7 +95,7 @@ export const Accordion = React.forwardRef<
warning,
info,
buttonHeading,
buttonWidth = 150,
buttonWidth = "150px",
openTitle,
...rest
}: AccordionProps & AccordionInternalProps,
Expand Down
4 changes: 2 additions & 2 deletions src/components/accordion/accordion.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ describe("Accordion", () => {
}
);

it.each(Array.from({ length: 10 }).map((_, i) => 100 + i))(
it.each(Array.from({ length: 10 }).map((_, i) => `${100 + i}px`))(
"sets the width of the button to the value passed in via the buttonWidth prop",
(buttonWidth) => {
wrapper = mount(
Expand All @@ -539,7 +539,7 @@ describe("Accordion", () => {

assertStyleMatch(
{
width: `${buttonWidth}px`,
width: `${buttonWidth}`,
},
wrapper
);
Expand Down
8 changes: 4 additions & 4 deletions src/components/accordion/accordion.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ export const OpeningButton: ComponentStory<typeof Accordion> = () => {
borders="none"
iconAlign="left"
buttonHeading
buttonWidth={200}
buttonWidth="200px"
error="hello"
>
<div>Content</div>
Expand All @@ -302,7 +302,7 @@ export const OpeningButton: ComponentStory<typeof Accordion> = () => {
borders="none"
iconAlign="right"
buttonHeading
buttonWidth={200}
buttonWidth="200px"
>
<div>Content</div>
<div>Content</div>
Expand All @@ -316,7 +316,7 @@ export const OpeningButton: ComponentStory<typeof Accordion> = () => {
openTitle="Less info"
buttonHeading
headerSpacing={{ px: 0 }}
buttonWidth={96}
buttonWidth="96px"
>
<div>Content</div>
<div>Content</div>
Expand All @@ -330,7 +330,7 @@ export const OpeningButton: ComponentStory<typeof Accordion> = () => {
openTitle="Less info"
iconAlign="left"
buttonHeading
buttonWidth={120}
buttonWidth="120px"
headerSpacing={{ px: 1 }}
>
<div>Content</div>
Expand Down
4 changes: 2 additions & 2 deletions src/components/accordion/accordion.style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ const StyledAccordionHeadingsContainer = styled.div<StyledAccordionHeadingsConta

interface StyledAccordionTitleContainerProps {
buttonHeading?: boolean;
buttonWidth?: number;
buttonWidth?: string;
hasButtonProps?: boolean;
iconAlign?: "left" | "right";
size?: "large" | "small";
Expand Down Expand Up @@ -195,7 +195,7 @@ const StyledAccordionTitleContainer = styled.div<StyledAccordionTitleContainerPr
${buttonWidth &&
css`
width: ${buttonWidth}px;
width: ${buttonWidth};
`}
`}
`}
Expand Down
4 changes: 2 additions & 2 deletions src/components/accordion/accordion.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,8 @@ context("Testing Accordion component", () => {
.and("have.attr", "type", "info");
});

it.each([[100], [200], [300]])(
"should check accordion heading is a button with width %spx",
it.each([["100px"], ["200px"], ["300px"]])(
"should check accordion heading is a button with width %s",
(widths) => {
CypressMountWithProviders(
<AccordionComponent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ export const WithHideableHeaderChildren = () => {
borders="none"
disableContentPadding
buttonHeading
buttonWidth={120}
buttonWidth="120px"
ml="-13px"
>
<Box py="16px" pl="14px">
Expand Down

0 comments on commit 046dbf3

Please sign in to comment.