Skip to content

Commit 974c5b2

Browse files
authored
Merge pull request #53 from Leets-Official/51-feat/ChatbotFloatingButton-컴포넌트-제작
[Feat] ChatbotFloatingButton 컴포넌트 제작
2 parents 4f83cd2 + af1eb42 commit 974c5b2

7 files changed

Lines changed: 82 additions & 3 deletions

File tree

src/pages/playground.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { BannerCard } from '@shared/ui/BannerCard/BannerCard';
22
import { Button } from '@shared/ui/Button/Button';
33
import { Card } from '@shared/ui/Card/Card';
4+
import { ChatbotFloatingButton } from '@shared/ui/ChatbotFloatingButton';
45
import { ChatBubble } from '@shared/ui/ChatBubble';
56
import { ChatInput } from '@shared/ui/ChatInput';
67
import { ChatPromptList } from '@shared/ui/ChatPromptList';
@@ -161,6 +162,11 @@ export default function Playground() {
161162
onSend={() => {}}
162163
/>
163164
</section>
165+
{/* Chatbot Floating Button */}
166+
<section className="flex flex-col gap-4">
167+
<h2 className="typo-body-1">ChatbotFloatingButton</h2>
168+
<ChatbotFloatingButton />
169+
</section>
164170
{/* Favorite Button */}
165171
<section className="flex flex-col gap-4">
166172
<h2 className="typo-body-1">FavoriteButton</h2>

src/shared/assets/icons/common/chatbot.svg

Lines changed: 9 additions & 0 deletions
Loading

src/shared/assets/icons/common/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ export { default as HeartIcon } from './heart-outline.svg?react';
77
export { default as AlertDotIcon } from './alertdot.svg?react';
88
export { default as HamburgerIcon } from './hamburger-md.svg?react';
99
export { default as kakaoLoginImg } from './kakao.png';
10+
export { default as ChatbotIcon } from './chatbot.svg?react';

src/shared/assets/icons/index.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
export {
22
AlertDotIcon,
3+
HamburgerIcon,
4+
kakaoLoginImg,
35
CaretDownMdIcon,
46
CheckIcon,
57
DoneIcon,
6-
HamburgerIcon,
78
HeartIcon,
8-
kakaoLoginImg,
9-
SearchMagnifyingGlassIcon,
109
SendIcon,
10+
SearchMagnifyingGlassIcon,
11+
ChatbotIcon,
1112
} from './common';
1213
export { GearIcon, ShoppingIcon, SellIcon } from './banner';
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { ChatbotIcon } from '@shared/assets/icons';
2+
import { chatbotFloatingButtonVariants } from './ChatbotFloatingButton.variants';
3+
import type { ComponentPropsWithoutRef } from 'react';
4+
5+
export type ChatbotFloatingButtonProps = ComponentPropsWithoutRef<'button'> & {
6+
label?: string;
7+
};
8+
9+
export const ChatbotFloatingButton = ({
10+
label = '챗봇상담',
11+
className,
12+
type = 'button',
13+
...props
14+
}: ChatbotFloatingButtonProps) => {
15+
const styles = chatbotFloatingButtonVariants();
16+
17+
return (
18+
<button type={type} className={styles.root({ className })} aria-label={label} {...props}>
19+
<span className={styles.content()}>
20+
<ChatbotIcon className={styles.icon()} aria-hidden="true" />
21+
<span className={styles.label()}>{label}</span>
22+
</span>
23+
</button>
24+
);
25+
};
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { tv } from 'tailwind-variants';
2+
3+
export const chatbotFloatingButtonVariants = tv({
4+
slots: {
5+
root: [
6+
'group flex items-center',
7+
'w-[80px] h-[80px]',
8+
'rounded-full',
9+
'bg-[var(--color-gray-50)]',
10+
'shadow-[0_4px_4px_0_var(--color-gray-100)]',
11+
'p-0',
12+
'overflow-hidden',
13+
'transition-[width,background-color,box-shadow] duration-200 ease-out',
14+
'hover:py-[9px] hover:pl-[8px] hover:pr-[19px]',
15+
'focus-visible:py-[9px] focus-visible:pl-[8px] focus-visible:pr-[19px]',
16+
'hover:w-[182px] hover:bg-[var(--color-gray-200)]',
17+
'focus-visible:w-[182px] focus-visible:bg-[var(--color-gray-200)]',
18+
],
19+
content: [
20+
'flex items-center justify-center w-full h-full',
21+
'gap-0 transition-[gap] duration-200 ease-out',
22+
'group-hover:justify-start group-focus-visible:justify-start',
23+
'group-hover:gap-0 group-focus-visible:gap-0',
24+
'group-hover:w-[144px] group-hover:h-[67px] group-focus-visible:w-[144px] group-focus-visible:h-[67px]',
25+
'group-hover:mx-auto group-focus-visible:mx-auto',
26+
],
27+
icon: ['w-[74px] h-[67px] shrink-0'],
28+
label: [
29+
'typo-title-3 text-[var(--color-black)] whitespace-nowrap',
30+
'opacity-0 max-w-0 translate-x-2',
31+
'transition-[opacity,transform,max-width] duration-200 ease-out',
32+
'group-hover:opacity-100 group-hover:max-w-[120px] group-hover:translate-x-0',
33+
'group-focus-visible:opacity-100 group-focus-visible:max-w-[120px] group-focus-visible:translate-x-0',
34+
],
35+
},
36+
});
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { ChatbotFloatingButton } from './ChatbotFloatingButton';

0 commit comments

Comments
 (0)