Skip to content

Commit

Permalink
feat: use Toggle component in GenerateFormLinkBottomSheet
Browse files Browse the repository at this point in the history
  • Loading branch information
ooooorobo committed Sep 19, 2024
1 parent d5f1e06 commit 946e46b
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 1 deletion.
4 changes: 4 additions & 0 deletions assets/icons/ToggleOff.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions assets/icons/ToggleOn.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions src/shared/ui/Toggle/Toggle.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.Input {
display: none;
}

.Label {
cursor: pointer;
}
13 changes: 13 additions & 0 deletions src/shared/ui/Toggle/Toggle.stories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Meta, StoryObj } from '@storybook/react';
import { Toggle } from './Toggle';

const meta: Meta<typeof Toggle> = {
component: Toggle,
};

export default meta;
type Story = StoryObj<typeof meta>;

export const Default: Story = {
args: {},
};
11 changes: 11 additions & 0 deletions src/shared/ui/Toggle/Toggle.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { ToggleOff, ToggleOn } from 'src/shared/ui/icons';
import styles from './Toggle.module.css';

export const Toggle = ({ checked, onToggle }: { checked?: boolean; onToggle: (value: boolean) => void }) => {
return (
<label className={styles.Label}>
{checked ? <ToggleOn /> : <ToggleOff />}
<input className={styles.Input} type={'checkbox'} checked={checked} onChange={() => onToggle(!checked)} />
</label>
);
};
9 changes: 9 additions & 0 deletions src/shared/ui/icons/ToggleOff.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import * as React from 'react';
import type { SVGProps } from 'react';
const SvgToggleOff = (props: SVGProps<SVGSVGElement>) => (
<svg xmlns="http://www.w3.org/2000/svg" width={48} height={24} fill="none" viewBox="0 0 48 24" {...props}>
<rect width={48} height={24} fill="#EBEAEB" rx={12} />
<circle cx={12} cy={12} r={9} fill="#AFAAB1" />
</svg>
);
export default SvgToggleOff;
9 changes: 9 additions & 0 deletions src/shared/ui/icons/ToggleOn.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import * as React from 'react';
import type { SVGProps } from 'react';
const SvgToggleOn = (props: SVGProps<SVGSVGElement>) => (
<svg xmlns="http://www.w3.org/2000/svg" width={48} height={24} fill="none" viewBox="0 0 48 24" {...props}>
<rect width={48} height={24} fill="#EBEAEB" rx={12} />
<circle cx={36} cy={12} r={9} fill="#D752FF" />
</svg>
);
export default SvgToggleOn;
2 changes: 2 additions & 0 deletions src/shared/ui/icons/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ export { default as Minus } from './Minus';
export { default as Plus } from './Plus';
export { default as Refresh } from './Refresh';
export { default as Share } from './Share';
export { default as ToggleOff } from './ToggleOff';
export { default as ToggleOn } from './ToggleOn';
export { default as UncheckedRadio } from './UncheckedRadio';
3 changes: 2 additions & 1 deletion src/widgets/GenerateFormLink/GenerateFormLinkBottomSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Link, Refresh } from 'src/shared/ui/icons';
import { Button } from 'src/shared/ui/Button/Button';
import { Theme } from 'src/shared/styles/constants';
import { IconBoxButton } from '../../shared/ui/IconBoxButton/IconBoxButton';
import { Toggle } from 'src/shared/ui/Toggle/Toggle';

export const GenerateFormLinkBottomSheet = ({ isOpen, onClose }: { isOpen: boolean; onClose: () => void }) => {
return (
Expand Down Expand Up @@ -62,7 +63,7 @@ const GenerateFormBottomSheetContent = () => {
<h3>링크 설정</h3>
<div className={styles.LinkConfig}>
<p>기존 링크 활성화</p>
<input type={'checkbox'} checked={isOpen} onClick={onToggleLinkOpen} />
<Toggle onToggle={onToggleLinkOpen} checked={isOpen} />
</div>
<div className={styles.LinkConfig}>
<p>새로운 링크 생성</p>
Expand Down

0 comments on commit 946e46b

Please sign in to comment.