-
Notifications
You must be signed in to change notification settings - Fork 3
허들 툴바 구현 #73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
허들 툴바 구현 #73
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0c98508
#60 feat(fe):toggle컴포넌트 구현 및 스토리북문서화
handje 7274f82
#60 fix(fe): toggle스타일 수정
handje bec521d
#60 feat(fe): toggle-group구현 및 스토리북 문서화
handje 18d672c
#60 refactor(fe):ToggleGroup을 Toggle폴더로 이동
handje b2b9cda
Merge branch 'dev' of https://github.com/sgdevcamp2025/c_sharp into f…
handje File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 { Toggle } from './toggle'; |
44 changes: 44 additions & 0 deletions
44
src/frontend/packages/ui/src/components/Toggle/toggle.stories.tsx
This file contains hidden or 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,44 @@ | ||
| import type { Meta, StoryObj } from '@storybook/react'; | ||
| import { Toggle } from './toggle'; | ||
| import { Mic, MicOff } from 'lucide-react'; | ||
| import { useState } from 'react'; | ||
|
|
||
| const meta: Meta<typeof Toggle> = { | ||
| title: 'Widget/Toggle', | ||
| component: Toggle, | ||
| parameters: { | ||
| layout: 'centered', | ||
| }, | ||
| tags: ['autodocs'], | ||
| argTypes: { | ||
| variant: { | ||
| control: 'select', | ||
| options: ['default', 'outline'], | ||
| }, | ||
| size: { | ||
| control: 'radio', | ||
| options: ['default', 'lg'], | ||
| }, | ||
| }, | ||
| }; | ||
| export default meta; | ||
| type Story = StoryObj<typeof Toggle>; | ||
|
|
||
| export const Default: Story = { | ||
| args: { | ||
| variant: 'outline', | ||
| size: 'default', | ||
| }, | ||
| render: (args) => { | ||
| const [isPressed, setIsPressed] = useState(false); | ||
| return ( | ||
| <Toggle | ||
| {...args} | ||
| pressed={isPressed} | ||
| onPressedChange={setIsPressed} | ||
| > | ||
| {isPressed ? <Mic /> : <MicOff />} | ||
| </Toggle> | ||
| ); | ||
| }, | ||
| }; |
This file contains hidden or 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,40 @@ | ||
| 'use client'; | ||
|
|
||
| import * as React from 'react'; | ||
| import * as TogglePrimitive from '@radix-ui/react-toggle'; | ||
| import { cva, type VariantProps } from 'class-variance-authority'; | ||
| import { cn } from '@workspace/ui/lib/utils'; | ||
|
|
||
| const toggleVariants = cva( | ||
| 'inline-flex items-center justify-center rounded-full text-sm font-medium text-muted-foreground ring-offset-background transition-colors hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 gap-2', | ||
| { | ||
| variants: { | ||
| variant: { | ||
| default: 'bg-transparent', | ||
| outline: 'border border-input bg-transparent hover:text-accent-foreground', | ||
| }, | ||
| size: { | ||
| default: 'w-10 h-10 px-3', | ||
| lg: 'w-12 h-12 px-5', | ||
| }, | ||
| }, | ||
| defaultVariants: { | ||
| variant: 'outline', | ||
| size: 'default', | ||
| }, | ||
| }, | ||
| ); | ||
|
|
||
| const Toggle = React.forwardRef<React.ElementRef<typeof TogglePrimitive.Root>, React.ComponentPropsWithoutRef<typeof TogglePrimitive.Root> & VariantProps<typeof toggleVariants>>( | ||
| ({ className, variant, size, ...props }, ref) => ( | ||
| <TogglePrimitive.Root | ||
| ref={ref} | ||
| className={cn(toggleVariants({ variant, size, className }))} | ||
| {...props} | ||
| /> | ||
| ), | ||
| ); | ||
|
|
||
| Toggle.displayName = TogglePrimitive.Root.displayName; | ||
|
|
||
| export { Toggle, toggleVariants }; |
This file contains hidden or 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 { ToggleGroup, ToggleGroupItem } from './toggle-group'; |
49 changes: 49 additions & 0 deletions
49
src/frontend/packages/ui/src/components/ToggleGroup/toggle-group.stories.tsx
This file contains hidden or 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,49 @@ | ||
| import type { Meta, StoryObj } from '@storybook/react'; | ||
| import { ToggleGroup, ToggleGroupItem } from './toggle-group'; | ||
| import { useState } from 'react'; | ||
| import { Mic, MicOff, ScreenShare, ScreenShareOff, Video, VideoOff } from 'lucide-react'; | ||
|
|
||
| const meta: Meta<typeof ToggleGroup> = { | ||
| title: 'Widget/ToggleGroup', | ||
| component: ToggleGroup, | ||
| parameters: { | ||
| layout: 'centered', | ||
| }, | ||
| tags: ['autodocs'], | ||
| }; | ||
| export default meta; | ||
| type Story = StoryObj<typeof ToggleGroup>; | ||
|
|
||
| export const Default: Story = { | ||
| render: () => { | ||
| const [isMicOn, setIsMicOn] = useState(false); | ||
| const [isVideoOn, setIsVideoOn] = useState(false); | ||
| const [isScreenSharing, setIsScreenSharing] = useState(false); | ||
|
|
||
| return ( | ||
| <ToggleGroup | ||
| variant="outline" | ||
| type="multiple" | ||
| > | ||
| <ToggleGroupItem | ||
| value="mic" | ||
| onClick={() => setIsMicOn((prev) => !prev)} | ||
| > | ||
| {isMicOn ? <Mic /> : <MicOff />} | ||
| </ToggleGroupItem> | ||
| <ToggleGroupItem | ||
| value="video" | ||
| onClick={() => setIsVideoOn((prev) => !prev)} | ||
| > | ||
| {isVideoOn ? <Video /> : <VideoOff />} | ||
| </ToggleGroupItem> | ||
| <ToggleGroupItem | ||
| value="sharing" | ||
| onClick={() => setIsScreenSharing((prev) => !prev)} | ||
| > | ||
| {isScreenSharing ? <ScreenShare /> : <ScreenShareOff />} | ||
| </ToggleGroupItem> | ||
| </ToggleGroup> | ||
| ); | ||
| }, | ||
| }; | ||
55 changes: 55 additions & 0 deletions
55
src/frontend/packages/ui/src/components/ToggleGroup/toggle-group.tsx
This file contains hidden or 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,55 @@ | ||
| 'use client'; | ||
|
|
||
| import * as React from 'react'; | ||
| import * as ToggleGroupPrimitive from '@radix-ui/react-toggle-group'; | ||
| import { type VariantProps } from 'class-variance-authority'; | ||
|
|
||
| import { cn } from '@workspace/ui/lib/utils'; | ||
| import { toggleVariants } from '../Toggle/toggle'; | ||
|
|
||
| const ToggleGroupContext = React.createContext<VariantProps<typeof toggleVariants>>({ | ||
| size: 'default', | ||
| variant: 'outline', | ||
| }); | ||
|
|
||
| const ToggleGroup = React.forwardRef< | ||
| React.ElementRef<typeof ToggleGroupPrimitive.Root>, | ||
| React.ComponentPropsWithoutRef<typeof ToggleGroupPrimitive.Root> & VariantProps<typeof toggleVariants> | ||
| >(({ className, variant, size, children, ...props }, ref) => ( | ||
| <ToggleGroupPrimitive.Root | ||
| ref={ref} | ||
| className={cn('flex items-center justify-center gap-1', className)} | ||
| {...props} | ||
| > | ||
| <ToggleGroupContext.Provider value={{ variant, size }}>{children}</ToggleGroupContext.Provider> | ||
| </ToggleGroupPrimitive.Root> | ||
| )); | ||
|
|
||
| ToggleGroup.displayName = ToggleGroupPrimitive.Root.displayName; | ||
|
|
||
| const ToggleGroupItem = React.forwardRef< | ||
| React.ElementRef<typeof ToggleGroupPrimitive.Item>, | ||
| React.ComponentPropsWithoutRef<typeof ToggleGroupPrimitive.Item> & VariantProps<typeof toggleVariants> | ||
| >(({ className, children, variant, size, ...props }, ref) => { | ||
| const context = React.useContext(ToggleGroupContext); | ||
|
|
||
| return ( | ||
| <ToggleGroupPrimitive.Item | ||
| ref={ref} | ||
| className={cn( | ||
| toggleVariants({ | ||
| variant: context.variant || variant, | ||
| size: context.size || size, | ||
| }), | ||
| className, | ||
| )} | ||
| {...props} | ||
| > | ||
| {children} | ||
| </ToggleGroupPrimitive.Item> | ||
| ); | ||
| }); | ||
|
|
||
| ToggleGroupItem.displayName = ToggleGroupPrimitive.Item.displayName; | ||
|
|
||
| export { ToggleGroup, ToggleGroupItem }; |
This file contains hidden or 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.