@integrigo/integrigo-ui 1.6.16-e → 1.6.16-f
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/index.esm.js +1 -1
- package/lib/index.js +1 -1
- package/lib/src/components/atoms/Chip/Chip.d.ts +2 -15
- package/lib/src/components/atoms/Divider/Divider.stories.d.ts +4 -4
- package/lib/src/components/molecules/Checkbox/Checkbox.stories.d.ts +4 -4
- package/lib/src/components/molecules/Radio/Radio.stories.d.ts +4 -4
- package/package.json +1 -1
- package/src/components/atoms/Chip/Chip.test.tsx +11 -9
- package/src/components/atoms/Chip/Chip.tsx +13 -28
@@ -4,23 +4,10 @@ declare type OnClickFunctionType = (e: MouseEvent<HTMLDivElement>) => void;
|
|
4
4
|
export interface ChipProps {
|
5
5
|
iconLeft?: IconType;
|
6
6
|
iconRight?: IconType;
|
7
|
-
size?:
|
7
|
+
size?: 's' | 'm' | 'l' | 'xl';
|
8
8
|
label: React.ReactNode;
|
9
|
-
variant?:
|
9
|
+
variant?: 'transparent' | 'white' | 'primary' | 'secondary' | 'grey';
|
10
10
|
onClick?: OnClickFunctionType;
|
11
11
|
}
|
12
|
-
export declare enum ChipVariant {
|
13
|
-
transparent = "transparent",
|
14
|
-
white = "white",
|
15
|
-
primary = "primary",
|
16
|
-
secondary = "secondary",
|
17
|
-
grey = "grey"
|
18
|
-
}
|
19
|
-
export declare enum ChipSize {
|
20
|
-
xl = "xl",
|
21
|
-
l = "l",
|
22
|
-
m = "m",
|
23
|
-
s = "s"
|
24
|
-
}
|
25
12
|
export declare const Chip: FC<ChipProps>;
|
26
13
|
export {};
|
@@ -1,14 +1,14 @@
|
|
1
1
|
import { ComponentStory, ComponentMeta } from '@storybook/react';
|
2
2
|
declare const _default: ComponentMeta<import("styled-components").StyledComponent<"div", any, {
|
3
|
-
variant?: "
|
3
|
+
variant?: "white" | "orange" | "navy" | undefined;
|
4
4
|
}, never>>;
|
5
5
|
export default _default;
|
6
6
|
export declare const Orange: ComponentStory<import("styled-components").StyledComponent<"div", any, {
|
7
|
-
variant?: "
|
7
|
+
variant?: "white" | "orange" | "navy" | undefined;
|
8
8
|
}, never>>;
|
9
9
|
export declare const Navy: ComponentStory<import("styled-components").StyledComponent<"div", any, {
|
10
|
-
variant?: "
|
10
|
+
variant?: "white" | "orange" | "navy" | undefined;
|
11
11
|
}, never>>;
|
12
12
|
export declare const White: ComponentStory<import("styled-components").StyledComponent<"div", any, {
|
13
|
-
variant?: "
|
13
|
+
variant?: "white" | "orange" | "navy" | undefined;
|
14
14
|
}, never>>;
|
@@ -1,19 +1,19 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import { ComponentStory, ComponentMeta } from '@storybook/react';
|
3
|
-
declare const _default: ComponentMeta<React.ForwardRefExoticComponent<Omit<React.InputHTMLAttributes<HTMLInputElement>, "
|
3
|
+
declare const _default: ComponentMeta<React.ForwardRefExoticComponent<Omit<React.InputHTMLAttributes<HTMLInputElement>, "type" | "size"> & {
|
4
4
|
size?: "s" | "m" | "l" | "xl" | undefined;
|
5
5
|
label?: string | undefined;
|
6
6
|
} & React.RefAttributes<HTMLInputElement>>>;
|
7
7
|
export default _default;
|
8
|
-
export declare const Basic: ComponentStory<React.ForwardRefExoticComponent<Omit<React.InputHTMLAttributes<HTMLInputElement>, "
|
8
|
+
export declare const Basic: ComponentStory<React.ForwardRefExoticComponent<Omit<React.InputHTMLAttributes<HTMLInputElement>, "type" | "size"> & {
|
9
9
|
size?: "s" | "m" | "l" | "xl" | undefined;
|
10
10
|
label?: string | undefined;
|
11
11
|
} & React.RefAttributes<HTMLInputElement>>>;
|
12
|
-
export declare const Controlled: ComponentStory<React.ForwardRefExoticComponent<Omit<React.InputHTMLAttributes<HTMLInputElement>, "
|
12
|
+
export declare const Controlled: ComponentStory<React.ForwardRefExoticComponent<Omit<React.InputHTMLAttributes<HTMLInputElement>, "type" | "size"> & {
|
13
13
|
size?: "s" | "m" | "l" | "xl" | undefined;
|
14
14
|
label?: string | undefined;
|
15
15
|
} & React.RefAttributes<HTMLInputElement>>>;
|
16
|
-
export declare const WithLabel: ComponentStory<React.ForwardRefExoticComponent<Omit<React.InputHTMLAttributes<HTMLInputElement>, "
|
16
|
+
export declare const WithLabel: ComponentStory<React.ForwardRefExoticComponent<Omit<React.InputHTMLAttributes<HTMLInputElement>, "type" | "size"> & {
|
17
17
|
size?: "s" | "m" | "l" | "xl" | undefined;
|
18
18
|
label?: string | undefined;
|
19
19
|
} & React.RefAttributes<HTMLInputElement>>>;
|
@@ -1,20 +1,20 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import { ComponentMeta, ComponentStory } from '@storybook/react';
|
3
3
|
import { Size } from './Radio';
|
4
|
-
declare const _default: ComponentMeta<React.ForwardRefExoticComponent<Omit<React.InputHTMLAttributes<HTMLInputElement>, "
|
4
|
+
declare const _default: ComponentMeta<React.ForwardRefExoticComponent<Omit<React.InputHTMLAttributes<HTMLInputElement>, "type" | "size"> & {
|
5
5
|
size?: Size | undefined;
|
6
6
|
label?: string | undefined;
|
7
7
|
} & React.RefAttributes<HTMLInputElement>>>;
|
8
8
|
export default _default;
|
9
|
-
export declare const Basic: ComponentStory<React.ForwardRefExoticComponent<Omit<React.InputHTMLAttributes<HTMLInputElement>, "
|
9
|
+
export declare const Basic: ComponentStory<React.ForwardRefExoticComponent<Omit<React.InputHTMLAttributes<HTMLInputElement>, "type" | "size"> & {
|
10
10
|
size?: Size | undefined;
|
11
11
|
label?: string | undefined;
|
12
12
|
} & React.RefAttributes<HTMLInputElement>>>;
|
13
|
-
export declare const Controlled: ComponentStory<React.ForwardRefExoticComponent<Omit<React.InputHTMLAttributes<HTMLInputElement>, "
|
13
|
+
export declare const Controlled: ComponentStory<React.ForwardRefExoticComponent<Omit<React.InputHTMLAttributes<HTMLInputElement>, "type" | "size"> & {
|
14
14
|
size?: Size | undefined;
|
15
15
|
label?: string | undefined;
|
16
16
|
} & React.RefAttributes<HTMLInputElement>>>;
|
17
|
-
export declare const WithLabel: ComponentStory<React.ForwardRefExoticComponent<Omit<React.InputHTMLAttributes<HTMLInputElement>, "
|
17
|
+
export declare const WithLabel: ComponentStory<React.ForwardRefExoticComponent<Omit<React.InputHTMLAttributes<HTMLInputElement>, "type" | "size"> & {
|
18
18
|
size?: Size | undefined;
|
19
19
|
label?: string | undefined;
|
20
20
|
} & React.RefAttributes<HTMLInputElement>>>;
|
package/package.json
CHANGED
@@ -1,18 +1,20 @@
|
|
1
|
-
import React from
|
2
|
-
import { render, screen } from
|
3
|
-
import userEvent from
|
4
|
-
import { Chip
|
1
|
+
import React from "react";
|
2
|
+
import { render, screen } from "@testing-library/react";
|
3
|
+
import userEvent from "@testing-library/user-event";
|
4
|
+
import { Chip } from "./Chip";
|
5
5
|
|
6
|
-
describe(
|
7
|
-
it(
|
6
|
+
describe("<Chip />", () => {
|
7
|
+
it("should match snapshot - basic", () => {
|
8
8
|
const { container } = render(<Chip label="Accept" />);
|
9
9
|
expect(container).toMatchSnapshot();
|
10
10
|
});
|
11
|
-
it(
|
12
|
-
const { container } = render(
|
11
|
+
it("should match snapshot - icon", () => {
|
12
|
+
const { container } = render(
|
13
|
+
<Chip label="Accept" variant="primary" iconLeft="close" />
|
14
|
+
);
|
13
15
|
expect(container).toMatchSnapshot();
|
14
16
|
});
|
15
|
-
it(
|
17
|
+
it("should call onclick function", async () => {
|
16
18
|
const user = userEvent.setup();
|
17
19
|
const handleClick = jest.fn();
|
18
20
|
render(<Chip label="Accept" onClick={handleClick} />);
|
@@ -7,27 +7,12 @@ type OnClickFunctionType = (e: MouseEvent<HTMLDivElement>) => void;
|
|
7
7
|
export interface ChipProps {
|
8
8
|
iconLeft?: IconType;
|
9
9
|
iconRight?: IconType;
|
10
|
-
size?:
|
10
|
+
size?: 's' | 'm' | 'l' | 'xl';
|
11
11
|
label: React.ReactNode;
|
12
|
-
variant?:
|
12
|
+
variant?: 'transparent' | 'white' | 'primary' | 'secondary' | 'grey';
|
13
13
|
onClick?: OnClickFunctionType;
|
14
14
|
}
|
15
15
|
|
16
|
-
export enum ChipVariant {
|
17
|
-
transparent = "transparent",
|
18
|
-
white = "white",
|
19
|
-
primary = "primary",
|
20
|
-
secondary = "secondary",
|
21
|
-
grey = "grey",
|
22
|
-
}
|
23
|
-
|
24
|
-
export enum ChipSize {
|
25
|
-
xl = "xl",
|
26
|
-
l = "l",
|
27
|
-
m = "m",
|
28
|
-
s = "s",
|
29
|
-
}
|
30
|
-
|
31
16
|
const sizeVariant = {
|
32
17
|
xl: {
|
33
18
|
iconSize: {
|
@@ -102,8 +87,8 @@ export const Chip: FC<ChipProps> = (props: ChipProps) => {
|
|
102
87
|
iconLeft,
|
103
88
|
iconRight,
|
104
89
|
label,
|
105
|
-
size =
|
106
|
-
variant =
|
90
|
+
size = 'm',
|
91
|
+
variant = 'primary',
|
107
92
|
onClick,
|
108
93
|
} = props;
|
109
94
|
|
@@ -132,9 +117,9 @@ export const Chip: FC<ChipProps> = (props: ChipProps) => {
|
|
132
117
|
);
|
133
118
|
};
|
134
119
|
|
135
|
-
const getVariantStyles = (variant:
|
120
|
+
const getVariantStyles = (variant: ChipProps['variant'], clickable: boolean): string => {
|
136
121
|
switch (variant) {
|
137
|
-
case
|
122
|
+
case 'secondary':
|
138
123
|
return `
|
139
124
|
background-color: var(--color-white);
|
140
125
|
opacity: 0.9;
|
@@ -156,7 +141,7 @@ const getVariantStyles = (variant: ChipVariant, clickable: boolean): string => {
|
|
156
141
|
`
|
157
142
|
}
|
158
143
|
`;
|
159
|
-
case
|
144
|
+
case 'transparent':
|
160
145
|
return `
|
161
146
|
${
|
162
147
|
clickable &&
|
@@ -171,7 +156,7 @@ const getVariantStyles = (variant: ChipVariant, clickable: boolean): string => {
|
|
171
156
|
`
|
172
157
|
}
|
173
158
|
`;
|
174
|
-
case
|
159
|
+
case 'grey':
|
175
160
|
return `
|
176
161
|
background-color: var(--shades-of-grey-20);
|
177
162
|
|
@@ -188,7 +173,7 @@ const getVariantStyles = (variant: ChipVariant, clickable: boolean): string => {
|
|
188
173
|
`
|
189
174
|
}
|
190
175
|
`;
|
191
|
-
case
|
176
|
+
case 'white':
|
192
177
|
return `
|
193
178
|
background-color: var(--color-white);
|
194
179
|
border-color: var(--shades-of-grey-40);
|
@@ -207,7 +192,7 @@ const getVariantStyles = (variant: ChipVariant, clickable: boolean): string => {
|
|
207
192
|
`
|
208
193
|
}
|
209
194
|
`;
|
210
|
-
case
|
195
|
+
case 'primary':
|
211
196
|
default:
|
212
197
|
return `
|
213
198
|
background-color: var(--color-orange);
|
@@ -233,8 +218,8 @@ const getVariantStyles = (variant: ChipVariant, clickable: boolean): string => {
|
|
233
218
|
Chip.displayName = "Chip";
|
234
219
|
|
235
220
|
const ChipWrapper = styled.div<{
|
236
|
-
size:
|
237
|
-
variant:
|
221
|
+
size: Exclude<ChipProps['size'], undefined>;
|
222
|
+
variant: Exclude<ChipProps['variant'], undefined>;
|
238
223
|
onClick?: OnClickFunctionType;
|
239
224
|
}>`
|
240
225
|
border-radius: 100px;
|
@@ -264,7 +249,7 @@ const IconWrapper = styled.span`
|
|
264
249
|
IconWrapper.displayName = "IconWrapper";
|
265
250
|
|
266
251
|
const Text = styled.span<{
|
267
|
-
size:
|
252
|
+
size: Exclude<ChipProps['size'], undefined>;
|
268
253
|
}>`
|
269
254
|
color: inherit;
|
270
255
|
font-weight: bold;
|