Skip to content

Commit

Permalink
New Accordion hooks and components
Browse files Browse the repository at this point in the history
  • Loading branch information
mj12albert committed Sep 4, 2024
1 parent e14cf39 commit 9400e99
Show file tree
Hide file tree
Showing 39 changed files with 1,723 additions and 3 deletions.
13 changes: 13 additions & 0 deletions docs/data/base/components/accordion/accordion.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
productId: base-ui
title: React Accordion components
components: AccordionRoot, AccordionSection, AccordionHeading, AccordionTrigger, AccordionPanel
hooks: useAccordionRoot
githubLabel: 'component: accordion'
waiAria: https://www.w3.org/WAI/ARIA/apg/patterns/accordion/
packageName: '@base_ui/react'
---

# Accordion

<p class="description">Accordion is a stacked set of interactive headings that each reveal an associated section of content.</p>
1 change: 1 addition & 0 deletions docs/data/base/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const pages: readonly MuiPage[] = [
pathname: '/base-ui/components/data-display',
subheader: 'data-display',
children: [
{ pathname: '/base-ui/react-accordion', title: 'Accordion' },
{ pathname: '/base-ui/react-collapsible', title: 'Collapsible' },
{ pathname: '/base-ui/react-popover', title: 'Popover' },
{ pathname: '/base-ui/react-preview-card', title: 'Preview Card' },
Expand Down
24 changes: 24 additions & 0 deletions docs/data/base/pagesApi.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,24 @@
module.exports = [
{
pathname: '/base-ui/react-accordion/components-api/#accordion-heading',
title: 'AccordionHeading',
},
{
pathname: '/base-ui/react-accordion/components-api/#accordion-panel',
title: 'AccordionPanel',
},
{
pathname: '/base-ui/react-accordion/components-api/#accordion-root',
title: 'AccordionRoot',
},
{
pathname: '/base-ui/react-accordion/components-api/#accordion-section',
title: 'AccordionSection',
},
{
pathname: '/base-ui/react-accordion/components-api/#accordion-trigger',
title: 'AccordionTrigger',
},
{
pathname: '/base-ui/react-alert-dialog/components-api/#alert-dialog-backdrop',
title: 'AlertDialogBackdrop',
Expand Down Expand Up @@ -334,6 +354,10 @@ module.exports = [
pathname: '/base-ui/react-tooltip/components-api/#tooltip-trigger',
title: 'TooltipTrigger',
},
{
pathname: '/base-ui/react-accordion/hooks-api/#use-accordion-root',
title: 'useAccordionRoot',
},
{
pathname: '/base-ui/react-autocomplete/hooks-api/#use-autocomplete',
title: 'useAutocomplete',
Expand Down
19 changes: 19 additions & 0 deletions docs/pages/base-ui/api/accordion-heading.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"props": {
"className": { "type": { "name": "union", "description": "func<br>&#124;&nbsp;string" } },
"render": { "type": { "name": "union", "description": "element<br>&#124;&nbsp;func" } }
},
"name": "AccordionHeading",
"imports": [
"import * as Accordion from '@base_ui/react/Accordion';\nconst AccordionHeading = Accordion.Heading;"
],
"classes": [],
"spread": true,
"themeDefaultProps": true,
"muiName": "AccordionHeading",
"forwardsRefTo": "HTMLHeadingElement",
"filename": "/packages/mui-base/src/Accordion/Heading/AccordionHeading.tsx",
"inheritance": null,
"demos": "<ul><li><a href=\"/base-ui/react-accordion/\">Accordion</a></li></ul>",
"cssComponent": false
}
23 changes: 23 additions & 0 deletions docs/pages/base-ui/api/accordion-panel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"props": {
"className": { "type": { "name": "union", "description": "func<br>&#124;&nbsp;string" } },
"htmlHidden": {
"type": { "name": "enum", "description": "'hidden'<br>&#124;&nbsp;'until-found'" },
"default": "'hidden'"
},
"render": { "type": { "name": "union", "description": "element<br>&#124;&nbsp;func" } }
},
"name": "AccordionPanel",
"imports": [
"import * as Accordion from '@base_ui/react/Accordion';\nconst AccordionPanel = Accordion.Panel;"
],
"classes": [],
"spread": true,
"themeDefaultProps": true,
"muiName": "AccordionPanel",
"forwardsRefTo": "HTMLDivElement",
"filename": "/packages/mui-base/src/Accordion/Panel/AccordionPanel.tsx",
"inheritance": null,
"demos": "<ul><li><a href=\"/base-ui/react-accordion/\">Accordion</a></li></ul>",
"cssComponent": false
}
29 changes: 29 additions & 0 deletions docs/pages/base-ui/api/accordion-root.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"props": {
"animated": { "type": { "name": "bool" }, "default": "true" },
"className": { "type": { "name": "union", "description": "func<br>&#124;&nbsp;string" } },
"defaultValue": {
"type": { "name": "arrayOf", "description": "Array&lt;number<br>&#124;&nbsp;string&gt;" },
"default": "0"
},
"disabled": { "type": { "name": "bool" }, "default": "false" },
"onOpenChange": { "type": { "name": "func" } },
"render": { "type": { "name": "union", "description": "element<br>&#124;&nbsp;func" } },
"value": {
"type": { "name": "arrayOf", "description": "Array&lt;number<br>&#124;&nbsp;string&gt;" }
}
},
"name": "AccordionRoot",
"imports": [
"import * as Accordion from '@base_ui/react/Accordion';\nconst AccordionRoot = Accordion.Root;"
],
"classes": [],
"spread": true,
"themeDefaultProps": true,
"muiName": "AccordionRoot",
"forwardsRefTo": "HTMLDivElement",
"filename": "/packages/mui-base/src/Accordion/Root/AccordionRoot.tsx",
"inheritance": null,
"demos": "<ul><li><a href=\"/base-ui/react-accordion/\">Accordion</a></li></ul>",
"cssComponent": false
}
21 changes: 21 additions & 0 deletions docs/pages/base-ui/api/accordion-section.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"props": {
"className": { "type": { "name": "union", "description": "func<br>&#124;&nbsp;string" } },
"disabled": { "type": { "name": "bool" }, "default": "false" },
"onOpenChange": { "type": { "name": "func" } },
"render": { "type": { "name": "union", "description": "element<br>&#124;&nbsp;func" } }
},
"name": "AccordionSection",
"imports": [
"import * as Accordion from '@base_ui/react/Accordion';\nconst AccordionSection = Accordion.Section;"
],
"classes": [],
"spread": true,
"themeDefaultProps": true,
"muiName": "AccordionSection",
"forwardsRefTo": "HTMLDivElement",
"filename": "/packages/mui-base/src/Accordion/Section/AccordionSection.tsx",
"inheritance": null,
"demos": "<ul><li><a href=\"/base-ui/react-accordion/\">Accordion</a></li></ul>",
"cssComponent": false
}
19 changes: 19 additions & 0 deletions docs/pages/base-ui/api/accordion-trigger.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"props": {
"className": { "type": { "name": "union", "description": "func<br>&#124;&nbsp;string" } },
"render": { "type": { "name": "union", "description": "element<br>&#124;&nbsp;func" } }
},
"name": "AccordionTrigger",
"imports": [
"import * as Accordion from '@base_ui/react/Accordion';\nconst AccordionTrigger = Accordion.Trigger;"
],
"classes": [],
"spread": true,
"themeDefaultProps": true,
"muiName": "AccordionTrigger",
"forwardsRefTo": "HTMLButtonElement",
"filename": "/packages/mui-base/src/Accordion/Trigger/AccordionTrigger.tsx",
"inheritance": null,
"demos": "<ul><li><a href=\"/base-ui/react-accordion/\">Accordion</a></li></ul>",
"cssComponent": false
}
8 changes: 8 additions & 0 deletions docs/pages/base-ui/api/use-accordion-root.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"parameters": {},
"returnValue": {},
"name": "useAccordionRoot",
"filename": "/packages/mui-base/src/Accordion/Root/useAccordionRoot.ts",
"imports": ["import { useAccordionRoot } from '@base_ui/react/Accordion';"],
"demos": "<ul><li><a href=\"/base-ui/react-accordion/#hook\">Accordion</a></li></ul>"
}
92 changes: 92 additions & 0 deletions docs/pages/base-ui/react-accordion/[docsTab]/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import * as React from 'react';
import MarkdownDocs from 'docs/src/modules/components/MarkdownDocsV2';
import AppFrame from 'docs/src/modules/components/AppFrame';
import * as pageProps from 'docs-base/data/base/components/accordion/accordion.md?@mui/markdown';
import mapApiPageTranslations from 'docs/src/modules/utils/mapApiPageTranslations';
import AccordionHeadingApiJsonPageContent from '../../api/accordion-heading.json';
import AccordionPanelApiJsonPageContent from '../../api/accordion-panel.json';
import AccordionRootApiJsonPageContent from '../../api/accordion-root.json';
import AccordionSectionApiJsonPageContent from '../../api/accordion-section.json';
import AccordionTriggerApiJsonPageContent from '../../api/accordion-trigger.json';
import useAccordionRootApiJsonPageContent from '../../api/use-accordion-root.json';

