-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
drill prop if item should be expanded or not
- Loading branch information
1 parent
38c59d3
commit 0809702
Showing
6 changed files
with
80 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,17 @@ | ||
import type { FC, PropsWithChildren } from 'react'; | ||
import React from 'react'; | ||
|
||
export interface ISideBar extends PropsWithChildren {} | ||
export interface ISideBar extends PropsWithChildren { | ||
isExpanded?: boolean; | ||
} | ||
|
||
export const SideBar: FC<ISideBar> = ({ children }) => { | ||
return <aside>{children}</aside>; | ||
export const SideBar: FC<ISideBar> = ({ children, isExpanded = false }) => { | ||
return ( | ||
<aside> | ||
{React.Children.map(children, (child) => { | ||
if (!React.isValidElement(child)) return null; | ||
return React.cloneElement(child, { ...child.props, isExpanded }); | ||
})} | ||
</aside> | ||
); | ||
}; |
20 changes: 15 additions & 5 deletions
20
packages/libs/kode-ui/src/components/SideBar/components/SideBarFooter.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,22 @@ | ||
import type { FC, PropsWithChildren } from 'react'; | ||
import React from 'react'; | ||
|
||
export interface ISideBarHeader extends PropsWithChildren {} | ||
export interface ISideBarFooter extends PropsWithChildren { | ||
isExpanded?: boolean; | ||
} | ||
|
||
export const SideBarHeader: FC<ISideBarHeader> = ({ children }) => { | ||
export const SideBarFooter: FC<ISideBarFooter> = ({ | ||
children, | ||
isExpanded = false, | ||
}) => { | ||
return ( | ||
<header> | ||
<ul>{children}</ul> | ||
</header> | ||
<footer> | ||
<ul> | ||
{React.Children.map(children, (child) => { | ||
if (!React.isValidElement(child)) return null; | ||
return React.cloneElement(child, { ...child.props, isExpanded }); | ||
})} | ||
</ul> | ||
</footer> | ||
); | ||
}; |
20 changes: 17 additions & 3 deletions
20
packages/libs/kode-ui/src/components/SideBar/components/SideBarHeader.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,22 @@ | ||
import type { FC, PropsWithChildren } from 'react'; | ||
import React from 'react'; | ||
|
||
export interface ISideBarFooter extends PropsWithChildren {} | ||
export interface ISideBarHeader extends PropsWithChildren { | ||
isExpanded?: boolean; | ||
} | ||
|
||
export const SideBarFooter: FC<ISideBarFooter> = ({ children }) => { | ||
return <ul>{children}</ul>; | ||
export const SideBarHeader: FC<ISideBarHeader> = ({ | ||
children, | ||
isExpanded = false, | ||
}) => { | ||
return ( | ||
<header> | ||
<ul> | ||
{React.Children.map(children, (child) => { | ||
if (!React.isValidElement(child)) return null; | ||
return React.cloneElement(child, { ...child.props, isExpanded }); | ||
})} | ||
</ul> | ||
</header> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 17 additions & 3 deletions
20
packages/libs/kode-ui/src/components/SideBar/components/SideBarNavigation.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,22 @@ | ||
import type { FC, PropsWithChildren } from 'react'; | ||
import React from 'react'; | ||
|
||
export interface ISideBarNavigation extends PropsWithChildren {} | ||
export interface ISideBarNavigation extends PropsWithChildren { | ||
isExpanded?: boolean; | ||
} | ||
|
||
export const SideBarNavigation: FC<ISideBarNavigation> = ({ children }) => { | ||
return <ul>{children}</ul>; | ||
export const SideBarNavigation: FC<ISideBarNavigation> = ({ | ||
children, | ||
isExpanded = false, | ||
}) => { | ||
return ( | ||
<nav> | ||
<ul> | ||
{React.Children.map(children, (child) => { | ||
if (!React.isValidElement(child)) return null; | ||
return React.cloneElement(child, { ...child.props, isExpanded }); | ||
})} | ||
</ul> | ||
</nav> | ||
); | ||
}; |