@i-dot-ai-npm/component-library-react 0.0.2 → 0.0.3
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 +1 -1
- package/src/button/Button.tsx +22 -3
- package/src/checkboxes/CheckboxConditional.tsx +24 -0
- package/src/error-message/ErrorMessage.tsx +5 -4
- package/src/index.ts +3 -0
- package/src/radios/RadioConditional.tsx +24 -0
- package/src/radios/RadioLabel.tsx +17 -0
- package/src/tag/Tag.tsx +2 -2
- package/src/textarea/Textarea.tsx +3 -2
package/package.json
CHANGED
package/src/button/Button.tsx
CHANGED
|
@@ -6,22 +6,41 @@ type ButtonProps = {
|
|
|
6
6
|
warning?: boolean;
|
|
7
7
|
inverse?: boolean;
|
|
8
8
|
small?: boolean;
|
|
9
|
+
startButton?: boolean;
|
|
9
10
|
href?: string;
|
|
11
|
+
type?: "button" | "reset" | "submit";
|
|
10
12
|
class?: string;
|
|
11
13
|
children?: ReactNode;
|
|
12
14
|
[key: string]: unknown;
|
|
13
15
|
};
|
|
14
16
|
|
|
15
|
-
|
|
17
|
+
const StartIcon = () => (
|
|
18
|
+
<svg
|
|
19
|
+
className="govuk-button__start-icon"
|
|
20
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
21
|
+
width="17.5"
|
|
22
|
+
height="19"
|
|
23
|
+
viewBox="0 0 33 40"
|
|
24
|
+
aria-hidden="true"
|
|
25
|
+
focusable="false"
|
|
26
|
+
>
|
|
27
|
+
<path fill="currentColor" d="M0 0h13l20 20-20 20H0l20-20z" />
|
|
28
|
+
</svg>
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
export default function Button({ secondary, tertiary, warning, inverse, small, startButton, href, type, class: className, children, ...rest }: ButtonProps) {
|
|
32
|
+
const classes = ["govuk-button", secondary ? "govuk-button--secondary" : "", warning ? "govuk-button--warning" : "", inverse ? "govuk-button--inverse" : "", tertiary ? "govuk-button--tertiary" : "", small ? "govuk-button--small" : "", startButton ? "govuk-button--start" : "", className ?? ""].filter(Boolean).join(" ");
|
|
16
33
|
|
|
17
34
|
return (
|
|
18
35
|
href ? (
|
|
19
|
-
<a href={href} role="button"
|
|
36
|
+
<a href={href} role="button" draggable="false" className={classes} data-module="govuk-button" {...rest}>
|
|
20
37
|
{children ?? ""}
|
|
38
|
+
{startButton ? <StartIcon /> : null}
|
|
21
39
|
</a>
|
|
22
40
|
) : (
|
|
23
|
-
<button
|
|
41
|
+
<button type={type ?? "submit"} className={classes} data-module="govuk-button" {...rest}>
|
|
24
42
|
{children ?? ""}
|
|
43
|
+
{startButton ? <StartIcon /> : null}
|
|
25
44
|
</button>
|
|
26
45
|
)
|
|
27
46
|
);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
type CheckboxConditionalProps = {
|
|
4
|
+
hidden?: boolean;
|
|
5
|
+
class?: string;
|
|
6
|
+
children?: ReactNode;
|
|
7
|
+
[key: string]: unknown;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export default function CheckboxConditional({ hidden = true, class: className, children, ...rest }: CheckboxConditionalProps) {
|
|
11
|
+
const classes = [
|
|
12
|
+
"govuk-checkboxes__conditional",
|
|
13
|
+
hidden ? "govuk-checkboxes__conditional--hidden" : "",
|
|
14
|
+
className ?? "",
|
|
15
|
+
]
|
|
16
|
+
.filter(Boolean)
|
|
17
|
+
.join(" ");
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<div className={classes} {...rest}>
|
|
21
|
+
{children ?? ""}
|
|
22
|
+
</div>
|
|
23
|
+
);
|
|
24
|
+
}
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
|
|
3
3
|
type ErrorMessageProps = {
|
|
4
|
+
visuallyHiddenText?: string;
|
|
4
5
|
class?: string;
|
|
5
6
|
children?: ReactNode;
|
|
6
7
|
[key: string]: unknown;
|
|
7
8
|
};
|
|
8
9
|
|
|
9
|
-
export default function ErrorMessage({ class: className, children, ...rest }: ErrorMessageProps) {
|
|
10
|
+
export default function ErrorMessage({ visuallyHiddenText = "Error", class: className, children, ...rest }: ErrorMessageProps) {
|
|
10
11
|
const classes = ["govuk-error-message", className ?? ""].filter(Boolean).join(" ");
|
|
11
12
|
|
|
12
13
|
return (
|
|
13
14
|
<p className={classes} {...rest}>
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
{visuallyHiddenText ? (
|
|
16
|
+
<span className="govuk-visually-hidden">{visuallyHiddenText}:</span>
|
|
17
|
+
) : null}{" "}
|
|
17
18
|
{children ?? ""}
|
|
18
19
|
</p>
|
|
19
20
|
);
|
package/src/index.ts
CHANGED
|
@@ -17,6 +17,7 @@ export { default as CardLink } from "./card/CardLink";
|
|
|
17
17
|
export { default as Card } from "./card/Card";
|
|
18
18
|
export { default as CharacterCountMessage } from "./character-count/CharacterCountMessage";
|
|
19
19
|
export { default as CharacterCount } from "./character-count/CharacterCount";
|
|
20
|
+
export { default as CheckboxConditional } from "./checkboxes/CheckboxConditional";
|
|
20
21
|
export { default as CheckboxDivider } from "./checkboxes/CheckboxDivider";
|
|
21
22
|
export { default as CheckboxInput } from "./checkboxes/CheckboxInput";
|
|
22
23
|
export { default as CheckboxItem } from "./checkboxes/CheckboxItem";
|
|
@@ -63,9 +64,11 @@ export { default as PaginationPrev } from "./pagination/PaginationPrev";
|
|
|
63
64
|
export { default as Pagination } from "./pagination/Pagination";
|
|
64
65
|
export { default as PasswordInput } from "./password-input/PasswordInput";
|
|
65
66
|
export { default as PhaseBanner } from "./phase-banner/PhaseBanner";
|
|
67
|
+
export { default as RadioConditional } from "./radios/RadioConditional";
|
|
66
68
|
export { default as RadioDivider } from "./radios/RadioDivider";
|
|
67
69
|
export { default as RadioInput } from "./radios/RadioInput";
|
|
68
70
|
export { default as RadioItem } from "./radios/RadioItem";
|
|
71
|
+
export { default as RadioLabel } from "./radios/RadioLabel";
|
|
69
72
|
export { default as Radios } from "./radios/Radios";
|
|
70
73
|
export { default as SelectOption } from "./select/SelectOption";
|
|
71
74
|
export { default as Select } from "./select/Select";
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
type RadioConditionalProps = {
|
|
4
|
+
hidden?: boolean;
|
|
5
|
+
class?: string;
|
|
6
|
+
children?: ReactNode;
|
|
7
|
+
[key: string]: unknown;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export default function RadioConditional({ hidden = true, class: className, children, ...rest }: RadioConditionalProps) {
|
|
11
|
+
const classes = [
|
|
12
|
+
"govuk-radios__conditional",
|
|
13
|
+
hidden ? "govuk-radios__conditional--hidden" : "",
|
|
14
|
+
className ?? "",
|
|
15
|
+
]
|
|
16
|
+
.filter(Boolean)
|
|
17
|
+
.join(" ");
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<div className={classes} {...rest}>
|
|
21
|
+
{children ?? ""}
|
|
22
|
+
</div>
|
|
23
|
+
);
|
|
24
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
type RadioLabelProps = {
|
|
4
|
+
class?: string;
|
|
5
|
+
children?: ReactNode;
|
|
6
|
+
[key: string]: unknown;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export default function RadioLabel({ class: className, children, ...rest }: RadioLabelProps) {
|
|
10
|
+
const classes = ["govuk-label govuk-radios__label", className ?? ""].filter(Boolean).join(" ");
|
|
11
|
+
|
|
12
|
+
return (
|
|
13
|
+
<label className={classes} {...rest}>
|
|
14
|
+
{children ?? ""}
|
|
15
|
+
</label>
|
|
16
|
+
);
|
|
17
|
+
}
|
package/src/tag/Tag.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
|
|
3
3
|
type TagProps = {
|
|
4
|
-
colour?: "grey" | "green" | "turquoise" | "blue" | "light-blue" | "purple" | "pink" | "red" | "orange" | "yellow";
|
|
4
|
+
colour?: "grey" | "green" | "teal" | "turquoise" | "blue" | "light-blue" | "purple" | "magenta" | "pink" | "red" | "orange" | "yellow";
|
|
5
5
|
class?: string;
|
|
6
6
|
children?: ReactNode;
|
|
7
7
|
[key: string]: unknown;
|
|
@@ -10,7 +10,7 @@ type TagProps = {
|
|
|
10
10
|
export default function Tag({ colour, class: className, children, ...rest }: TagProps) {
|
|
11
11
|
const classes = [
|
|
12
12
|
"govuk-tag",
|
|
13
|
-
({ "grey": "govuk-tag--grey", "green": "govuk-tag--green", "turquoise": "govuk-tag--turquoise", "blue": "govuk-tag--blue", "light-blue": "govuk-tag--light-blue", "purple": "govuk-tag--purple", "pink": "govuk-tag--pink", "red": "govuk-tag--red", "orange": "govuk-tag--orange", "yellow": "govuk-tag--yellow" }[colour] ?? ""),
|
|
13
|
+
({ "grey": "govuk-tag--grey", "green": "govuk-tag--green", "teal": "govuk-tag--teal", "turquoise": "govuk-tag--turquoise", "blue": "govuk-tag--blue", "light-blue": "govuk-tag--light-blue", "purple": "govuk-tag--purple", "magenta": "govuk-tag--magenta", "pink": "govuk-tag--pink", "red": "govuk-tag--red", "orange": "govuk-tag--orange", "yellow": "govuk-tag--yellow" }[colour] ?? ""),
|
|
14
14
|
className ?? "",
|
|
15
15
|
]
|
|
16
16
|
.filter(Boolean)
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
type TextareaProps = {
|
|
2
2
|
error?: boolean;
|
|
3
3
|
subtle?: boolean;
|
|
4
|
+
value?: string;
|
|
4
5
|
class?: string;
|
|
5
6
|
[key: string]: unknown;
|
|
6
7
|
};
|
|
7
8
|
|
|
8
|
-
export default function Textarea({ error, subtle, class: className, ...rest }: TextareaProps) {
|
|
9
|
+
export default function Textarea({ error, subtle, value, class: className, ...rest }: TextareaProps) {
|
|
9
10
|
const classes = [
|
|
10
11
|
"govuk-textarea",
|
|
11
12
|
error ? "govuk-textarea--error" : "",
|
|
@@ -16,6 +17,6 @@ export default function Textarea({ error, subtle, class: className, ...rest }: T
|
|
|
16
17
|
.join(" ");
|
|
17
18
|
|
|
18
19
|
return (
|
|
19
|
-
<textarea className={classes} {...rest}></textarea>
|
|
20
|
+
<textarea className={classes} defaultValue={value} {...rest}></textarea>
|
|
20
21
|
);
|
|
21
22
|
}
|