@yusufalperendumlu/component-library 0.0.6 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,65 +1,65 @@
1
- import React, { useState } from "react";
2
- import { Meta, StoryObj } from "@storybook/react";
3
-
4
- import Autocomplete from "./Autocomplete";
5
-
6
- const meta: Meta<typeof Autocomplete> = {
7
- title: "Components/Autocomplete",
8
- component: Autocomplete,
9
- tags: ["autodocs"],
10
- argTypes: {
11
- placeholder: { control: "text" },
12
- className: { control: false },
13
- },
14
- };
15
-
16
- export default meta;
17
- type Story = StoryObj<typeof Autocomplete>;
18
-
19
- const sampleOptions = [
20
- { id: 1, name: "JavaScript" },
21
- { id: 2, name: "TypeScript" },
22
- { id: 3, name: "Python" },
23
- { id: 4, name: "Rust" },
24
- { id: 5, name: "Go" },
25
- { id: 6, name: "Java" },
26
- ];
27
-
28
- export const Default: Story = {
29
- render: (args) => {
30
- const [selected, setSelected] = useState<typeof sampleOptions>([]);
31
-
32
- return (
33
- <div className="max-w-md mx-auto mt-10">
34
- <Autocomplete
35
- {...args}
36
- options={sampleOptions}
37
- selected={selected}
38
- setSelected={setSelected}
39
- showChosen={false}
40
- placeholder="Choose a language"
41
- label="Choose a language"
42
- />
43
- </div>
44
- );
45
- },
46
- };
47
-
48
- export const WithChosen: Story = {
49
- render: (args) => {
50
- const [selected, setSelected] = useState<typeof sampleOptions>([]);
51
-
52
- return (
53
- <div className="max-w-md mx-auto mt-10">
54
- <Autocomplete
55
- {...args}
56
- options={sampleOptions}
57
- selected={selected}
58
- setSelected={setSelected}
59
- placeholder="Choose languages"
60
- showChosen
61
- />
62
- </div>
63
- );
64
- },
65
- };
1
+ import React, { useState } from 'react';
2
+ import { Meta, StoryObj } from '@storybook/react';
3
+
4
+ import Autocomplete from './Autocomplete';
5
+
6
+ const meta: Meta<typeof Autocomplete> = {
7
+ title: 'Components/Autocomplete',
8
+ component: Autocomplete,
9
+ tags: ['autodocs'],
10
+ argTypes: {
11
+ placeholder: { control: 'text' },
12
+ className: { control: false },
13
+ },
14
+ };
15
+
16
+ export default meta;
17
+ type Story = StoryObj<typeof Autocomplete>;
18
+
19
+ const sampleOptions = [
20
+ { id: 1, name: 'JavaScript' },
21
+ { id: 2, name: 'TypeScript' },
22
+ { id: 3, name: 'Python' },
23
+ { id: 4, name: 'Rust' },
24
+ { id: 5, name: 'Go' },
25
+ { id: 6, name: 'Java' },
26
+ ];
27
+
28
+ export const Default: Story = {
29
+ render: args => {
30
+ const [selected, setSelected] = useState<typeof sampleOptions>([]);
31
+
32
+ return (
33
+ <div className='max-w-md mx-auto mt-10'>
34
+ <Autocomplete
35
+ {...args}
36
+ options={sampleOptions}
37
+ selected={selected}
38
+ setSelected={setSelected}
39
+ showChosen={false}
40
+ placeholder='Choose a language'
41
+ label='Choose a language'
42
+ />
43
+ </div>
44
+ );
45
+ },
46
+ };
47
+
48
+ export const WithChosen: Story = {
49
+ render: args => {
50
+ const [selected, setSelected] = useState<typeof sampleOptions>([]);
51
+
52
+ return (
53
+ <div className='max-w-md mx-auto mt-10'>
54
+ <Autocomplete
55
+ {...args}
56
+ options={sampleOptions}
57
+ selected={selected}
58
+ setSelected={setSelected}
59
+ placeholder='Choose languages'
60
+ showChosen
61
+ />
62
+ </div>
63
+ );
64
+ },
65
+ };
@@ -1,52 +1,52 @@
1
- import React from "react";
2
- import type { Meta, StoryObj } from "@storybook/react";
3
- import Button from "./Button";
4
-
5
- const meta: Meta<typeof Button> = {
6
- title: "Components/Button",
7
- component: Button,
8
- tags: ["autodocs"],
9
- argTypes: {
10
- variant: {
11
- control: "radio",
12
- options: ["primary", "secondary"],
13
- },
14
- onClick: { action: "clicked" },
15
- },
16
- };
17
-
18
- export default meta;
19
-
20
- type Story = StoryObj<typeof Button>;
21
-
22
- export const Primary: Story = {
23
- args: {
24
- title: "Login",
25
- variant: "primary",
26
- size: "small",
27
- },
28
- };
29
-
30
- export const Secondary: Story = {
31
- args: {
32
- title: "Show history",
33
- variant: "secondary",
34
- size: "small",
35
- },
36
- };
37
-
38
- export const Outline: Story = {
39
- args: {
40
- title: "Cancel",
41
- variant: "danger",
42
- size: "small",
43
- },
44
- };
45
-
46
- export const CustomClass: Story = {
47
- args: {
48
- title: "Custom Class Button",
49
- variant: "primary",
50
- className: "mt-4 bg-green-500 text-white hover:bg-green-600",
51
- },
52
- };
1
+ import React from 'react';
2
+ import type { Meta, StoryObj } from '@storybook/react';
3
+ import Button from './Button';
4
+
5
+ const meta: Meta<typeof Button> = {
6
+ title: 'Components/Button',
7
+ component: Button,
8
+ tags: ['autodocs'],
9
+ argTypes: {
10
+ variant: {
11
+ control: 'radio',
12
+ options: ['primary', 'secondary'],
13
+ },
14
+ onClick: { action: 'clicked' },
15
+ },
16
+ };
17
+
18
+ export default meta;
19
+
20
+ type Story = StoryObj<typeof Button>;
21
+
22
+ export const Primary: Story = {
23
+ args: {
24
+ title: 'Login',
25
+ variant: 'primary',
26
+ size: 'small',
27
+ },
28
+ };
29
+
30
+ export const Secondary: Story = {
31
+ args: {
32
+ title: 'Show history',
33
+ variant: 'secondary',
34
+ size: 'small',
35
+ },
36
+ };
37
+
38
+ export const Outline: Story = {
39
+ args: {
40
+ title: 'Cancel',
41
+ variant: 'danger',
42
+ size: 'small',
43
+ },
44
+ };
45
+
46
+ export const CustomClass: Story = {
47
+ args: {
48
+ title: 'Custom Class Button',
49
+ variant: 'primary',
50
+ className: 'mt-4 bg-green-500 text-white hover:bg-green-600',
51
+ },
52
+ };
@@ -1,102 +1,102 @@
1
- import React, { useState } from "react";
2
- import type { Meta, StoryObj } from "@storybook/react";
3
- import Dialog from "./Dialog";
4
- import Button from "../Button";
5
- const meta: Meta<typeof Dialog> = {
6
- title: "Components/Dialog",
7
- component: Dialog,
8
- tags: ["autodocs"],
9
- };
10
-
11
- export default meta;
12
- type Story = StoryObj<typeof Dialog>;
13
-
14
- const DialogWrapper = ({
15
- title,
16
- body,
17
- variant = "default",
18
- confirmText = "Update",
19
- cancelText = "Cancel",
20
- }: {
21
- title: string;
22
- body: React.ReactNode;
23
- variant?: "default" | "destructive";
24
- confirmText?: string;
25
- cancelText?: string;
26
- }) => {
27
- const [open, setOpen] = useState(false);
28
-
29
- return (
30
- <>
31
- <Button onClick={() => setOpen(true)} variant="outline" title={title} />
32
- <Dialog isOpen={open} onClose={() => setOpen(false)}>
33
- <Dialog.Header>{title}</Dialog.Header>
34
- <Dialog.Body>{body}</Dialog.Body>
35
- <Dialog.Footer>
36
- <Button
37
- variant="outline"
38
- onClick={() => setOpen(false)}
39
- title={cancelText}
40
- size="small"
41
- />
42
-
43
- <Button
44
- onClick={() => setOpen(false)}
45
- title={confirmText}
46
- variant="primary"
47
- size="small"
48
- />
49
- </Dialog.Footer>
50
- </Dialog>
51
- </>
52
- );
53
- };
54
-
55
- // 🟣 Update Dialog
56
- export const UpdateDialog: Story = {
57
- render: () => (
58
- <DialogWrapper
59
- title="Update XY1234"
60
- body={
61
- <>
62
- <div className="mb-4">
63
- <label className="block text-sm mb-1">Type</label>
64
- <select className="w-full border rounded p-2 dark:bg-zinc-800">
65
- <option>Passenger</option>
66
- <option>Cargo</option>
67
- </select>
68
- </div>
69
- <div>
70
- <label className="block text-sm mb-1">Classification</label>
71
- <select className="w-full border rounded p-2 dark:bg-zinc-800">
72
- <option>Friendly</option>
73
- <option>Hostile</option>
74
- </select>
75
- </div>
76
- </>
77
- }
78
- />
79
- ),
80
- };
81
-
82
- // 🔴 Delete Dialog
83
- export const DeleteDialog: Story = {
84
- render: () => (
85
- <DialogWrapper
86
- title="Delete XY1234"
87
- variant="destructive"
88
- confirmText="Delete"
89
- body={
90
- <>
91
- <p className="text-base font-semibold text-zinc-900 dark:text-white">
92
- Are you sure you want to delete aircraft XY1234?
93
- </p>
94
- <p className="text-sm text-zinc-500 dark:text-zinc-400 mt-2">
95
- This action cannot be undone. The aircraft will be permanently
96
- removed from the system.
97
- </p>
98
- </>
99
- }
100
- />
101
- ),
102
- };
1
+ import React, { useState } from 'react';
2
+ import type { Meta, StoryObj } from '@storybook/react';
3
+ import Dialog from './Dialog';
4
+ import Button from '../Button';
5
+ const meta: Meta<typeof Dialog> = {
6
+ title: 'Components/Dialog',
7
+ component: Dialog,
8
+ tags: ['autodocs'],
9
+ };
10
+
11
+ export default meta;
12
+ type Story = StoryObj<typeof Dialog>;
13
+
14
+ const DialogWrapper = ({
15
+ title,
16
+ body,
17
+ variant = 'default',
18
+ confirmText = 'Update',
19
+ cancelText = 'Cancel',
20
+ }: {
21
+ title: string;
22
+ body: React.ReactNode;
23
+ variant?: 'default' | 'destructive';
24
+ confirmText?: string;
25
+ cancelText?: string;
26
+ }) => {
27
+ const [open, setOpen] = useState(false);
28
+
29
+ return (
30
+ <>
31
+ <Button onClick={() => setOpen(true)} variant='outline' title={title} />
32
+ <Dialog isOpen={open} onClose={() => setOpen(false)}>
33
+ <Dialog.Header>{title}</Dialog.Header>
34
+ <Dialog.Body>{body}</Dialog.Body>
35
+ <Dialog.Footer>
36
+ <Button
37
+ variant='outline'
38
+ onClick={() => setOpen(false)}
39
+ title={cancelText}
40
+ size='small'
41
+ />
42
+
43
+ <Button
44
+ onClick={() => setOpen(false)}
45
+ title={confirmText}
46
+ variant='primary'
47
+ size='small'
48
+ />
49
+ </Dialog.Footer>
50
+ </Dialog>
51
+ </>
52
+ );
53
+ };
54
+
55
+ // 🟣 Update Dialog
56
+ export const UpdateDialog: Story = {
57
+ render: () => (
58
+ <DialogWrapper
59
+ title='Update XY1234'
60
+ body={
61
+ <>
62
+ <div className='mb-4'>
63
+ <label className='block text-sm mb-1'>Type</label>
64
+ <select className='w-full border rounded p-2 dark:bg-zinc-800'>
65
+ <option>Passenger</option>
66
+ <option>Cargo</option>
67
+ </select>
68
+ </div>
69
+ <div>
70
+ <label className='block text-sm mb-1'>Classification</label>
71
+ <select className='w-full border rounded p-2 dark:bg-zinc-800'>
72
+ <option>Friendly</option>
73
+ <option>Hostile</option>
74
+ </select>
75
+ </div>
76
+ </>
77
+ }
78
+ />
79
+ ),
80
+ };
81
+
82
+ // 🔴 Delete Dialog
83
+ export const DeleteDialog: Story = {
84
+ render: () => (
85
+ <DialogWrapper
86
+ title='Delete XY1234'
87
+ variant='destructive'
88
+ confirmText='Delete'
89
+ body={
90
+ <>
91
+ <p className='text-base font-semibold text-zinc-900 dark:text-white'>
92
+ Are you sure you want to delete aircraft XY1234?
93
+ </p>
94
+ <p className='text-sm text-zinc-500 dark:text-zinc-400 mt-2'>
95
+ This action cannot be undone. The aircraft will be permanently
96
+ removed from the system.
97
+ </p>
98
+ </>
99
+ }
100
+ />
101
+ ),
102
+ };
@@ -1,34 +1,34 @@
1
- import React from "react";
2
- import type { Meta, StoryObj } from "@storybook/react";
3
- import Input from "./Input";
4
-
5
- const meta: Meta<typeof Input> = {
6
- title: "Components/Input",
7
- component: Input,
8
- tags: ["autodocs"],
9
- argTypes: {
10
- placeholder: {
11
- control: "text",
12
- description: "Placeholder text for the input field",
13
- },
14
- },
15
- };
16
-
17
- export default meta;
18
-
19
- type Story = StoryObj<typeof Input>;
20
-
21
- export const Primary: Story = {
22
- args: {
23
- label: "Input",
24
- placeholder: "Enter text here",
25
- type: "text",
26
- },
27
- };
28
-
29
- export const Secondary: Story = {
30
- args: {
31
- placeholder: "Search...",
32
- type: "dropdown",
33
- },
34
- };
1
+ import React from 'react';
2
+ import type { Meta, StoryObj } from '@storybook/react';
3
+ import Input from './Input';
4
+
5
+ const meta: Meta<typeof Input> = {
6
+ title: 'Components/Input',
7
+ component: Input,
8
+ tags: ['autodocs'],
9
+ argTypes: {
10
+ placeholder: {
11
+ control: 'text',
12
+ description: 'Placeholder text for the input field',
13
+ },
14
+ },
15
+ };
16
+
17
+ export default meta;
18
+
19
+ type Story = StoryObj<typeof Input>;
20
+
21
+ export const Primary: Story = {
22
+ args: {
23
+ label: 'Input',
24
+ placeholder: 'Enter text here',
25
+ type: 'text',
26
+ },
27
+ };
28
+
29
+ export const Secondary: Story = {
30
+ args: {
31
+ placeholder: 'Search...',
32
+ type: 'dropdown',
33
+ },
34
+ };
@@ -1,53 +1,53 @@
1
- import React from "react";
2
- import { Meta, StoryFn } from "@storybook/react";
3
- import Table from "./Table";
4
- import { TableColumn } from "./Table.types";
5
-
6
- interface Person {
7
- id: number;
8
- name: string;
9
- age: number;
10
- email: string;
11
- }
12
-
13
- const columns: TableColumn<Person>[] = [
14
- { key: "id", label: "ID", sortable: true },
15
- { key: "name", label: "Name", sortable: true },
16
- { key: "age", label: "Age", sortable: true },
17
- {
18
- key: "email",
19
- label: "Email",
20
- render: (value) => (
21
- <a href={`mailto:${value}`} className="text-blue-400 underline">
22
- {value}
23
- </a>
24
- ),
25
- },
26
- ];
27
-
28
- const data: Person[] = [
29
- { id: 1, name: "Alice", age: 28, email: "alice@example.com" },
30
- { id: 2, name: "Bob", age: 34, email: "bob@example.com" },
31
- { id: 3, name: "Charlie", age: 22, email: "charlie@example.com" },
32
- ];
33
-
34
- const meta: Meta<typeof Table> = {
35
- title: "Components/Table",
36
- component: Table,
37
- argTypes: {
38
- onRowClick: { action: "row clicked" },
39
- },
40
- };
41
-
42
- export default meta;
43
-
44
- const Template: StoryFn<React.ComponentProps<typeof Table<Person>>> = (
45
- args
46
- ) => <Table {...args} />;
47
-
48
- export const Default = Template.bind({});
49
- Default.args = {
50
- columns,
51
- data,
52
- onRowClick: (row) => console.log("Row clicked:", row),
53
- };
1
+ import React from 'react';
2
+ import { Meta, StoryFn } from '@storybook/react';
3
+ import Table from './Table';
4
+ import { TableColumn } from './Table.types';
5
+
6
+ interface Person {
7
+ id: number;
8
+ name: string;
9
+ age: number;
10
+ email: string;
11
+ }
12
+
13
+ const columns: TableColumn<Person>[] = [
14
+ { key: 'id', label: 'ID', sortable: true },
15
+ { key: 'name', label: 'Name', sortable: true },
16
+ { key: 'age', label: 'Age', sortable: true },
17
+ {
18
+ key: 'email',
19
+ label: 'Email',
20
+ render: value => (
21
+ <a href={`mailto:${value}`} className='text-blue-400 underline'>
22
+ {value}
23
+ </a>
24
+ ),
25
+ },
26
+ ];
27
+
28
+ const data: Person[] = [
29
+ { id: 1, name: 'Alice', age: 28, email: 'alice@example.com' },
30
+ { id: 2, name: 'Bob', age: 34, email: 'bob@example.com' },
31
+ { id: 3, name: 'Charlie', age: 22, email: 'charlie@example.com' },
32
+ ];
33
+
34
+ const meta: Meta<typeof Table> = {
35
+ title: 'Components/Table',
36
+ component: Table,
37
+ argTypes: {
38
+ onRowClick: { action: 'row clicked' },
39
+ },
40
+ };
41
+
42
+ export default meta;
43
+
44
+ const Template: StoryFn<React.ComponentProps<typeof Table<Person>>> = args => (
45
+ <Table {...args} />
46
+ );
47
+
48
+ export const Default = Template.bind({});
49
+ Default.args = {
50
+ columns,
51
+ data,
52
+ onRowClick: row => console.log('Row clicked:', row),
53
+ };
@@ -0,0 +1,44 @@
1
+ // Toast.stories.tsx
2
+ import React from 'react';
3
+ import type { Meta, StoryObj } from '@storybook/react';
4
+ import Toast from './Toast';
5
+
6
+ const meta: Meta<typeof Toast> = {
7
+ title: 'Components/Toast',
8
+ component: Toast,
9
+ tags: ['autodocs'],
10
+ argTypes: {
11
+ type: {
12
+ control: 'radio',
13
+ options: ['success', 'error'],
14
+ },
15
+ position: {
16
+ control: 'radio',
17
+ options: ['top-left', 'top-right', 'bottom-left', 'bottom-right'],
18
+ },
19
+ },
20
+ };
21
+
22
+ export default meta;
23
+
24
+ type Story = StoryObj<typeof Toast>;
25
+
26
+ export const SuccessTopRight: Story = {
27
+ args: {
28
+ title: 'Success',
29
+ description: 'Operation was successful!',
30
+ duration: 3000,
31
+ type: 'success',
32
+ position: 'top-right',
33
+ },
34
+ };
35
+
36
+ export const ErrorBottomLeft: Story = {
37
+ args: {
38
+ title: 'Error',
39
+ description: 'Something went wrong!',
40
+ duration: 3000,
41
+ type: 'error',
42
+ position: 'bottom-left',
43
+ },
44
+ };