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

PLASMA-4309: add Header sizes to Accordion #1724

Merged
merged 5 commits into from
Jan 30, 2025
Merged
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions packages/plasma-b2c/api/plasma-b2c.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,10 @@ l: PolymorphicClassName;
m: PolymorphicClassName;
s: PolymorphicClassName;
xs: PolymorphicClassName;
h2: PolymorphicClassName;
h3: PolymorphicClassName;
h4: PolymorphicClassName;
h5: PolymorphicClassName;
};
stretching: {
filled: PolymorphicClassName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export const config = {
${accordionTokens.accordionItemBorderBottom}: 0;
${accordionTokens.accordionItemPaddingHorizontalLeft}: var(${accordionTokens.accordionItemPaddingHorizontal});
`,
/* @deprecated */
outlined: css`
${accordionTokens.accordionGap}: 0.125rem;
${accordionTokens.accordionWidth}: 20rem;
Expand All @@ -45,8 +46,8 @@ export const config = {
${accordionTokens.accordionItemIconColor}: var(--text-primary);
${accordionTokens.accordionItemFocus}: var(--surface-accent);
${accordionTokens.accordionBackground}: var(--surface-clear);
${accordionTokens.accordionItemBorder}: 0.125rem solid var(--surface-transparent-secondary);
${accordionTokens.accordionItemBorderBottom}: 0.125rem solid var(--surface-transparent-secondary);
${accordionTokens.accordionItemBorder}: 0.063rem solid var(--surface-transparent-secondary);
${accordionTokens.accordionItemBorderBottom}: 0.063rem solid var(--surface-transparent-secondary);
${accordionTokens.accordionItemPaddingHorizontalLeft}: var(${accordionTokens.accordionItemPaddingHorizontal});
`,
clear: css`
Expand All @@ -61,15 +62,15 @@ export const config = {
${accordionTokens.accordionItemBorderRadius}: 0rem !important;
${accordionTokens.accordionBackground}: var(--surface-clear);
${accordionTokens.accordionItemBorder}: none;
${accordionTokens.accordionItemBorderBottom}: 0.125rem solid var(--surface-solid-tertiary);
${accordionTokens.accordionItemBorderBottom}: 0.063rem solid var(--surface-solid-tertiary);
${accordionTokens.accordionItemPaddingHorizontalLeft}: 0;
`,
},
size: {
l: css`
${accordionTokens.accordionItemPaddingVertical}: 1.0625rem;
${accordionTokens.accordionItemPaddingHorizontal}: 1.25rem;
${accordionTokens.accordionItemGap}: 0.875rem;
${accordionTokens.accordionItemGap}: 0.5rem;
${accordionTokens.accordionItemBorderRadius}: 0.875rem;

${accordionTokens.accordionItemTitleFontFamily}: var(--plasma-typo-body-l-font-family);
Expand All @@ -89,7 +90,7 @@ export const config = {
m: css`
${accordionTokens.accordionItemPaddingVertical}: 0.875rem;
${accordionTokens.accordionItemPaddingHorizontal}: 1.125rem;
${accordionTokens.accordionItemGap}: 0.75rem;
${accordionTokens.accordionItemGap}: 0.375rem;
${accordionTokens.accordionItemBorderRadius}: 0.75rem;

${accordionTokens.accordionItemTitleFontFamily}: var(--plasma-typo-body-m-font-family);
Expand All @@ -109,7 +110,7 @@ export const config = {
s: css`
${accordionTokens.accordionItemPaddingVertical}: 0.6875rem;
${accordionTokens.accordionItemPaddingHorizontal}: 0.875rem;
${accordionTokens.accordionItemGap}: 0.625rem;
${accordionTokens.accordionItemGap}: 0.375rem;
${accordionTokens.accordionItemBorderRadius}: 0.625rem;

${accordionTokens.accordionItemTitleFontFamily}: var(--plasma-typo-body-s-font-family);
Expand All @@ -129,7 +130,7 @@ export const config = {
xs: css`
${accordionTokens.accordionItemPaddingVertical}: 0.5rem;
${accordionTokens.accordionItemPaddingHorizontal}: 0.75rem;
${accordionTokens.accordionItemGap}: 0.5rem;
${accordionTokens.accordionItemGap}: 0.25rem;
${accordionTokens.accordionItemBorderRadius}: 0.5rem;

${accordionTokens.accordionItemTitleFontFamily}: var(--plasma-typo-body-xs-font-family);
Expand All @@ -146,6 +147,88 @@ export const config = {
${accordionTokens.accordionItemTextLetterSpacing}: var(--plasma-typo-body-xs-letter-spacing);
${accordionTokens.accordionItemTextLineHeight}: var(--plasma-typo-body-xs-line-height);
`,
h2: css`
${accordionTokens.accordionItemPaddingVertical}: 1rem;
${accordionTokens.accordionItemPaddingHorizontal}: 1.25rem;
${accordionTokens.accordionItemGap}: 0.25rem;
${accordionTokens.accordionItemBorderRadius}: 0.75rem;
${accordionTokens.accordionItemIconSize}: 1.5rem;

${accordionTokens.accordionItemTitleFontFamily}: var(--plasma-typo-h2-font-family);
${accordionTokens.accordionItemTitleFontSize}: var(--plasma-typo-h2-font-size);
${accordionTokens.accordionItemTitleFontStyle}: var(--plasma-typo-h2-font-style);
${accordionTokens.accordionItemTitleFontWeight}: var(--plasma-typo-h2-bold-font-weight);
${accordionTokens.accordionItemTitleLetterSpacing}: var(--plasma-typo-h2-letter-spacing);
${accordionTokens.accordionItemTitleLineHeight}: var(--plasma-typo-h2-line-height);

${accordionTokens.accordionItemTextFontFamily}: var(--plasma-typo-body-l-font-family);
${accordionTokens.accordionItemTextFontSize}: var(--plasma-typo-body-l-font-size);
${accordionTokens.accordionItemTextFontStyle}: var(--plasma-typo-body-l-font-style);
${accordionTokens.accordionItemTextFontWeight}: var(--plasma-typo-body-l-font-weight);
${accordionTokens.accordionItemTextLetterSpacing}: var(--plasma-typo-body-l-letter-spacing);
${accordionTokens.accordionItemTextLineHeight}: var(--plasma-typo-body-l-line-height);
`,
h3: css`
${accordionTokens.accordionItemPaddingVertical}: 0.875rem;
${accordionTokens.accordionItemPaddingHorizontal}: 1.125rem;
${accordionTokens.accordionItemGap}: 0.25rem;
${accordionTokens.accordionItemBorderRadius}: 0.75rem;
${accordionTokens.accordionItemIconSize}: 1.5rem;

${accordionTokens.accordionItemTitleFontFamily}: var(--plasma-typo-h3-font-family);
${accordionTokens.accordionItemTitleFontSize}: var(--plasma-typo-h3-font-size);
${accordionTokens.accordionItemTitleFontStyle}: var(--plasma-typo-h3-font-style);
${accordionTokens.accordionItemTitleFontWeight}: var(--plasma-typo-h3-bold-font-weight);
${accordionTokens.accordionItemTitleLetterSpacing}: var(--plasma-typo-h3-letter-spacing);
${accordionTokens.accordionItemTitleLineHeight}: var(--plasma-typo-h3-line-height);

${accordionTokens.accordionItemTextFontFamily}: var(--plasma-typo-body-l-font-family);
${accordionTokens.accordionItemTextFontSize}: var(--plasma-typo-body-l-font-size);
${accordionTokens.accordionItemTextFontStyle}: var(--plasma-typo-body-l-font-style);
${accordionTokens.accordionItemTextFontWeight}: var(--plasma-typo-body-l-font-weight);
${accordionTokens.accordionItemTextLetterSpacing}: var(--plasma-typo-body-l-letter-spacing);
${accordionTokens.accordionItemTextLineHeight}: var(--plasma-typo-body-l-line-height);
`,
h4: css`
${accordionTokens.accordionItemPaddingVertical}: 0.688rem;
${accordionTokens.accordionItemPaddingHorizontal}: 0.875rem;
${accordionTokens.accordionItemGap}: 0.25rem;
${accordionTokens.accordionItemBorderRadius}: 0.625rem;

${accordionTokens.accordionItemTitleFontFamily}: var(--plasma-typo-h4-font-family);
${accordionTokens.accordionItemTitleFontSize}: var(--plasma-typo-h4-font-size);
${accordionTokens.accordionItemTitleFontStyle}: var(--plasma-typo-h4-font-style);
${accordionTokens.accordionItemTitleFontWeight}: var(--plasma-typo-h4-bold-font-weight);
${accordionTokens.accordionItemTitleLetterSpacing}: var(--plasma-typo-h4-letter-spacing);
${accordionTokens.accordionItemTitleLineHeight}: var(--plasma-typo-h4-line-height);

${accordionTokens.accordionItemTextFontFamily}: var(--plasma-typo-body-m-font-family);
${accordionTokens.accordionItemTextFontSize}: var(--plasma-typo-body-m-font-size);
${accordionTokens.accordionItemTextFontStyle}: var(--plasma-typo-body-m-font-style);
${accordionTokens.accordionItemTextFontWeight}: var(--plasma-typo-body-m-font-weight);
${accordionTokens.accordionItemTextLetterSpacing}: var(--plasma-typo-body-m-letter-spacing);
${accordionTokens.accordionItemTextLineHeight}: var(--plasma-typo-body-m-line-height);
`,
h5: css`
${accordionTokens.accordionItemPaddingVertical}: 0.5rem;
${accordionTokens.accordionItemPaddingHorizontal}: 0.75rem;
${accordionTokens.accordionItemGap}: 0.25rem;
${accordionTokens.accordionItemBorderRadius}: 0.5rem;

${accordionTokens.accordionItemTitleFontFamily}: var(--plasma-typo-h5-font-family);
${accordionTokens.accordionItemTitleFontSize}: var(--plasma-typo-h5-font-size);
${accordionTokens.accordionItemTitleFontStyle}: var(--plasma-typo-h5-font-style);
${accordionTokens.accordionItemTitleFontWeight}: var(--plasma-typo-h5-bold-font-weight);
${accordionTokens.accordionItemTitleLetterSpacing}: var(--plasma-typo-h5-letter-spacing);
${accordionTokens.accordionItemTitleLineHeight}: var(--plasma-typo-h5-line-height);

${accordionTokens.accordionItemTextFontFamily}: var(--plasma-typo-body-m-font-family);
${accordionTokens.accordionItemTextFontSize}: var(--plasma-typo-body-m-font-size);
${accordionTokens.accordionItemTextFontStyle}: var(--plasma-typo-body-m-font-style);
${accordionTokens.accordionItemTextFontWeight}: var(--plasma-typo-body-m-font-weight);
${accordionTokens.accordionItemTextLetterSpacing}: var(--plasma-typo-body-m-letter-spacing);
${accordionTokens.accordionItemTextLineHeight}: var(--plasma-typo-body-m-line-height);
`,
},
stretching: {
filled: css``,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import { IconButton } from '../IconButton/IconButton';

import { Accordion, AccordionItem } from '.';

const sizes = ['l', 'm', 's', 'xs', 'h2', 'h3', 'h4', 'h5'] as const;
const stretching = ['filled', 'fixed'] as const;
const types = ['arrow', 'sign', 'clear'] as const;

const meta: Meta<typeof Accordion> = {
title: 'Data Display/Accordion',
component: Accordion,
Expand All @@ -23,14 +27,20 @@ const meta: Meta<typeof Accordion> = {
},
argTypes: {
...disableProps(['text']),
size: {
options: sizes,
control: {
type: 'select',
},
},
stretching: {
options: ['filled', 'fixed'],
options: stretching,
control: {
type: 'select',
},
},
type: {
options: ['arrow', 'sign', 'clear'],
options: types,
control: {
type: 'select',
},
Expand Down Expand Up @@ -61,6 +71,24 @@ export const Default: StoryObj<ComponentProps<typeof Accordion>> = {
};

const getSizeForIcon = (size) => (size === 'xs' ? 'xs' : 's');
const getSizeForIconButton = (size) => {
switch (size) {
case 'l':
case 'h2':
case 'h3':
return 'l';
case 'm':
return 'm';
case 's':
case 'h4':
return 's';
case 'xs':
case 'h5':
return 'xs';
default:
return 'm';
}
};

const ControlledAccordion = (props: ComponentProps<typeof Accordion>) => {
const args = { ...props, text: undefined };
Expand All @@ -72,7 +100,11 @@ const ControlledAccordion = (props: ComponentProps<typeof Accordion>) => {
<Accordion {...args}>
<AccordionItem
contentRight={
<IconButton view="secondary" size={args.size} onClick={() => setActiveFirst(!activeFirst)}>
<IconButton
view="secondary"
size={getSizeForIconButton(args.size)}
onClick={() => setActiveFirst(!activeFirst)}
>
<IconPlus size={getSizeForIcon(args.size)} />
</IconButton>
}
Expand All @@ -86,7 +118,11 @@ const ControlledAccordion = (props: ComponentProps<typeof Accordion>) => {
</AccordionItem>
<AccordionItem
contentRight={
<IconButton view="secondary" size={args.size} onClick={() => setActiveSecond(!activeSecond)}>
<IconButton
view="secondary"
size={getSizeForIconButton(args.size)}
onClick={() => setActiveSecond(!activeSecond)}
>
<IconPlus size={getSizeForIcon(args.size)} />
</IconButton>
}
Expand All @@ -100,7 +136,11 @@ const ControlledAccordion = (props: ComponentProps<typeof Accordion>) => {
</AccordionItem>
<AccordionItem
contentRight={
<IconButton view="secondary" size={args.size} onClick={() => setActiveThree(!activeThree)}>
<IconButton
view="secondary"
size={getSizeForIconButton(args.size)}
onClick={() => setActiveThree(!activeThree)}
>
<IconPlus size={getSizeForIcon(args.size)} />
</IconButton>
}
Expand Down
4 changes: 4 additions & 0 deletions packages/plasma-giga/api/plasma-giga.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,10 @@ l: PolymorphicClassName;
m: PolymorphicClassName;
s: PolymorphicClassName;
xs: PolymorphicClassName;
h2: PolymorphicClassName;
h3: PolymorphicClassName;
h4: PolymorphicClassName;
h5: PolymorphicClassName;
};
}> & {
view?: string | undefined;
Expand Down
Loading