generated from telekom/reuse-template
-
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
Showing
15 changed files
with
223 additions
and
24 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,24 @@ | ||
--- | ||
title: Button Group | ||
description: Displays a button group. | ||
|
||
|
||
slug: button-group | ||
|
||
primaryTag: WIP | ||
--- | ||
|
||
<ComponentPreview name="button-group/preview" /> | ||
|
||
|
||
### Examples | ||
|
||
<ComponentPreview name="button-group/preview" /> | ||
|
||
### Variants | ||
|
||
<ComponentPreview name="button-group/variants" /> | ||
|
||
### Orientation | ||
|
||
<ComponentPreview name="button-group/orientation" /> |
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,11 @@ | ||
import { Button, ButtonGroup } from "@dv/ui/components" | ||
|
||
export default function Example() { | ||
return ( | ||
<ButtonGroup orientation="vertical"> | ||
<Button>One</Button> | ||
<Button>Two</Button> | ||
<Button>Three</Button> | ||
</ButtonGroup> | ||
) | ||
} |
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,11 @@ | ||
import { Button, ButtonGroup } from "@dv/ui/components" | ||
|
||
export default function Example() { | ||
return ( | ||
<ButtonGroup variant="outline"> | ||
<Button>One</Button> | ||
<Button>Two</Button> | ||
<Button>Three</Button> | ||
</ButtonGroup> | ||
) | ||
} |
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 { Button, ButtonGroup, Heading } from "@dv/ui/components" | ||
|
||
export default function Example() { | ||
return ( | ||
<div className="flex flex-col gap-4"> | ||
<Heading level={3}>Solid Button Group</Heading> | ||
<ButtonGroup variant="solid"> | ||
<Button>One</Button> | ||
<Button>Two</Button> | ||
<Button>Three</Button> | ||
</ButtonGroup> | ||
<Heading level={3}>Ghost Button Group</Heading> | ||
<ButtonGroup variant="ghost"> | ||
<Button>One</Button> | ||
<Button>Two</Button> | ||
<Button>Three</Button> | ||
</ButtonGroup> | ||
<Heading level={3}>Outline Button Group</Heading> | ||
<ButtonGroup variant="outline"> | ||
<Button>One</Button> | ||
<Button>Two</Button> | ||
<Button>Three</Button> | ||
</ButtonGroup> | ||
</div> | ||
) | ||
} |
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 @@ | ||
export * from "./variants" |
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,47 @@ | ||
import { tv } from "tailwind-variants" | ||
import { buttonVariants } from "../button" | ||
import { cn } from "@dv/ui/utils" | ||
|
||
export const buttonGroupVariants = tv({ | ||
slots: { | ||
buttonGroup: "flex items-center", | ||
...buttonVariants.slots, | ||
button: cn( | ||
buttonVariants.slots.button, | ||
"first:rounded-r-none first:rounded-l-md last:rounded-r-md last:rounded-l-none", | ||
), | ||
}, | ||
defaultVariants: { | ||
orientation: "horizontal", | ||
gap: 0, | ||
...buttonVariants.defaultVariants, | ||
}, | ||
variants: { | ||
...buttonVariants.variants, | ||
// variants: { | ||
// ...buttonVariants.variants.variant, | ||
// outline: "first:bg-red-500 last:bg-red-500 ", | ||
// // solid: "solid", | ||
// }, | ||
variant: { | ||
...buttonVariants.variants.variant, | ||
}, | ||
orientation: { | ||
horizontal: { buttonGroup: "flex-row" }, | ||
vertical: { buttonGroup: "flex-col" }, | ||
}, | ||
gap: { | ||
0: { buttonGroup: "gap-0" }, | ||
1: { buttonGroup: "gap-1" }, | ||
2: { buttonGroup: "gap-2" }, | ||
3: { buttonGroup: "gap-3" }, | ||
4: { buttonGroup: "gap-4" }, | ||
5: { buttonGroup: "gap-5" }, | ||
6: { buttonGroup: "gap-6" }, | ||
7: { buttonGroup: "gap-7" }, | ||
8: { buttonGroup: "gap-8" }, | ||
9: { buttonGroup: "gap-9" }, | ||
10: { buttonGroup: "gap-10" }, | ||
}, | ||
}, | ||
}) |
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,11 +1,11 @@ | ||
{ | ||
"extends": "@dv/typescript-config/react-library.json", | ||
"compilerOptions": { | ||
"outDir": "dist", | ||
"paths": { | ||
"tailwind-variants": ["../../node_modules/tailwind-variants"] | ||
} | ||
}, | ||
"include": ["src"], | ||
"exclude": ["node_modules", "dist"] | ||
"extends": "@dv/typescript-config/react-library.json", | ||
"compilerOptions": { | ||
"outDir": "dist", | ||
"paths": { | ||
"tailwind-variants": ["../../node_modules/tailwind-variants"] | ||
} | ||
}, | ||
"include": ["src"], | ||
"exclude": ["node_modules", "dist"] | ||
} |
4 changes: 4 additions & 0 deletions
4
packages/ui/src/components/ui/button-group/button-group-context.ts
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,4 @@ | ||
import { buttonGroupVariants } from "@dv/styles/components/button-group" | ||
import { createStyleContext } from "../../../utils/create-style-context" | ||
|
||
export const buttonGroupContext = createStyleContext(buttonGroupVariants) |
22 changes: 22 additions & 0 deletions
22
packages/ui/src/components/ui/button-group/button-group.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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import type { ReactNode } from "react" | ||
|
||
import { buttonGroupContext } from "./button-group-context" | ||
|
||
interface ButtonGroupProps { | ||
/** The children of the button group. */ | ||
children: ReactNode | ||
|
||
/** The styles of the button group. */ | ||
className?: string | ||
} | ||
|
||
const { withProvider } = buttonGroupContext | ||
|
||
/** Displays a group of buttons with matching styles. */ | ||
const UnstyledButtonGroup = ({ children, className, ...props }: ButtonGroupProps) => { | ||
return <div {...props}>{children}</div> | ||
} | ||
|
||
const ButtonGroup = withProvider(UnstyledButtonGroup, "buttonGroup") | ||
|
||
export { ButtonGroup } |
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 @@ | ||
export * from "./button-group" |
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