-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move TabBar component under navigation
- Loading branch information
1 parent
96fb352
commit e5189dc
Showing
3 changed files
with
69 additions
and
52 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import React, { HTMLProps } from 'react'; | ||
|
||
import { NavLink, NavLinkProps } from 'app/components/content/Link'; | ||
import { Path } from 'app/utils/routes'; | ||
|
||
import styles from './styles.module.css'; | ||
|
||
type TabBarProps = HTMLProps<HTMLElement> & { children: React.ReactNode }; | ||
const TabBar = function ({ | ||
children, | ||
className, | ||
...args | ||
}: TabBarProps): JSX.Element { | ||
return ( | ||
<nav className={[className, styles.nav].join(' ')} {...args}> | ||
<ul className={styles.navList}>{children}</ul> | ||
</nav> | ||
); | ||
}; | ||
|
||
type TabBarItemProps = HTMLProps<HTMLLIElement> & { children: React.ReactNode }; | ||
TabBar.Item = function TabBarItem(args: TabBarItemProps): JSX.Element { | ||
return <li {...args} />; | ||
}; | ||
|
||
TabBar.LinkItem = function TabBarLinkItem({ | ||
className, | ||
to, | ||
...args | ||
}: NavLinkProps): JSX.Element { | ||
if (to instanceof Path) to = to.toString(); | ||
|
||
return ( | ||
<TabBar.Item> | ||
<NavLink | ||
className={[className, styles.navLink].join(' ')} | ||
to={to} | ||
{...args} | ||
/> | ||
</TabBar.Item> | ||
); | ||
}; | ||
|
||
export default TabBar; |
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