Skip to content
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

ADCIO-3112) feat: option list #29

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/ColorPicker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { HexAlphaColorPicker } from 'react-colorful';
import styled from '@emotion/styled';

import { TextInput } from '../Input';
import useClickOutside from '../Input/hook';
import useClickOutside from '../../utils/hooks/useClickOutside';
import { B3 } from '../Text';
import { color } from '../styles';

Expand Down
4 changes: 4 additions & 0 deletions src/components/OptionList/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { type BasicOptionItem, OptionList, type SectionOptionItem } from './OptionList';

export { OptionList };
export type { BasicOptionItem, SectionOptionItem };
2 changes: 1 addition & 1 deletion src/components/Select/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { type KeyboardEvent, useCallback, useEffect, useMemo, useRef, useState }

import styled from '@emotion/styled';

import { type BasicOptionItem, OptionList } from './OptionList';
import { type BasicOptionItem, OptionList } from '../OptionList';
import { SelectInput, type SelectInputBaseProps } from './SelectInput';
import Icon from '../Icon';

Expand Down
4 changes: 1 addition & 3 deletions src/components/Select/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { type BasicOptionItem, OptionList, type SectionOptionItem } from './OptionList';
import { Select } from './Select';

export { OptionList, Select };
export type { BasicOptionItem, SectionOptionItem };
export { Select };
1 change: 1 addition & 0 deletions src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ export * from './Tooltip';
export * from './Topbar';
export * from './Filter';
export * from './Spinner';
export * from './OptionList';
98 changes: 98 additions & 0 deletions src/stories/OptionList.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import { StoryFn } from '@storybook/react';

import styled from '@emotion/styled';

import { type BasicOptionItem, OptionList, SectionOptionItem } from '../components';
import Icon from '../components/Icon';

export default {
title: 'Components/OptionList',
component: OptionList,
tags: ['autodocs'],
decorators: [
(Story: StoryFn) => (
<Container>
<Story />
</Container>
),
],
parameters: {
design: {
type: 'figma',
// TODO: λ‚˜κ²½
url: 'https://www.figma.com/file/tN7Q8dJZqVsjo2FWflOKfu/CDS(Corca-Design-System)?type=design&node-id=435-14814&mode=design&t=8a3wutSi3o4LHHer-4',
},
},
};

const Container = styled.div`
width: 100%;
height: 100%;
min-height: 600px;
display: flex;
flex-direction: column;
align-items: flex-start;
justify-content: flex-start;
padding: 50px;
text-align: center;
line-height: normal;
gap: 20px;
`;

const BASIC: BasicOptionItem[] = [
{ label: 'Label1 with Icon', value: '1', icon: Icon.QuestionCircle },
{
label: 'Label2 with Icon and disabled',
value: '2',
disabled: true,
icon: Icon.Shop,
},
{ label: 'Label3 with just disabled', value: '3', disabled: true },
{ label: 'Label4', value: '4' },
{ label: 'Label5', value: '5' },
];

const SECTION_EXAMPLE: SectionOptionItem[] = [
{
sectionTitle: 'Section 1',
sectionItems: BASIC.slice(0, 2),
},
{
sectionTitle: 'Section 2',
sectionItems: BASIC.slice(2),
},
];

const Template: StoryFn<typeof OptionList> = args => {
return <OptionList {...args} />;
};

export const BasicControllable = Template.bind({});
BasicControllable.args = {
value: '',
onChange: () => {},
width: 400,
option: { type: 'basic', items: BASIC },
};

export function Basic() {
return (
<OptionList
width={400}
option={{ type: 'basic', items: BASIC }}
onChange={() => {}}
value={''}
/>
);
}

export function Section() {
return (
<OptionList
width={400}
option={{ type: 'section', items: SECTION_EXAMPLE }}
onChange={value => {}}
value={''}
/>
);
}
3 changes: 3 additions & 0 deletions src/utils/hooks/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import useClickOutside from './useClickOutside';

export { useClickOutside };
File renamed without changes.
1 change: 1 addition & 0 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './date';
export * from './types/locale.types';
export * from './hooks';