-
-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ebba840
commit 8d74184
Showing
20 changed files
with
1,487 additions
and
834 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
'@saas-ui/theme': minor | ||
'@saas-ui/core': minor | ||
'@saas-ui/react': minor | ||
--- | ||
|
||
Added new Navbar component 🥳 |
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
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,14 @@ | ||
export type { NavbarProps } from './navbar' | ||
export type { NavbarBrandProps } from './navbar-brand' | ||
export type { NavbarContentProps } from './navbar-content' | ||
export type { NavbarItemProps } from './navbar-item' | ||
|
||
export { useNavbar } from './use-navbar' | ||
|
||
export { NavbarProvider, useNavbarContext } from './navbar-context' | ||
|
||
export { Navbar } from './navbar' | ||
export { NavbarBrand } from './navbar-brand' | ||
export { NavbarContent } from './navbar-content' | ||
export { NavbarItem } from './navbar-item' | ||
export { NavbarLink } from './navbar-link' |
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,26 @@ | ||
import { chakra, forwardRef, HTMLChakraProps } from '@chakra-ui/react' | ||
import { cx } from '@chakra-ui/utils' | ||
import { useNavBarStyles } from './navbar-context' | ||
|
||
export interface NavbarBrandProps extends HTMLChakraProps<'div'> { | ||
children?: React.ReactNode | React.ReactNode[] | ||
} | ||
|
||
export const NavbarBrand = forwardRef<NavbarBrandProps, 'div'>((props, ref) => { | ||
const { className, children, ...rest } = props | ||
|
||
const styles = useNavBarStyles() | ||
|
||
return ( | ||
<chakra.div | ||
ref={ref} | ||
__css={styles.brand} | ||
className={cx('sui-navbar__brand')} | ||
{...rest} | ||
> | ||
{children} | ||
</chakra.div> | ||
) | ||
}) | ||
|
||
NavbarBrand.displayName = 'NavbarBrand' |
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,46 @@ | ||
import { | ||
chakra, | ||
forwardRef, | ||
HTMLChakraProps, | ||
SystemProps, | ||
} from '@chakra-ui/react' | ||
import { cx } from '@chakra-ui/utils' | ||
|
||
import { useNavBarStyles } from './navbar-context' | ||
|
||
export interface NavbarContentProps extends HTMLChakraProps<'ul'> { | ||
/** | ||
* Typically the `NavbarItem` component | ||
*/ | ||
children?: React.ReactNode | React.ReactNode[] | ||
/** | ||
* Spacing between each navbar item | ||
*/ | ||
spacing?: SystemProps['margin'] | ||
} | ||
|
||
export const NavbarContent = forwardRef<NavbarContentProps, 'ul'>( | ||
(props, ref) => { | ||
const { className, children, spacing = 0, ...rest } = props | ||
|
||
const styles = useNavBarStyles() | ||
|
||
const contentStyles = { | ||
...styles.content, | ||
'& > *:not(style) ~ *:not(style)': { marginStart: spacing }, | ||
} | ||
|
||
return ( | ||
<chakra.ul | ||
ref={ref} | ||
__css={contentStyles} | ||
className={cx('sui-navbar__content', className)} | ||
{...rest} | ||
> | ||
{children} | ||
</chakra.ul> | ||
) | ||
} | ||
) | ||
|
||
NavbarContent.displayName = 'NavbarContent' |
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,20 @@ | ||
import { createContext } from '@chakra-ui/react-context' | ||
|
||
import { UseNavbarReturn } from './use-navbar' | ||
import { SystemStyleObject } from '@chakra-ui/styled-system' | ||
|
||
export const [NavbarProvider, useNavbarContext] = | ||
createContext<UseNavbarReturn>({ | ||
name: 'NavbarContext', | ||
strict: true, | ||
errorMessage: | ||
'useNavbarContext: `context` is undefined. Seems you forgot to wrap component within <Navbar />', | ||
}) | ||
|
||
export const [NavBarStylesProvider, useNavBarStyles] = createContext< | ||
Record<string, SystemStyleObject> | ||
>({ | ||
name: `NavBarStylesContext`, | ||
hookName: `useNavItemStyles`, | ||
providerName: '<NavBar />', | ||
}) |
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,33 @@ | ||
import { chakra, forwardRef, HTMLChakraProps } from '@chakra-ui/react' | ||
import { cx, dataAttr } from '@chakra-ui/utils' | ||
|
||
import { useNavBarStyles } from './navbar-context' | ||
|
||
export interface NavbarItemProps extends HTMLChakraProps<'li'> { | ||
children?: React.ReactNode | ||
/** | ||
* Whether the item is active or not. | ||
* @default false | ||
*/ | ||
isActive?: boolean | ||
} | ||
|
||
export const NavbarItem = forwardRef<NavbarItemProps, 'li'>((props, ref) => { | ||
const { className, children, isActive, ...rest } = props | ||
|
||
const styles = useNavBarStyles() | ||
|
||
return ( | ||
<chakra.li | ||
ref={ref} | ||
__css={styles.item} | ||
className={cx('sui-navbar__item', className)} | ||
data-active={dataAttr(isActive)} | ||
{...rest} | ||
> | ||
{children} | ||
</chakra.li> | ||
) | ||
}) | ||
|
||
NavbarItem.displayName = 'NavbarItem' |
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,36 @@ | ||
import { forwardRef, HTMLChakraProps } from '@chakra-ui/react' | ||
import { cx, dataAttr } from '@chakra-ui/utils' | ||
|
||
import { useNavBarStyles } from './navbar-context' | ||
import { useLink } from '../provider' | ||
|
||
export interface NavbarLinkProps extends HTMLChakraProps<'a'> { | ||
children?: React.ReactNode | ||
/** | ||
* Whether the link is active or not. | ||
* @default false | ||
*/ | ||
isActive?: boolean | ||
} | ||
|
||
export const NavbarLink = forwardRef<NavbarLinkProps, 'li'>((props, ref) => { | ||
const { className, children, isActive, ...rest } = props | ||
|
||
const Link = useLink() | ||
|
||
const styles = useNavBarStyles() | ||
|
||
return ( | ||
<Link | ||
ref={ref} | ||
__css={styles.link} | ||
data-active={dataAttr(isActive)} | ||
className={cx('sui-navbar__link', className)} | ||
{...rest} | ||
> | ||
{children} | ||
</Link> | ||
) | ||
}) | ||
|
||
NavbarLink.displayName = 'NavbarLink' |
Oops, something went wrong.