@lux-design-system/components-react 1.0.0-alpha.1 → 1.0.0-alpha.2
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.
- package/package.json +3 -2
- package/src/Alert.css +16 -0
- package/src/Alert.tsx +65 -0
- package/src/button/Button.tsx +31 -0
- package/src/button/button.scss +17 -0
- package/src/icons/CrossIcon.tsx +8 -0
- package/src/icons/ErrorIcon.tsx +11 -0
- package/src/icons/InfoIcon.tsx +16 -0
- package/src/icons/SuccessIcon.tsx +14 -0
- package/src/icons/WarningIcon.tsx +16 -0
- package/src/icons/index.ts +5 -0
- package/src/index.test.ts +5 -0
- package/src/index.ts +3 -0
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.0.0-alpha.
|
|
2
|
+
"version": "1.0.0-alpha.2",
|
|
3
3
|
"author": "Community for NL Design System",
|
|
4
4
|
"description": "React component library for LUX, the Design System for Logius, based on the NL Design System architecture",
|
|
5
5
|
"license": "EUPL-1.2",
|
|
@@ -21,7 +21,8 @@
|
|
|
21
21
|
"module": "./dist/index.esm.js",
|
|
22
22
|
"types": "./dist/index.d.ts",
|
|
23
23
|
"files": [
|
|
24
|
-
"dist/"
|
|
24
|
+
"dist/",
|
|
25
|
+
"src/"
|
|
25
26
|
],
|
|
26
27
|
"dependencies": {
|
|
27
28
|
"@utrecht/component-library-react": "5",
|
package/src/Alert.css
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
.lux-alert {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: row;
|
|
4
|
+
align-items: flex-start;
|
|
5
|
+
gap: var(--lux-alert-column-gap);
|
|
6
|
+
|
|
7
|
+
.lux-alert-type-icon {
|
|
8
|
+
min-inline-size: var(--lux-alert-icon-size);
|
|
9
|
+
min-block-size: var(--lux-alert-icon-size);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.lux-alert-cross-icon {
|
|
13
|
+
min-inline-size: var(--lux-alert-close-button-size);
|
|
14
|
+
min-block-size: var(--lux-alert-close-button-size);
|
|
15
|
+
}
|
|
16
|
+
}
|
package/src/Alert.tsx
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Alert as UtrechtAlert,
|
|
3
|
+
AlertProps as UtrechtAlertProps,
|
|
4
|
+
AlertType as UtrechtAlertType,
|
|
5
|
+
Icon as UtrechtIcon,
|
|
6
|
+
} from '@utrecht/component-library-react/dist/css-module';
|
|
7
|
+
import { PropsWithChildren, ReactNode, useState } from 'react';
|
|
8
|
+
import { CrossIcon, ErrorIcon, InfoIcon, SuccessIcon, WarningIcon } from './icons';
|
|
9
|
+
import './Alert.css';
|
|
10
|
+
|
|
11
|
+
type AlertType = Exclude<UtrechtAlertType, 'ok'> | 'success';
|
|
12
|
+
|
|
13
|
+
export interface LuxAlertProps extends Omit<UtrechtAlertProps, 'type'> {
|
|
14
|
+
type?: AlertType;
|
|
15
|
+
closable?: boolean;
|
|
16
|
+
onClose?: Function;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const LuxAlert = ({
|
|
20
|
+
children,
|
|
21
|
+
type = 'info',
|
|
22
|
+
closable = false,
|
|
23
|
+
onClose,
|
|
24
|
+
...props
|
|
25
|
+
}: PropsWithChildren<LuxAlertProps>): ReactNode => {
|
|
26
|
+
const [_closed, setClosed] = useState(false);
|
|
27
|
+
const utrechtAlertType: UtrechtAlertType = type === 'success' ? 'ok' : type;
|
|
28
|
+
|
|
29
|
+
const icon =
|
|
30
|
+
type === 'info' ? (
|
|
31
|
+
<InfoIcon />
|
|
32
|
+
) : type === 'success' ? (
|
|
33
|
+
<SuccessIcon />
|
|
34
|
+
) : type === 'warning' ? (
|
|
35
|
+
<WarningIcon />
|
|
36
|
+
) : type === 'error' ? (
|
|
37
|
+
<ErrorIcon />
|
|
38
|
+
) : (
|
|
39
|
+
<></>
|
|
40
|
+
);
|
|
41
|
+
return (
|
|
42
|
+
!_closed && (
|
|
43
|
+
<UtrechtAlert icon={<></>} type={utrechtAlertType} {...props}>
|
|
44
|
+
<div className="lux-alert">
|
|
45
|
+
<UtrechtIcon className="lux-alert-type-icon">{icon}</UtrechtIcon>
|
|
46
|
+
{children}
|
|
47
|
+
{closable && (
|
|
48
|
+
<UtrechtIcon
|
|
49
|
+
className="lux-alert-cross-icon"
|
|
50
|
+
onClick={(e) => {
|
|
51
|
+
setClosed(true);
|
|
52
|
+
if (onClose) {
|
|
53
|
+
onClose();
|
|
54
|
+
}
|
|
55
|
+
e.preventDefault();
|
|
56
|
+
}}
|
|
57
|
+
>
|
|
58
|
+
{CrossIcon()}
|
|
59
|
+
</UtrechtIcon>
|
|
60
|
+
)}
|
|
61
|
+
</div>
|
|
62
|
+
</UtrechtAlert>
|
|
63
|
+
)
|
|
64
|
+
);
|
|
65
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type ButtonProps as UtrechtButtonProps } from '@utrecht/component-library-react';
|
|
2
|
+
import { Button as UtrechtButton } from '@utrecht/component-library-react/dist/css-module';
|
|
3
|
+
|
|
4
|
+
import './button.scss';
|
|
5
|
+
|
|
6
|
+
type Variant = 'primary' | 'secondary' | 'tertiary';
|
|
7
|
+
|
|
8
|
+
export type LuxButtonProps = Omit<UtrechtButtonProps, 'appearance'> & {
|
|
9
|
+
variant: Variant;
|
|
10
|
+
size: undefined | 'small';
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const mapVariant = (variant: Variant): string => {
|
|
14
|
+
return {
|
|
15
|
+
undefined: 'primary-action-button',
|
|
16
|
+
primary: 'primary-action-button',
|
|
17
|
+
secondary: 'secondary-action-button',
|
|
18
|
+
tertiary: 'subtle-button',
|
|
19
|
+
}[variant];
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const LuxButton = (props: LuxButtonProps) => {
|
|
23
|
+
const newProps: any = {
|
|
24
|
+
...props,
|
|
25
|
+
appearance: mapVariant(props.variant),
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const classNames = { 'lux-button--small': props.size === 'small' };
|
|
29
|
+
|
|
30
|
+
return <UtrechtButton {...newProps} className={classNames} />;
|
|
31
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
.lux-button {
|
|
2
|
+
padding-block-start: var(--lux-button-default-padding-block-start);
|
|
3
|
+
padding-block-end: var(--lux-button-default-padding-block-end);
|
|
4
|
+
min-inline-size: var(--lux-button-default-min-inline-size);
|
|
5
|
+
min-block-size: var(--lux-button-default-min-block-size);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.lux-button--small {
|
|
9
|
+
padding-block-start: var(--lux-button-small-padding-block-start);
|
|
10
|
+
padding-block-end: var(--lux-button-small-padding-block-end);
|
|
11
|
+
min-inline-size: var(--lux-button-small-min-inline-size);
|
|
12
|
+
min-block-size: var(--lux-button-small-min-block-size);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.lux-remy {
|
|
16
|
+
color: blue;
|
|
17
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export const CrossIcon = () => (
|
|
2
|
+
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
3
|
+
<path
|
|
4
|
+
d="M12.0967 2.27459L7.94538 5.93572L3.79406 2.27459C3.35708 1.90847 2.70161 1.90847 2.33746 2.27459C1.90048 2.71392 1.90048 3.37293 2.26463 3.81226L5.97897 7.98596L2.33746 12.1597C1.97331 12.599 1.97331 13.258 2.33746 13.6973C2.77444 14.0634 3.42991 14.1367 3.86689 13.6973L8.01821 10.0362L12.1695 13.6973C12.6065 14.0634 13.262 14.0634 13.699 13.6973C14.0631 13.258 14.1359 12.599 13.699 12.1597L9.98462 7.98596L13.6261 3.81226C13.9903 3.37293 13.9903 2.71392 13.6261 2.27459C13.1891 1.90847 12.5337 1.90847 12.0967 2.27459Z"
|
|
5
|
+
fill="#282828"
|
|
6
|
+
/>
|
|
7
|
+
</svg>
|
|
8
|
+
);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export const ErrorIcon = () => {
|
|
2
|
+
return (
|
|
3
|
+
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
4
|
+
<circle cx="12" cy="12" r="10.5" fill="#D52B1E" />
|
|
5
|
+
<path
|
|
6
|
+
d="M15.12 7.71L12 10.48L8.88 7.71C8.55 7.42 8.05 7.43 7.73 7.73C7.43 8.05 7.42 8.54 7.71 8.87L10.48 12L7.71 15.12C7.42 15.45 7.42 15.95 7.73 16.26C8.05 16.56 8.54 16.57 8.87 16.28L12 13.52L15.12 16.29C15.45 16.58 15.95 16.57 16.26 16.27C16.56 15.95 16.57 15.46 16.28 15.13L13.52 12L16.29 8.88C16.58 8.55 16.58 8.05 16.27 7.74C15.95 7.43 15.45 7.42 15.12 7.71Z"
|
|
7
|
+
fill="white"
|
|
8
|
+
/>
|
|
9
|
+
</svg>
|
|
10
|
+
);
|
|
11
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const InfoIcon = () => {
|
|
2
|
+
return (
|
|
3
|
+
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
4
|
+
<path
|
|
5
|
+
d="M22.04 3.78C21.88 2.83 21.16 2.11 20.21 1.95C17.48 1.5 12.91 1.5 12 1.5C11.09 1.5 6.52 1.5 3.78 1.96C2.84 2.11 2.11 2.84 1.96 3.78C1.5 6.52 1.5 11.09 1.5 12C1.5 12.91 1.5 17.48 1.96 20.22C2.12 21.17 2.84 21.89 3.79 22.05C6.53 22.51 11.09 22.51 12.01 22.51C12.92 22.51 17.49 22.51 20.23 22.05C21.18 21.89 21.9 21.17 22.06 20.22C22.52 17.48 22.52 12.92 22.52 12C22.5 9.26 22.5 6.52 22.04 3.78Z"
|
|
6
|
+
fill="#007BC7"
|
|
7
|
+
/>
|
|
8
|
+
<path
|
|
9
|
+
fill-rule="evenodd"
|
|
10
|
+
clip-rule="evenodd"
|
|
11
|
+
d="M11.04 6.05004C10.82 6.30004 10.71 6.59004 10.71 6.93004C10.71 7.28004 10.82 7.57004 11.04 7.81004C11.27 8.04004 11.58 8.16004 11.99 8.16004C12.39 8.16004 12.71 8.04004 12.93 7.79004C13.15 7.54004 13.26 7.25004 13.26 6.93004C13.26 6.57004 13.15 6.27004 12.93 6.03004C12.71 5.79004 12.4 5.67004 11.99 5.67004C11.58 5.67004 11.26 5.80004 11.04 6.05004ZM13.11 18.28V9.32004L10.9 9.41004V18.28H13.11Z"
|
|
12
|
+
fill="white"
|
|
13
|
+
/>
|
|
14
|
+
</svg>
|
|
15
|
+
);
|
|
16
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export const SuccessIcon = () => {
|
|
2
|
+
return (
|
|
3
|
+
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
4
|
+
<path
|
|
5
|
+
d="M22.04 3.78C21.88 2.83 21.16 2.11 20.21 1.95C17.48 1.5 12.91 1.5 12 1.5C11.09 1.5 6.52 1.5 3.78 1.96C2.83 2.11 2.11 2.83 1.96 3.78C1.5 6.52 1.5 11.09 1.5 12C1.5 12.91 1.5 17.48 1.96 20.22C2.12 21.17 2.84 21.89 3.79 22.05C6.53 22.51 11.09 22.51 12.01 22.51C12.92 22.51 17.49 22.51 20.23 22.05C21.18 21.89 21.9 21.17 22.06 20.22C22.52 17.48 22.52 12.92 22.52 12C22.5 9.26 22.5 6.52 22.04 3.78Z"
|
|
6
|
+
fill="#39870C"
|
|
7
|
+
/>
|
|
8
|
+
<path
|
|
9
|
+
d="M16.5 7.35C16.19 7.12 15.75 7.16 15.49 7.45L11.09 12.4L8.44 10.1C8.16 9.86 7.75 9.86 7.47 10.1C7.19 10.34 7.12 10.75 7.31 11.07L10.51 16.45C10.65 16.68 10.89 16.82 11.15 16.82C11.41 16.82 11.66 16.68 11.79 16.46L16.68 8.37C16.89 8.02 16.81 7.59 16.5 7.35Z"
|
|
10
|
+
fill="white"
|
|
11
|
+
/>
|
|
12
|
+
</svg>
|
|
13
|
+
);
|
|
14
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const WarningIcon = () => {
|
|
2
|
+
return (
|
|
3
|
+
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
4
|
+
<path
|
|
5
|
+
d="M23.38 19.64L13.67 2.47C12.94 1.17 11.07 1.17 10.33 2.47L0.620006 19.64C-0.0999945 20.92 0.820006 22.5 2.29001 22.5H21.72C23.18 22.5 24.1 20.92 23.38 19.64Z"
|
|
6
|
+
fill="#FFB612"
|
|
7
|
+
/>
|
|
8
|
+
<path
|
|
9
|
+
fill-rule="evenodd"
|
|
10
|
+
clip-rule="evenodd"
|
|
11
|
+
d="M13.33 6.98L10.85 7.18H10.84V15.17L13.11 15.12V12.49L13.33 6.98ZM10.9 16.33C10.66 16.63 10.54 17.01 10.54 17.45C10.54 17.96 10.67 18.34 10.92 18.59C11.17 18.85 11.54 18.98 12.02 18.98C12.51 18.98 12.87 18.83 13.11 18.54C13.35 18.25 13.47 17.88 13.47 17.45C13.47 16.93 13.34 16.54 13.09 16.27C12.84 16.01 12.47 15.87 11.99 15.87C11.5 15.87 11.14 16.02 10.9 16.33Z"
|
|
12
|
+
fill="black"
|
|
13
|
+
/>
|
|
14
|
+
</svg>
|
|
15
|
+
);
|
|
16
|
+
};
|
package/src/index.ts
ADDED