Skip to content

Commit

Permalink
Indent prop added to accordion (#2027)
Browse files Browse the repository at this point in the history
  • Loading branch information
JulianNymark authored Jun 5, 2023
1 parent 988fb36 commit c028f36
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
6 changes: 6 additions & 0 deletions .changeset/small-clouds-wash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@navikt/ds-css": patch
"@navikt/ds-react": patch
---

add indent prop to accordion
7 changes: 6 additions & 1 deletion @navikt/core/css/accordion.css
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,16 @@
/*************************
* Content *
*************************/

.navds-accordion__content {
padding: 0 var(--a-spacing-3) var(--a-spacing-5) var(--a-spacing-11);
padding: 0 var(--a-spacing-3) var(--a-spacing-5);
animation: fadeAccordionContent 250ms ease;
}

.navds-accordion--indent > :where(.navds-accordion__item) > :where(.navds-accordion__content) {
padding: 0 var(--a-spacing-3) var(--a-spacing-5) var(--a-spacing-11);
}

.navds-accordion__content--closed {
display: none;
}
Expand Down
9 changes: 8 additions & 1 deletion @navikt/core/react/src/accordion/Accordion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ export interface AccordionProps extends React.HTMLAttributes<HTMLDivElement> {
* @default "medium"
*/
size?: "large" | "medium" | "small";
/**
* Whether to indent content or not
* @default true
*/
indent?: boolean;
/**
* Instances of Accordion.Item
*/
Expand All @@ -40,6 +45,7 @@ export const Accordion = forwardRef<HTMLDivElement, AccordionProps>(
variant = "default",
headingSize = "small",
size = "medium",
indent = true,
...rest
},
ref
Expand All @@ -57,7 +63,8 @@ export const Accordion = forwardRef<HTMLDivElement, AccordionProps>(
className={cl(
"navds-accordion",
className,
`navds-accordion--${size}`
`navds-accordion--${size}`,
{ "navds-accordion--indent": indent }
)}
ref={ref}
/>
Expand Down
6 changes: 4 additions & 2 deletions @navikt/core/react/src/accordion/accordion.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,12 @@ export const Default = {
},

args: {
controlled: "false",
controlled: false,
nItems: 2,
variant: "default",
headingSize: "medium",
size: "medium",
indent: true,
},
};

Expand All @@ -137,7 +138,7 @@ export const DefaultOpen = {

args: {
openItems: [1, 2],
controlled: "false",
controlled: false,
nItems: 5,
variant: "neutral",
headingSize: "large",
Expand Down Expand Up @@ -251,6 +252,7 @@ export const WithTable = {
args: {
variant: "default",
headingSize: "large",
indent: false,
},
};

Expand Down

0 comments on commit c028f36

Please sign in to comment.