Skip to content

Commit

Permalink
feat: improve structure
Browse files Browse the repository at this point in the history
  • Loading branch information
timoheddes committed Oct 3, 2023
1 parent 82eb94a commit a15f04b
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ export const Dynamic: IStory = {
render: ({ linked }) => {
return (
<NavAccordion.Root linked={linked} initialOpenSection={-1}>
{/* <NavAccordion.Link>Introduction</NavAccordion.Link> */}
<NavAccordion.Section title="Developers">
<NavAccordion.Group title="Guides">
<NavAccordion.Link href="#pact">
Expand All @@ -70,7 +69,6 @@ export const Dynamic: IStory = {
Technical Grants
</NavAccordion.Link>
</NavAccordion.Section>
{/* <NavAccordion.Link>Pact Reference</NavAccordion.Link> */}
</NavAccordion.Root>
);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
navAccordionGroupIconClass,
navAccordionGroupListClass,
navAccordionGroupTitleClass,
navAccordionListItemClass,
} from './NavAccordion.css';
import type { INavAccordionLinkProps } from './NavAccordionLink';

Expand Down Expand Up @@ -57,18 +58,20 @@ export const NavAccordionGroup: FC<INavAccordionGroupProps> = ({
</button>
{isOpen && children && (
<ul className={navAccordionGroupListClass}>
{React.Children.map(children, (section) =>
React.cloneElement(
section as React.ReactElement<
INavAccordionLinkProps,
React.JSXElementConstructor<INavAccordionLinkProps>
>,
{
deepLink: true,
active: section.props.active,
},
),
)}
{React.Children.map(children, (section) => (
<li className={navAccordionListItemClass}>
{React.cloneElement(
section as React.ReactElement<
INavAccordionLinkProps,
React.JSXElementConstructor<INavAccordionLinkProps>
>,
{
deepLink: true,
active: section.props.active,
},
)}
</li>
))}
</ul>
)}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {
navAccordionDeepLinkClass,
navAccordionLinkActiveClass,
navAccordionLinkClass,
navAccordionListItemClass,
} from './NavAccordion.css';

import { Link } from '@components/Link';
Expand All @@ -24,16 +23,14 @@ export const NavAccordionLink: FC<INavAccordionLinkProps> = ({
href,
}) => {
return (
<li className={navAccordionListItemClass}>
<Link
_className={classNames(navAccordionLinkClass, {
[navAccordionDeepLinkClass]: deepLink,
[navAccordionLinkActiveClass]: active,
})}
href={href}
>
{children}
</Link>
</li>
<Link
_className={classNames(navAccordionLinkClass, {
[navAccordionDeepLinkClass]: deepLink,
[navAccordionLinkActiveClass]: active,
})}
href={href}
>
{children}
</Link>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,18 @@ import {
navAccordionSectionWrapperClass,
navAccordionToggleIconClass,
} from './NavAccordion.css';
import type { INavAccordionGroupProps } from './NavAccordionGroup';
import type { INavAccordionLinkProps } from './NavAccordionLink';

import { SystemIcon } from '@components/Icon';
import classNames from 'classnames';
import type { FC } from 'react';
import type { FC, FunctionComponentElement } from 'react';
import React from 'react';

export interface INavAccordionSectionProps {
children?: React.ReactNode;
children?: FunctionComponentElement<
INavAccordionGroupProps | INavAccordionLinkProps
>[];
index?: number;
isOpen?: boolean;
onClick?: () => void;
Expand Down

0 comments on commit a15f04b

Please sign in to comment.