export default function Page(props) {
const { userLanguage, ...other } = props;
return <MarkdownDocs {...pageProps} {...other} />;
}

Page.getLayout = (page) => {
return <AppFrame>{page}</AppFrame>;
};

export const getStaticPaths = () => {
return {
paths: [{ params: { docsTab: 'components-api' } }, { params: { docsTab: 'hooks-api' } }],
fallback: false, // can also be true or 'blocking'
};
};

export const getStaticProps = () => {
const AccordionHeadingApiReq = require.context(
'docs-base/translations/api-docs/accordion-heading',
false,
/\.\/accordion-heading.*.json$/,
);
const AccordionHeadingApiDescriptions = mapApiPageTranslations(AccordionHeadingApiReq);

const AccordionPanelApiReq = require.context(
'docs-base/translations/api-docs/accordion-panel',
false,
/\.\/accordion-panel.*.json$/,
);
const AccordionPanelApiDescriptions = mapApiPageTranslations(AccordionPanelApiReq);

const AccordionRootApiReq = require.context(
'docs-base/translations/api-docs/accordion-root',
false,
/\.\/accordion-root.*.json$/,
);
const AccordionRootApiDescriptions = mapApiPageTranslations(AccordionRootApiReq);

const AccordionSectionApiReq = require.context(
'docs-base/translations/api-docs/accordion-section',
false,
/\.\/accordion-section.*.json$/,
);
const AccordionSectionApiDescriptions = mapApiPageTranslations(AccordionSectionApiReq);

const AccordionTriggerApiReq = require.context(
'docs-base/translations/api-docs/accordion-trigger',
false,
/\.\/accordion-trigger.*.json$/,
);
const AccordionTriggerApiDescriptions = mapApiPageTranslations(AccordionTriggerApiReq);

const useAccordionRootApiReq = require.context(
'docs-base/translations/api-docs/use-accordion-root',
false,
/\.\/use-accordion-root.*.json$/,
);
const useAccordionRootApiDescriptions = mapApiPageTranslations(useAccordionRootApiReq);

return {
props: {
componentsApiDescriptions: {
AccordionHeading: AccordionHeadingApiDescriptions,
AccordionPanel: AccordionPanelApiDescriptions,
AccordionRoot: AccordionRootApiDescriptions,
AccordionSection: AccordionSectionApiDescriptions,
AccordionTrigger: AccordionTriggerApiDescriptions,
},
componentsApiPageContents: {
AccordionHeading: AccordionHeadingApiJsonPageContent,
AccordionPanel: AccordionPanelApiJsonPageContent,
AccordionRoot: AccordionRootApiJsonPageContent,
AccordionSection: AccordionSectionApiJsonPageContent,
AccordionTrigger: AccordionTriggerApiJsonPageContent,
},
hooksApiDescriptions: { useAccordionRoot: useAccordionRootApiDescriptions },
hooksApiPageContents: { useAccordionRoot: useAccordionRootApiJsonPageContent },
},
};
};
13 changes: 13 additions & 0 deletions docs/pages/base-ui/react-accordion/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import * as React from 'react';
import MarkdownDocs from 'docs/src/modules/components/MarkdownDocsV2';
import AppFrame from 'docs/src/modules/components/AppFrame';
import * as pageProps from 'docs-base/data/base/components/accordion/accordion.md?@mui/markdown';

export default function Page(props) {
const { userLanguage, ...other } = props;
return <MarkdownDocs {...pageProps} {...other} />;
}

Page.getLayout = (page) => {
return <AppFrame>{page}</AppFrame>;
};
Loading

0 comments on commit 9400e99

Please sign in to comment.