-
Notifications
You must be signed in to change notification settings - Fork 0
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
43cd8d6
commit f1bcf97
Showing
7 changed files
with
123 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
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,34 @@ | ||
import type { Meta, StoryObj } from "@storybook/react" | ||
|
||
import { FeatureCard } from "~/ui/FeatureCard" | ||
import { default as FeatureCardDefault } from "~/ui/FeatureCard/FeatureCard.stories" | ||
|
||
import { Sidebar } from "./Sidebar" | ||
|
||
type Story = StoryObj<typeof Sidebar> | ||
|
||
// Meta | ||
export default { | ||
title: "UI/Sidebar", | ||
component: Sidebar, | ||
args: { | ||
...Sidebar.defaultProps, | ||
children: ( | ||
<> | ||
Witam | ||
<Sidebar.Separator /> | ||
<div className="flex-1" /> | ||
<FeatureCard theme="gray" variant="outline" closer> | ||
{FeatureCardDefault.args.children} | ||
</FeatureCard> | ||
<Sidebar.Separator /> | ||
Żegnam | ||
</> | ||
), | ||
}, | ||
} satisfies Meta | ||
|
||
// Stories | ||
export const Default = { | ||
args: {}, | ||
} satisfies Story |
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,30 @@ | ||
import { forwardRef } from "react" | ||
import type { HTMLAttributes } from "react" | ||
|
||
import { cx, type VariantProps } from "~/shared/cva" | ||
|
||
import { sidebarSeparatorVariants, sidebarVariants } from "./Sidebar.variants" | ||
|
||
export type SidebarElement = HTMLDivElement | ||
|
||
export type SidebarProps = HTMLAttributes<SidebarElement> & VariantProps<typeof sidebarVariants> | ||
|
||
const SidebarBase = forwardRef<SidebarElement, SidebarProps>((props, ref) => { | ||
const { className, ...rest } = props | ||
|
||
return <div className={cx(sidebarVariants({ className }))} ref={ref} {...rest} /> | ||
}) | ||
|
||
const SidebarSeparator = forwardRef<HTMLHRElement, HTMLAttributes<HTMLHRElement>>((props, ref) => { | ||
const { className, ...rest } = props | ||
|
||
return <hr className={cx(sidebarSeparatorVariants({ className }))} ref={ref} {...rest} /> | ||
}) | ||
|
||
export const Sidebar = Object.assign(SidebarBase, { | ||
Separator: SidebarSeparator, | ||
}) | ||
|
||
Sidebar.defaultProps = {} | ||
|
||
Sidebar.displayName = "Sidebar" |
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 { cva } from "~/shared/cva" | ||
|
||
export const sidebarVariants = cva({ | ||
base: "sticky top-0 z-40 flex h-screen w-72 shrink-0 flex-col gap-y-5 overflow-y-scroll border-r p-5", | ||
|
||
variants: { | ||
theme: { | ||
blue: "", | ||
orange: "", | ||
red: "", | ||
yellow: "", | ||
green: "", | ||
purple: "", | ||
pink: "", | ||
teal: "", | ||
gray: "", | ||
}, | ||
variant: { | ||
solid: "", | ||
soft: "", | ||
outline: "border-gray-200", | ||
}, | ||
}, | ||
|
||
defaultVariants: { | ||
theme: "gray", | ||
variant: "soft", | ||
}, | ||
}) | ||
|
||
export const sidebarSeparatorVariants = cva({ | ||
base: "-mx-5", | ||
}) |
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,2 @@ | ||
export { Sidebar } from "./Sidebar" | ||
export type { SidebarProps, SidebarElement } from "./Sidebar" |