Skip to content

Commit

Permalink
Feature/accordion (#496)
Browse files Browse the repository at this point in the history
Depends on #483

closes #456

---------

Co-authored-by: Ruben Smit <[email protected]>
Co-authored-by: Rozerin <[email protected]>
Co-authored-by: Robbert <[email protected]>
  • Loading branch information
4 people authored Aug 15, 2024
1 parent 20fe189 commit 528462b
Show file tree
Hide file tree
Showing 12 changed files with 199 additions and 23 deletions.
5 changes: 5 additions & 0 deletions packages/components-css/accordion/index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@import "../node_modules/@utrecht/components/accordion/src/";

.utrecht-accordion__button {
--utrecht-button-border-radius: var(--utrecht-accordion-border-radius);
}
2 changes: 1 addition & 1 deletion packages/components-css/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
* @license EUPL-1.2
* Copyright (c) 2021 Community for NL Design System
*/

@import "accordion/index";
@import "logo/index";
3 changes: 3 additions & 0 deletions packages/components-css/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
"access": "restricted",
"registry": "https://registry.npmjs.org/"
},
"devDependencies": {
"@utrecht/components": "6.0.0"
},
"repository": {
"type": "git+ssh",
"url": "[email protected]:nl-design-system/rijkshuisstijl-community.git",
Expand Down
1 change: 1 addition & 0 deletions packages/components-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
],
"sideEffects": false,
"dependencies": {
"@rijkshuisstijl-community/components-css": "workspace:*",
"@utrecht/component-library-react": "5.0.0",
"clsx": "2.1.1",
"date-fns": "3.6.0",
Expand Down
11 changes: 11 additions & 0 deletions packages/components-react/src/Accordion.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import '@rijkshuisstijl-community/components-css/index.scss';

export {
Accordion,
type AccordionProps,
AccordionProvider,
type AccordionProviderProps,
AccordionSection,
type AccordionSectionProps,
type AccordionSectionProviderProps,
} from '@utrecht/component-library-react/';
10 changes: 10 additions & 0 deletions packages/components-react/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
// Export all Utrecht components
export * from '@utrecht/component-library-react/dist/css-module';

// Export overwrites and new components
export {
Accordion,
type AccordionProps,
AccordionProvider,
type AccordionProviderProps,
AccordionSection,
type AccordionSectionProps,
type AccordionSectionProviderProps,
} from './Accordion';
export { Logo } from './Logo';
export type { LogoProps } from './Logo';
3 changes: 2 additions & 1 deletion packages/storybook/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"@nl-rvo/assets": "1.0.0-alpha.360",
"@rijkshuisstijl-community/assets": "workspace:*",
"@rijkshuisstijl-community/components-css": "workspace:*",
"@rijkshuisstijl-community/components-react": "workspace:*",
"@rijkshuisstijl-community/design-tokens": "workspace:*",
"@rijkshuisstijl-community/digid-design-tokens": "workspace:*",
"@rijkshuisstijl-community/font": "workspace:*",
Expand All @@ -51,7 +52,7 @@
"@types/react": "18.3.3",
"@types/react-dom": "18.3.0",
"@utrecht/component-library-css": "4.0.0",
"@utrecht/component-library-react": "4.1.0",
"@utrecht/component-library-react": "5.0.0",
"@utrecht/web-component-library-react": "1.2.0",
"@utrecht/web-component-library-stencil": "1.3.0",
"@whitespace/storybook-addon-html": "6.1.1",
Expand Down
3 changes: 3 additions & 0 deletions packages/storybook/src/community/accordion.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<!-- @license CC0-1.0 -->

# Rijkshuisstijl Community accordion component
137 changes: 137 additions & 0 deletions packages/storybook/src/community/accordion.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
import { AccordionProvider, AccordionSectionProps } from '@rijkshuisstijl-community/components-react';
import { Meta, StoryObj } from '@storybook/react';
import { UtrechtIconChevronDown } from '@utrecht/web-component-library-react';
import { ReactNode } from 'react';
import readme from './accordion.md?raw';

interface AccordionStoryProps {
label: string;
body: ReactNode;
expanded?: boolean;
expandedAccordion?: boolean;
icon?: ReactNode;
appearance?: string;
sections?: AccordionSectionProps[];
}

const AccordionStory = ({ expanded, label, body, appearance, icon, sections }: AccordionStoryProps) => (
<AccordionProvider icon={icon} appearance={appearance} sections={sections || [{ expanded, label, body }]} />
);

const meta = {
title: 'Rijkshuisstijl/Accordion',
id: 'react-accordion',
args: {
label: '',
body: '',
expandedAccordion: false,
appearance: '',
icon: undefined,
},
argTypes: {
label: {
name: 'label',
type: { name: 'string', required: true },
table: {
defaultValue: { summary: '' },
category: 'API',
},
},
body: {
name: 'body',
type: { name: 'string', required: true },
table: {
defaultValue: { summary: '' },
category: 'API',
},
},
expandedAccordion: {
name: 'expandedAccordion',
type: { name: 'boolean', required: false },
table: {
defaultValue: { summary: false },
category: 'API',
},
},
appearance: {
description: 'Appearance',
control: { type: 'select' },
options: ['', 'utrecht'],
},
icon: {
name: 'icon',
description: 'Icon at the start',
control: { type: 'select' },
options: {
'': undefined,
null: null,
'utrecht-icon-chevron-down': <UtrechtIconChevronDown />,
},
},
},
parameters: {
tokensPrefix: 'utrecht-accordion',
docs: {
description: {
component: readme,
},
},
},
render: AccordionStory,
} satisfies Meta<AccordionStoryProps>;

export default meta;

type Story = StoryObj<typeof meta>;

const accordionDefaultDataAR = {
label: 'ما هو "لوريم إيبسوم" ؟',
body: ' المحتوى) ويُستخدم في صناعات المطابع ودور النشر. كان لوريم إيبسوم ولايزال المعيار للنص الشكلي منذ القرن الخامس عشر عندما قامت مطبعة مجهولة برص مجموعة من الأحرف بشكل عشوائي أخذتها من نص، لتكوّن كتيّب بمثابة دليل أو مرجع شكلي لهذه الأحرف. خمسة قرون من الزمن لم تقضي على هذا النص، بل انه حتى صار مستخدماً وبشكله الأصلي في الطباعة والتنضيد الإلكتروني. انتشر بشكل كبير في ستينيّات هذا القرن مع إصدار رقائق "ليتراسيت" (Letraset) البلاستيكية تحوي مقاطع من هذا النص، وعاد لينتشر مرة أخرى مؤخراَ مع ظهور برامج النشر الإلكتروني مثل "ألدوس بايج مايكر" (Aldus PageMaker) والتي حوت أيضاً على نسخ من نص لوريم إيبسوم.',
};
const accordionData = [
{
label: 'Lorem ipsum 1',
body: `Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est
laborum.`,
expandedAccordion: true,
},
{
label: 'Lorem ipsum 2',
body: `Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est
laborum.`,
expandedAccordion: false,
},
{
label: 'Lorem ipsum 3',
body: `Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est
laborum.`,
expandedAccordion: false,
},
];

export const Default: Story = {
args: {
sections: accordionData,
},
};

export const RTL: Story = {
args: accordionDefaultDataAR,
decorators: [
(Story) => (
<div lang="ar" dir="rtl">
{Story()}
</div>
),
],
name: 'Right-to-left',
};
16 changes: 13 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 13 additions & 17 deletions proprietary/design-tokens/figma/figma.tokens.json
Original file line number Diff line number Diff line change
Expand Up @@ -805,14 +805,6 @@
}
},
"utrecht/document": {
"background-color": {
"value": "{rhc.color.wit}",
"type": "other"
},
"color": {
"value": "{rhc.color.zwart}",
"type": "other"
},
"font-family": {
"value": "{rhc.font-family.primary}",
"type": "other"
Expand Down Expand Up @@ -1281,7 +1273,7 @@
"type": "color"
}
},
"body": {
"panel": {
"border-color": {
"value": "{rhc.color.border.subdued}",
"type": "color"
Expand Down Expand Up @@ -1316,6 +1308,10 @@
"value": "{rhc.line-height.md}",
"type": "lineHeights"
},
"gap": {
"value": "{rhc.space.100}",
"type": "spacing"
},
"icon": {
"margin-inline": {
"value": "{rhc.space.100}",
Expand Down Expand Up @@ -1625,7 +1621,7 @@
},
"text": {
"font-family": {
"value": "{utrecht.document.font-family}",
"value": "{rhc.font-family.primary}",
"type": "fontFamilies"
},
"font-weight": {
Expand Down Expand Up @@ -2789,7 +2785,7 @@
"header": {
"label": {
"font-family": {
"value": "{utrecht.document.font-family}",
"value": "{rhc.font-family.primary}",
"type": "fontFamilies"
},
"font-size": {
Expand Down Expand Up @@ -2879,7 +2875,7 @@
"type": "color"
},
"font-family": {
"value": "{utrecht.document.font-family}",
"value": "{rhc.font-family.primary}",
"type": "fontFamilies"
},
"font-size": {
Expand Down Expand Up @@ -3284,7 +3280,7 @@
"type": "color"
},
"font-family": {
"value": "{utrecht.document.font-family}",
"value": "{rhc.font-family.primary}",
"type": "fontFamilies"
},
"font-weight": {
Expand Down Expand Up @@ -3686,7 +3682,7 @@
}
},
"font-family": {
"value": "{utrecht.document.font-family}",
"value": "{rhc.font-family.primary}",
"type": "fontFamilies"
},
"line-height": {
Expand Down Expand Up @@ -4126,7 +4122,7 @@
"type": "borderWidth"
},
"font-family": {
"value": "{utrecht.document.font-family}",
"value": "{rhc.font-family.primary}",
"type": "fontFamilies"
},
"font-weight": {
Expand Down Expand Up @@ -4856,7 +4852,7 @@
}
},
"font-family": {
"value": "{utrecht.document.font-family}",
"value": "{rhc.font-family.primary}",
"type": "fontFamilies"
},
"font-size": {
Expand Down Expand Up @@ -5028,7 +5024,7 @@
"type": "borderWidth"
},
"font-family": {
"value": "{utrecht.document.font-family}",
"value": "{rhc.font-family.primary}",
"type": "fontFamilies"
},
"font-weight": {
Expand Down
1 change: 0 additions & 1 deletion proprietary/design-tokens/token-transformer.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const init = async ({ input, output }) => {
// The following components didn't work yet because of broken design token references.
// You can remove excludes from this list at any time, as long as they don't break the build.
const excludes = [
'components/accordion',
'components/alert',
'components/avatar',
'components/backdrop',
Expand Down

0 comments on commit 528462b

Please sign in to comment.