Skip to content

Commit 3cf91f9

Browse files
authored
feat(Join): Add Join Component (#363)
* using dialog element * fix ModalLegacy story meta * add glass button & neutral color * feat(Join): Add Join Component BREAKING CHANGE: replaces buttongroup and inputgroup
1 parent 2e7e0c4 commit 3cf91f9

3 files changed

Lines changed: 148 additions & 0 deletions

File tree

src/Join/Join.stories.tsx

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
import React from 'react'
2+
import { StoryFn as Story, Meta } from '@storybook/react'
3+
4+
import Join, { JoinProps } from '.'
5+
import Button from '../Button'
6+
import Input from '../Input'
7+
import Select from '../Select'
8+
import Indicator from '../Indicator'
9+
import Badge from '../Badge'
10+
11+
export default {
12+
title: 'Layout/Join (group items)',
13+
component: Join,
14+
} as Meta
15+
16+
export const Default: Story<JoinProps> = (args) => {
17+
return (
18+
<Join {...args}>
19+
<Button className="join-item">Button</Button>
20+
<Button className="join-item">Button</Button>
21+
<Button className="join-item">Button</Button>
22+
</Join>
23+
)
24+
}
25+
Default.args = {}
26+
27+
export const Vertically: Story<JoinProps> = (args) => {
28+
return (
29+
<Join {...args}>
30+
<Button className="join-item">Button</Button>
31+
<Button className="join-item">Button</Button>
32+
<Button className="join-item">Button</Button>
33+
</Join>
34+
)
35+
}
36+
Vertically.args = {
37+
vertical: true,
38+
}
39+
40+
export const ExtraElementsInTheGroup: Story<JoinProps> = (args) => {
41+
return (
42+
<Join {...args}>
43+
<div>
44+
<div>
45+
<Input className="join-item" placeholder="Search..." />
46+
</div>
47+
</div>
48+
<Select className="join-item">
49+
<Select.Option selected disabled>
50+
Category
51+
</Select.Option>
52+
<Select.Option>Sci-fi</Select.Option>
53+
<Select.Option>Drama</Select.Option>
54+
<Select.Option>Action</Select.Option>
55+
</Select>
56+
<Indicator item={<Badge color="secondary">new</Badge>}>
57+
<Button className="join-item">Search</Button>
58+
</Indicator>
59+
</Join>
60+
)
61+
}
62+
ExtraElementsInTheGroup.args = {}
63+
64+
export const CustomBorderRadius: Story<JoinProps> = (args) => {
65+
return (
66+
<Join {...args}>
67+
<Input className="join-item" placeholder="Email" />
68+
<Button className="join-item rounded-r-full">Subscribe</Button>
69+
</Join>
70+
)
71+
}
72+
CustomBorderRadius.args = {}
73+
74+
export const RadioInputsWithBtnStyle: Story<JoinProps> = (args) => {
75+
return (
76+
<Join {...args}>
77+
<Input
78+
className="join-item btn"
79+
type="radio"
80+
name="options"
81+
aria-label="Radio 1"
82+
/>
83+
<Input
84+
className="join-item btn"
85+
type="radio"
86+
name="options"
87+
aria-label="Radio 2"
88+
/>
89+
<Input
90+
className="join-item btn"
91+
type="radio"
92+
name="options"
93+
aria-label="Radio 3"
94+
/>
95+
</Join>
96+
)
97+
}
98+
RadioInputsWithBtnStyle.args = {}

src/Join/Join.tsx

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import React, { forwardRef, ReactNode } from 'react'
2+
import clsx from 'clsx'
3+
import { twMerge } from 'tailwind-merge'
4+
5+
import { IComponentBaseProps } from '../types'
6+
7+
export type JoinProps = React.HTMLAttributes<HTMLDivElement> &
8+
IComponentBaseProps & {
9+
responsive?: boolean
10+
vertical?: boolean
11+
horizontal?: boolean
12+
}
13+
14+
const Join = forwardRef<HTMLDivElement, JoinProps>(
15+
(
16+
{
17+
dataTheme,
18+
className,
19+
children,
20+
responsive,
21+
vertical,
22+
horizontal,
23+
...props
24+
},
25+
ref
26+
): JSX.Element => {
27+
const classes = twMerge(
28+
'join',
29+
clsx({
30+
'join-vertical': !responsive && vertical,
31+
'join-horizontal': !responsive && horizontal,
32+
'join-vertical lg:join-horizontal': responsive,
33+
}),
34+
className
35+
)
36+
37+
return (
38+
<div {...props} data-theme={dataTheme} className={classes} ref={ref}>
39+
{children}
40+
</div>
41+
)
42+
}
43+
)
44+
45+
Join.displayName = 'Join'
46+
47+
export default Join

src/Join/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import Join, { JoinProps as TJoinProps } from './Join'
2+
export type JoinProps = TJoinProps
3+
export default Join

0 commit comments

Comments
 (0)