@recursica/mui-adapter 0.5.0 → 0.6.0
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/CHANGELOG.md +9 -0
- package/dist/mui-adapter.cjs +74 -1
- package/dist/mui-adapter.cjs.map +1 -1
- package/dist/mui-adapter.css +1 -1
- package/dist/mui-adapter.js +6652 -204
- package/dist/mui-adapter.js.map +1 -1
- package/dist/src/components/Accordion/Accordion.d.ts +63 -2
- package/dist/src/components/AssistiveElement/AssistiveElement.d.ts +9 -2
- package/dist/src/components/Autocomplete/Autocomplete.d.ts +16 -2
- package/dist/src/components/Avatar/Avatar.d.ts +14 -2
- package/dist/src/components/Badge/Badge.d.ts +13 -3
- package/dist/src/components/Breadcrumb/Breadcrumb.d.ts +10 -3
- package/dist/src/components/Button/Button.d.ts +1 -1
- package/dist/src/components/Card/Card.d.ts +40 -3
- package/dist/src/components/Checkbox/Checkbox.d.ts +15 -2
- package/dist/src/components/Checkbox/CheckboxGroup.d.ts +16 -0
- package/dist/src/components/Checkbox/index.d.ts +5 -1
- package/dist/src/components/Chip/Chip.d.ts +18 -2
- package/dist/src/components/Dropdown/Dropdown.d.ts +23 -3
- package/dist/src/components/FormControlLayout/FormControlLayout.d.ts +10 -2
- package/dist/src/components/FormControlWrapper/FormControlWrapper.d.ts +24 -2
- package/dist/src/components/HoverCard/HoverCard.d.ts +55 -3
- package/dist/src/components/Label/Label.d.ts +13 -2
- package/dist/src/components/Link/Link.d.ts +1 -1
- package/dist/src/components/Menu/Menu.d.ts +99 -3
- package/dist/src/components/Modal/Modal.d.ts +36 -2
- package/dist/src/components/NumberInput/NumberInput.d.ts +14 -2
- package/dist/src/components/Pagination/Pagination.d.ts +44 -2
- package/dist/src/components/Pagination/Pagination.icons.d.ts +8 -0
- package/dist/src/components/Panel/Panel.d.ts +65 -3
- package/dist/src/components/Radio/Radio.d.ts +13 -3
- package/dist/src/components/Radio/RadioGroup.d.ts +13 -0
- package/dist/src/components/ReadOnlyField/ReadOnlyBooleanField.d.ts +5 -0
- package/dist/src/components/ReadOnlyField/ReadOnlyField.d.ts +7 -2
- package/dist/src/components/ReadOnlyField/ReadOnlySwitchField.d.ts +5 -0
- package/dist/src/components/ReadOnlyField/ReadOnlyTextField.d.ts +8 -0
- package/dist/src/components/ReadOnlyField/WithReadOnlyWrapper.d.ts +28 -0
- package/dist/src/components/ReadOnlyField/index.d.ts +1 -0
- package/dist/src/components/SegmentedControl/SegmentedControl.d.ts +31 -3
- package/dist/src/components/Slider/Slider.d.ts +28 -2
- package/dist/src/components/Stepper/Stepper.d.ts +21 -2
- package/dist/src/components/Switch/Switch.d.ts +10 -3
- package/dist/src/components/Switch/SwitchGroup.d.ts +13 -0
- package/dist/src/components/Tabs/Tabs.d.ts +35 -3
- package/dist/src/components/Text/Text.d.ts +1 -1
- package/dist/src/components/TextArea/TextArea.d.ts +18 -2
- package/dist/src/components/TextField/TextField.d.ts +16 -2
- package/dist/src/components/Timeline/Timeline.d.ts +14 -2
- package/dist/src/components/Timeline/TimelineItem.d.ts +29 -0
- package/dist/src/components/Title/Title.d.ts +1 -1
- package/dist/src/components/Toast/Toast.d.ts +25 -2
- package/dist/src/components/Tooltip/Tooltip.d.ts +42 -3
- package/dist/src/components/Typography/Typography.d.ts +1 -1
- package/package.json +9 -2
- package/src/components/Accordion/Accordion.module.css +295 -56
- package/src/components/Accordion/Accordion.stories.tsx +149 -21
- package/src/components/Accordion/Accordion.tsx +264 -5
- package/src/components/AssistiveElement/AssistiveElement.module.css +111 -20
- package/src/components/AssistiveElement/AssistiveElement.stories.tsx +76 -19
- package/src/components/AssistiveElement/AssistiveElement.tsx +85 -5
- package/src/components/Autocomplete/Autocomplete.module.css +320 -42
- package/src/components/Autocomplete/Autocomplete.stories.tsx +180 -19
- package/src/components/Autocomplete/Autocomplete.tsx +199 -6
- package/src/components/Avatar/Avatar.module.css +343 -73
- package/src/components/Avatar/Avatar.stories.tsx +94 -22
- package/src/components/Avatar/Avatar.tsx +110 -6
- package/src/components/Badge/Badge.module.css +127 -29
- package/src/components/Badge/Badge.stories.tsx +65 -22
- package/src/components/Badge/Badge.tsx +70 -6
- package/src/components/Breadcrumb/Breadcrumb.module.css +25 -5
- package/src/components/Breadcrumb/Breadcrumb.stories.tsx +57 -22
- package/src/components/Breadcrumb/Breadcrumb.tsx +62 -6
- package/src/components/Button/Button.module.css +3 -3
- package/src/components/Card/Card.module.css +118 -38
- package/src/components/Card/Card.stories.tsx +117 -19
- package/src/components/Card/Card.tsx +179 -5
- package/src/components/Checkbox/Checkbox.module.css +232 -39
- package/src/components/Checkbox/Checkbox.stories.tsx +81 -19
- package/src/components/Checkbox/Checkbox.tsx +146 -5
- package/src/components/Checkbox/CheckboxGroup.tsx +117 -0
- package/src/components/Checkbox/index.ts +6 -1
- package/src/components/Chip/Chip.module.css +228 -43
- package/src/components/Chip/Chip.stories.tsx +101 -21
- package/src/components/Chip/Chip.tsx +138 -6
- package/src/components/Dropdown/Dropdown.module.css +291 -41
- package/src/components/Dropdown/Dropdown.stories.tsx +80 -21
- package/src/components/Dropdown/Dropdown.tsx +182 -6
- package/src/components/FormControlLayout/FormControlLayout.module.css +92 -0
- package/src/components/FormControlLayout/FormControlLayout.stories.tsx +74 -19
- package/src/components/FormControlLayout/FormControlLayout.tsx +58 -4
- package/src/components/FormControlWrapper/FormControlWrapper.module.css +96 -0
- package/src/components/FormControlWrapper/FormControlWrapper.stories.tsx +122 -19
- package/src/components/FormControlWrapper/FormControlWrapper.tsx +145 -6
- package/src/components/HoverCard/HoverCard.module.css +90 -22
- package/src/components/HoverCard/HoverCard.stories.tsx +158 -21
- package/src/components/HoverCard/HoverCard.tsx +150 -5
- package/src/components/Label/Label.module.css +136 -35
- package/src/components/Label/Label.stories.tsx +98 -17
- package/src/components/Label/Label.tsx +88 -5
- package/src/components/Menu/Menu.module.css +285 -51
- package/src/components/Menu/Menu.stories.tsx +307 -21
- package/src/components/Menu/Menu.tsx +318 -5
- package/src/components/Modal/Modal.module.css +171 -35
- package/src/components/Modal/Modal.stories.tsx +66 -22
- package/src/components/Modal/Modal.tsx +216 -4
- package/src/components/NumberInput/NumberInput.module.css +276 -42
- package/src/components/NumberInput/NumberInput.stories.tsx +83 -20
- package/src/components/NumberInput/NumberInput.tsx +148 -6
- package/src/components/Pagination/Pagination.icons.tsx +66 -0
- package/src/components/Pagination/Pagination.module.css +246 -20
- package/src/components/Pagination/Pagination.stories.tsx +42 -21
- package/src/components/Pagination/Pagination.tsx +193 -5
- package/src/components/Panel/Panel.module.css +206 -38
- package/src/components/Panel/Panel.stories.tsx +214 -22
- package/src/components/Panel/Panel.tsx +153 -5
- package/src/components/Radio/Radio.module.css +220 -37
- package/src/components/Radio/Radio.stories.tsx +77 -19
- package/src/components/Radio/Radio.tsx +178 -5
- package/src/components/Radio/RadioGroup.tsx +111 -0
- package/src/components/ReadOnlyField/ReadOnlyBooleanField.tsx +21 -0
- package/src/components/ReadOnlyField/ReadOnlyField.module.css +53 -15
- package/src/components/ReadOnlyField/ReadOnlyField.stories.tsx +175 -16
- package/src/components/ReadOnlyField/ReadOnlyField.tsx +109 -5
- package/src/components/ReadOnlyField/ReadOnlySwitchField.tsx +21 -0
- package/src/components/ReadOnlyField/ReadOnlyTextField.tsx +48 -0
- package/src/components/ReadOnlyField/WithReadOnlyWrapper.tsx +93 -0
- package/src/components/ReadOnlyField/index.ts +1 -0
- package/src/components/SegmentedControl/SegmentedControl.module.css +203 -47
- package/src/components/SegmentedControl/SegmentedControl.stories.tsx +102 -20
- package/src/components/SegmentedControl/SegmentedControl.tsx +110 -6
- package/src/components/Slider/Slider.module.css +542 -86
- package/src/components/Slider/Slider.stories.tsx +157 -19
- package/src/components/Slider/Slider.tsx +282 -5
- package/src/components/Stepper/Stepper.module.css +410 -71
- package/src/components/Stepper/Stepper.stories.tsx +132 -19
- package/src/components/Stepper/Stepper.tsx +145 -6
- package/src/components/Switch/Switch.module.css +238 -39
- package/src/components/Switch/Switch.stories.tsx +98 -19
- package/src/components/Switch/Switch.tsx +153 -6
- package/src/components/Switch/SwitchGroup.tsx +111 -0
- package/src/components/Tabs/Tabs.module.css +422 -79
- package/src/components/Tabs/Tabs.stories.tsx +138 -19
- package/src/components/Tabs/Tabs.tsx +103 -6
- package/src/components/TextArea/TextArea.module.css +155 -32
- package/src/components/TextArea/TextArea.stories.tsx +80 -21
- package/src/components/TextArea/TextArea.tsx +156 -6
- package/src/components/TextField/TextField.module.css +261 -42
- package/src/components/TextField/TextField.stories.tsx +168 -15
- package/src/components/TextField/TextField.tsx +171 -6
- package/src/components/Timeline/Timeline.module.css +365 -76
- package/src/components/Timeline/Timeline.stories.tsx +114 -21
- package/src/components/Timeline/Timeline.tsx +80 -5
- package/src/components/Timeline/TimelineItem.tsx +101 -0
- package/src/components/Toast/Toast.module.css +166 -28
- package/src/components/Toast/Toast.stories.tsx +54 -22
- package/src/components/Toast/Toast.tsx +90 -5
- package/src/components/Tooltip/Tooltip.module.css +89 -24
- package/src/components/Tooltip/Tooltip.stories.tsx +152 -22
- package/src/components/Tooltip/Tooltip.tsx +114 -5
|
@@ -1,35 +1,107 @@
|
|
|
1
|
+
import React from "react";
|
|
1
2
|
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
3
|
import { Avatar } from "./Avatar";
|
|
3
|
-
import {
|
|
4
|
+
import { Layer } from "@recursica/adapter-common";
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
type AvatarStoryProps = React.ComponentProps<typeof Avatar>;
|
|
7
|
+
|
|
8
|
+
const meta: Meta<AvatarStoryProps> = {
|
|
9
|
+
title: "UI-Kit/Avatar",
|
|
7
10
|
component: Avatar,
|
|
8
11
|
tags: ["autodocs"],
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
12
|
+
argTypes: {
|
|
13
|
+
variant: {
|
|
14
|
+
control: "select",
|
|
15
|
+
options: ["solid", "outline", "ghost"],
|
|
16
|
+
description:
|
|
17
|
+
"The visual variant of the avatar (applies to icon/text styles)",
|
|
18
|
+
},
|
|
19
|
+
size: {
|
|
20
|
+
control: "radio",
|
|
21
|
+
options: ["default", "small", "large"],
|
|
22
|
+
description: "The size of the avatar",
|
|
23
|
+
},
|
|
24
|
+
src: {
|
|
25
|
+
control: "text",
|
|
26
|
+
description: "Image URL for the image style avatar",
|
|
27
|
+
},
|
|
28
|
+
icon: {
|
|
29
|
+
table: {
|
|
30
|
+
disable: true,
|
|
31
|
+
},
|
|
26
32
|
},
|
|
27
33
|
},
|
|
28
34
|
};
|
|
29
35
|
|
|
30
36
|
export default meta;
|
|
31
|
-
|
|
37
|
+
|
|
38
|
+
type Story = StoryObj<AvatarStoryProps>;
|
|
32
39
|
|
|
33
40
|
export const Default: Story = {
|
|
34
|
-
|
|
41
|
+
args: {
|
|
42
|
+
size: "default",
|
|
43
|
+
variant: "solid",
|
|
44
|
+
},
|
|
45
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
|
|
46
|
+
render: ({ withLayer, layer, ...args }: any) => {
|
|
47
|
+
return <Avatar {...args} />;
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export const TextSolidDefault: Story = {
|
|
52
|
+
args: {
|
|
53
|
+
children: "JD",
|
|
54
|
+
variant: "solid",
|
|
55
|
+
size: "default",
|
|
56
|
+
},
|
|
57
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
|
|
58
|
+
render: ({ withLayer, layer, ...args }: any) => <Avatar {...args} />,
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export const ImageLarge: Story = {
|
|
62
|
+
args: {
|
|
63
|
+
src: "https://images.unsplash.com/photo-1535713875002-d1d0cf377fde?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=250&q=80",
|
|
64
|
+
size: "large",
|
|
65
|
+
},
|
|
66
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
|
|
67
|
+
render: ({ withLayer, layer, ...args }: any) => <Avatar {...args} />,
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export const IconSmallGhost: Story = {
|
|
71
|
+
args: {
|
|
72
|
+
size: "small",
|
|
73
|
+
variant: "ghost",
|
|
74
|
+
icon: (
|
|
75
|
+
<svg
|
|
76
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
77
|
+
width="16"
|
|
78
|
+
height="16"
|
|
79
|
+
viewBox="0 0 24 24"
|
|
80
|
+
fill="none"
|
|
81
|
+
stroke="currentColor"
|
|
82
|
+
strokeWidth="2"
|
|
83
|
+
strokeLinecap="round"
|
|
84
|
+
strokeLinejoin="round"
|
|
85
|
+
>
|
|
86
|
+
<path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"></path>
|
|
87
|
+
<circle cx="12" cy="7" r="4"></circle>
|
|
88
|
+
</svg>
|
|
89
|
+
),
|
|
90
|
+
},
|
|
91
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
|
|
92
|
+
render: ({ withLayer, layer, ...args }: any) => <Avatar {...args} />,
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export const LayerOneOutline: Story = {
|
|
96
|
+
args: {
|
|
97
|
+
children: "L1",
|
|
98
|
+
variant: "outline",
|
|
99
|
+
size: "default",
|
|
100
|
+
},
|
|
101
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
|
|
102
|
+
render: ({ withLayer, layer, ...args }: any) => (
|
|
103
|
+
<Layer layer={1} style={{ padding: "24px", display: "inline-block" }}>
|
|
104
|
+
<Avatar {...args} />
|
|
105
|
+
</Layer>
|
|
106
|
+
),
|
|
35
107
|
};
|
|
@@ -1,8 +1,112 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import
|
|
1
|
+
import React, { forwardRef } from "react";
|
|
2
|
+
import {
|
|
3
|
+
Avatar as MuiAvatar,
|
|
4
|
+
type AvatarProps as MuiAvatarProps,
|
|
5
|
+
} from "@mui/material";
|
|
6
|
+
import {
|
|
7
|
+
filterStylingProps,
|
|
8
|
+
type RecursicaOverStyled,
|
|
9
|
+
} from "../../utils/filterStylingProps";
|
|
10
|
+
import styles from "./Avatar.module.css";
|
|
3
11
|
|
|
4
|
-
export
|
|
12
|
+
export interface RecursicaAvatarProps {
|
|
13
|
+
size?: "small" | "default" | "large";
|
|
14
|
+
variant?: "solid" | "outline" | "ghost";
|
|
15
|
+
icon?: React.ReactNode;
|
|
16
|
+
}
|
|
5
17
|
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
|
|
18
|
+
export type AvatarProps = RecursicaOverStyled<
|
|
19
|
+
Omit<MuiAvatarProps, "variant" | "size" | "color" | "radius"> &
|
|
20
|
+
RecursicaAvatarProps
|
|
21
|
+
>;
|
|
22
|
+
|
|
23
|
+
const _Avatar = forwardRef<HTMLDivElement, AvatarProps>(function Avatar(
|
|
24
|
+
{
|
|
25
|
+
size = "default",
|
|
26
|
+
variant = "solid",
|
|
27
|
+
icon,
|
|
28
|
+
children,
|
|
29
|
+
src,
|
|
30
|
+
overStyled = false,
|
|
31
|
+
...rest
|
|
32
|
+
},
|
|
33
|
+
ref,
|
|
34
|
+
) {
|
|
35
|
+
const mapVariant = {
|
|
36
|
+
solid: "filled",
|
|
37
|
+
outline: "outline",
|
|
38
|
+
ghost: "transparent",
|
|
39
|
+
} as const;
|
|
40
|
+
|
|
41
|
+
const mapSize = {
|
|
42
|
+
default: "md",
|
|
43
|
+
small: "sm",
|
|
44
|
+
large: "lg",
|
|
45
|
+
} as const;
|
|
46
|
+
|
|
47
|
+
const sanitizedProps = filterStylingProps(rest, overStyled);
|
|
48
|
+
const restRecord = sanitizedProps as Record<string, unknown>;
|
|
49
|
+
|
|
50
|
+
// Determine semantic style based on provided props
|
|
51
|
+
let computedStyle = "text";
|
|
52
|
+
if (src) {
|
|
53
|
+
computedStyle = "image";
|
|
54
|
+
} else if (icon) {
|
|
55
|
+
computedStyle = "icon";
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const mergedClassNames: Partial<Record<string, string>> = {
|
|
59
|
+
root: styles.root,
|
|
60
|
+
image: styles.image,
|
|
61
|
+
placeholder: styles.placeholder,
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const classNamesProp = restRecord.classNames;
|
|
65
|
+
if (
|
|
66
|
+
classNamesProp &&
|
|
67
|
+
typeof classNamesProp === "object" &&
|
|
68
|
+
!Array.isArray(classNamesProp)
|
|
69
|
+
) {
|
|
70
|
+
const o = classNamesProp as Partial<Record<string, string>>;
|
|
71
|
+
mergedClassNames.root = o.root ? `${styles.root} ${o.root}` : styles.root;
|
|
72
|
+
mergedClassNames.image = o.image
|
|
73
|
+
? `${styles.image} ${o.image}`
|
|
74
|
+
: styles.image;
|
|
75
|
+
mergedClassNames.placeholder = o.placeholder
|
|
76
|
+
? `${styles.placeholder} ${o.placeholder}`
|
|
77
|
+
: styles.placeholder;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const classNameProp = restRecord.className as string | undefined;
|
|
81
|
+
|
|
82
|
+
return (
|
|
83
|
+
<MuiAvatar
|
|
84
|
+
ref={ref}
|
|
85
|
+
className={classNameProp}
|
|
86
|
+
classes={mergedClassNames}
|
|
87
|
+
variant={mapVariant[variant]}
|
|
88
|
+
size={mapSize[size]}
|
|
89
|
+
src={src}
|
|
90
|
+
data-variant={variant}
|
|
91
|
+
data-size={size}
|
|
92
|
+
data-style={computedStyle}
|
|
93
|
+
{...sanitizedProps}
|
|
94
|
+
>
|
|
95
|
+
{icon != null ? (
|
|
96
|
+
<span className={styles.iconWrapper} aria-hidden>
|
|
97
|
+
{icon}
|
|
98
|
+
</span>
|
|
99
|
+
) : children != null ? (
|
|
100
|
+
<span className={styles.textWrapper}>{children}</span>
|
|
101
|
+
) : undefined}
|
|
102
|
+
</MuiAvatar>
|
|
103
|
+
);
|
|
104
|
+
});
|
|
105
|
+
_Avatar.displayName = "Avatar";
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Recursica Avatar component wrapping Mui's Avatar.
|
|
109
|
+
*
|
|
110
|
+
* Supports polymorphism via the `component` prop or `renderRoot` for custom element rendering.
|
|
111
|
+
*/
|
|
112
|
+
export const Avatar = _Avatar as any;
|
|
@@ -1,29 +1,127 @@
|
|
|
1
|
-
/*
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
/*
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
/*
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
/*
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
1
|
+
/* HARDCODED VALUES:
|
|
2
|
+
- border-style: solid (needs a token if we support other border styles)
|
|
3
|
+
- box-sizing: border-box
|
|
4
|
+
- display: inline-flex
|
|
5
|
+
- align-items: center
|
|
6
|
+
- justify-content: center
|
|
7
|
+
- text-transform: uppercase (Mantine does this, but our tokens also specify it so we map it)
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
.root {
|
|
11
|
+
/* HARDCODE: Basic structural assumptions */
|
|
12
|
+
box-sizing: border-box;
|
|
13
|
+
display: inline-flex;
|
|
14
|
+
align-items: center;
|
|
15
|
+
justify-content: center;
|
|
16
|
+
border-style: solid;
|
|
17
|
+
|
|
18
|
+
/* Base style resets to fully clear Mantine's defaults before applying ours */
|
|
19
|
+
background-color: transparent;
|
|
20
|
+
color: inherit;
|
|
21
|
+
border-color: transparent;
|
|
22
|
+
|
|
23
|
+
/* Apply global badge properties */
|
|
24
|
+
border-radius: var(
|
|
25
|
+
--recursica_ui-kit_components_badge_properties_border-radius
|
|
26
|
+
);
|
|
27
|
+
border-width: var(--recursica_ui-kit_components_badge_properties_border-size);
|
|
28
|
+
box-shadow: var(--recursica_ui-kit_components_badge_properties_elevation);
|
|
29
|
+
|
|
30
|
+
padding-left: var(
|
|
31
|
+
--recursica_ui-kit_components_badge_properties_padding-horizontal
|
|
32
|
+
);
|
|
33
|
+
padding-right: var(
|
|
34
|
+
--recursica_ui-kit_components_badge_properties_padding-horizontal
|
|
35
|
+
);
|
|
36
|
+
padding-top: var(
|
|
37
|
+
--recursica_ui-kit_components_badge_properties_padding-vertical
|
|
38
|
+
);
|
|
39
|
+
padding-bottom: var(
|
|
40
|
+
--recursica_ui-kit_components_badge_properties_padding-vertical
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
font-family: var(
|
|
44
|
+
--recursica_ui-kit_components_badge_properties_text_font-family
|
|
45
|
+
);
|
|
46
|
+
font-size: var(--recursica_ui-kit_components_badge_properties_text_font-size);
|
|
47
|
+
font-weight: var(
|
|
48
|
+
--recursica_ui-kit_components_badge_properties_text_font-weight
|
|
49
|
+
);
|
|
50
|
+
font-style: var(
|
|
51
|
+
--recursica_ui-kit_components_badge_properties_text_font-style
|
|
52
|
+
);
|
|
53
|
+
letter-spacing: var(
|
|
54
|
+
--recursica_ui-kit_components_badge_properties_text_letter-spacing
|
|
55
|
+
);
|
|
56
|
+
line-height: var(
|
|
57
|
+
--recursica_ui-kit_components_badge_properties_text_line-height
|
|
58
|
+
);
|
|
59
|
+
text-decoration: var(
|
|
60
|
+
--recursica_ui-kit_components_badge_properties_text_text-decoration
|
|
61
|
+
);
|
|
62
|
+
text-transform: var(
|
|
63
|
+
--recursica_ui-kit_components_badge_properties_text_text-transform
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/* Variant Definitions */
|
|
68
|
+
|
|
69
|
+
.root[data-variant="alert"] {
|
|
70
|
+
background-color: var(
|
|
71
|
+
--recursica_ui-kit_components_badge_variants_styles_alert_properties_colors_background
|
|
72
|
+
);
|
|
73
|
+
border-color: var(
|
|
74
|
+
--recursica_ui-kit_components_badge_variants_styles_alert_properties_colors_border-color
|
|
75
|
+
);
|
|
76
|
+
color: var(
|
|
77
|
+
--recursica_ui-kit_components_badge_variants_styles_alert_properties_colors_text
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.root[data-variant="primary-color"] {
|
|
82
|
+
background-color: var(
|
|
83
|
+
--recursica_ui-kit_components_badge_variants_styles_primary-color_properties_colors_background
|
|
84
|
+
);
|
|
85
|
+
border-color: var(
|
|
86
|
+
--recursica_ui-kit_components_badge_variants_styles_primary-color_properties_colors_border-color
|
|
87
|
+
);
|
|
88
|
+
color: var(
|
|
89
|
+
--recursica_ui-kit_components_badge_variants_styles_primary-color_properties_colors_text
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.root[data-variant="success"] {
|
|
94
|
+
background-color: var(
|
|
95
|
+
--recursica_ui-kit_components_badge_variants_styles_success_properties_colors_background
|
|
96
|
+
);
|
|
97
|
+
border-color: var(
|
|
98
|
+
--recursica_ui-kit_components_badge_variants_styles_success_properties_colors_border-color
|
|
99
|
+
);
|
|
100
|
+
color: var(
|
|
101
|
+
--recursica_ui-kit_components_badge_variants_styles_success_properties_colors_text
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.root[data-variant="warning"] {
|
|
106
|
+
background-color: var(
|
|
107
|
+
--recursica_ui-kit_components_badge_variants_styles_warning_properties_colors_background
|
|
108
|
+
);
|
|
109
|
+
border-color: var(
|
|
110
|
+
--recursica_ui-kit_components_badge_variants_styles_warning_properties_colors_border-color
|
|
111
|
+
);
|
|
112
|
+
color: var(
|
|
113
|
+
--recursica_ui-kit_components_badge_variants_styles_warning_properties_colors_text
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/* Target Mantine internal children if needed for typography constraints */
|
|
118
|
+
.root :global(.mantine-Badge-label),
|
|
119
|
+
.root :global(.mantine-Badge-section) {
|
|
120
|
+
/* HARDCODE: Prevent Mantine from overriding our typography setup inside inner wrappers */
|
|
121
|
+
font-size: inherit;
|
|
122
|
+
font-weight: inherit;
|
|
123
|
+
line-height: inherit;
|
|
124
|
+
font-family: inherit;
|
|
125
|
+
letter-spacing: inherit;
|
|
126
|
+
text-transform: inherit;
|
|
127
|
+
}
|
|
@@ -1,35 +1,78 @@
|
|
|
1
|
+
import React from "react";
|
|
1
2
|
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
3
|
import { Badge } from "./Badge";
|
|
3
|
-
import {
|
|
4
|
+
import { Layer } from "@recursica/adapter-common";
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
type BadgeStoryProps = React.ComponentProps<typeof Badge>;
|
|
7
|
+
|
|
8
|
+
const meta: Meta<BadgeStoryProps> = {
|
|
9
|
+
title: "UI-Kit/Badge",
|
|
7
10
|
component: Badge,
|
|
8
11
|
tags: ["autodocs"],
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
"children",
|
|
15
|
-
"component",
|
|
16
|
-
"variant",
|
|
17
|
-
"size",
|
|
18
|
-
"icon",
|
|
19
|
-
"disabled",
|
|
20
|
-
"href",
|
|
21
|
-
"onClick",
|
|
22
|
-
"onChange",
|
|
23
|
-
"value",
|
|
24
|
-
"checked",
|
|
25
|
-
],
|
|
12
|
+
argTypes: {
|
|
13
|
+
variant: {
|
|
14
|
+
control: "select",
|
|
15
|
+
options: ["alert", "primary-color", "success", "warning"],
|
|
16
|
+
description: "The style / intent mapping for the badge",
|
|
26
17
|
},
|
|
27
18
|
},
|
|
28
19
|
};
|
|
29
20
|
|
|
30
21
|
export default meta;
|
|
31
|
-
|
|
22
|
+
|
|
23
|
+
type Story = StoryObj<BadgeStoryProps>;
|
|
32
24
|
|
|
33
25
|
export const Default: Story = {
|
|
34
|
-
|
|
26
|
+
args: {
|
|
27
|
+
children: "Badge Label",
|
|
28
|
+
variant: "primary-color",
|
|
29
|
+
},
|
|
30
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
|
|
31
|
+
render: ({ withLayer, layer, ...args }: any) => {
|
|
32
|
+
return <Badge {...args} />;
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export const StaticAlert: Story = {
|
|
37
|
+
args: {
|
|
38
|
+
children: "Alert Badge",
|
|
39
|
+
variant: "alert",
|
|
40
|
+
},
|
|
41
|
+
render: (args: BadgeStoryProps) => <Badge {...args} />,
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export const StaticPrimary: Story = {
|
|
45
|
+
args: {
|
|
46
|
+
children: "Primary Badge",
|
|
47
|
+
variant: "primary-color",
|
|
48
|
+
},
|
|
49
|
+
render: (args: BadgeStoryProps) => <Badge {...args} />,
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export const StaticSuccess: Story = {
|
|
53
|
+
args: {
|
|
54
|
+
children: "Success Badge",
|
|
55
|
+
variant: "success",
|
|
56
|
+
},
|
|
57
|
+
render: (args: BadgeStoryProps) => <Badge {...args} />,
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export const StaticWarning: Story = {
|
|
61
|
+
args: {
|
|
62
|
+
children: "Warning Badge",
|
|
63
|
+
variant: "warning",
|
|
64
|
+
},
|
|
65
|
+
render: (args: BadgeStoryProps) => <Badge {...args} />,
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export const LayerOneAlert: Story = {
|
|
69
|
+
args: {
|
|
70
|
+
children: "Layer 1 Alert",
|
|
71
|
+
variant: "alert",
|
|
72
|
+
},
|
|
73
|
+
render: (args: BadgeStoryProps) => (
|
|
74
|
+
<Layer layer={1} style={{ padding: "24px" }}>
|
|
75
|
+
<Badge {...args} />
|
|
76
|
+
</Layer>
|
|
77
|
+
),
|
|
35
78
|
};
|
|
@@ -1,8 +1,72 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { forwardRef } from "react";
|
|
2
|
+
import {
|
|
3
|
+
Badge as MuiBadge,
|
|
4
|
+
type BadgeProps as MuiBadgeProps,
|
|
5
|
+
} from "@mui/material";
|
|
6
|
+
import {
|
|
7
|
+
filterStylingProps,
|
|
8
|
+
type RecursicaOverStyled,
|
|
9
|
+
} from "../../utils/filterStylingProps";
|
|
10
|
+
import styles from "./Badge.module.css";
|
|
3
11
|
|
|
4
|
-
export
|
|
12
|
+
export interface RecursicaBadgeProps {
|
|
13
|
+
/** Map to the component styles defined in variables */
|
|
14
|
+
variant?: "alert" | "primary-color" | "success" | "warning";
|
|
15
|
+
}
|
|
5
16
|
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
|
|
17
|
+
export type BadgeProps = RecursicaOverStyled<
|
|
18
|
+
Omit<MuiBadgeProps, "variant" | "size" | "color" | "radius"> &
|
|
19
|
+
RecursicaBadgeProps
|
|
20
|
+
>;
|
|
21
|
+
|
|
22
|
+
const _Badge = forwardRef<HTMLDivElement, BadgeProps>(function Badge(
|
|
23
|
+
{ variant = "primary-color", overStyled = false, ...rest },
|
|
24
|
+
ref,
|
|
25
|
+
) {
|
|
26
|
+
// Strip all visual override injections unless developer has specifically opted into overStyling.
|
|
27
|
+
// External layout props like margins are safely preserved.
|
|
28
|
+
const sanitizedProps = filterStylingProps(rest, overStyled);
|
|
29
|
+
|
|
30
|
+
const mergedClassNames: Partial<Record<string, string>> = {
|
|
31
|
+
root: styles.root,
|
|
32
|
+
section: styles.section,
|
|
33
|
+
label: styles.label,
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const classNamesProp = (sanitizedProps as Record<string, unknown>).classNames;
|
|
37
|
+
if (
|
|
38
|
+
classNamesProp &&
|
|
39
|
+
typeof classNamesProp === "object" &&
|
|
40
|
+
!Array.isArray(classNamesProp)
|
|
41
|
+
) {
|
|
42
|
+
const o = classNamesProp as Partial<Record<string, string>>;
|
|
43
|
+
mergedClassNames.root = o.root ? `${styles.root} ${o.root}` : styles.root;
|
|
44
|
+
mergedClassNames.section = o.section ?? styles.section;
|
|
45
|
+
mergedClassNames.label = o.label ?? styles.label;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const classNameProp = (sanitizedProps as Record<string, unknown>)
|
|
49
|
+
.className as string | undefined;
|
|
50
|
+
const finalClass = classNameProp
|
|
51
|
+
? `${styles.root} ${classNameProp}`
|
|
52
|
+
: styles.root;
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<MuiBadge
|
|
56
|
+
ref={ref}
|
|
57
|
+
variant="filled" // We manage visual style purely through our CSS variables mapping
|
|
58
|
+
data-variant={variant}
|
|
59
|
+
{...sanitizedProps}
|
|
60
|
+
className={finalClass}
|
|
61
|
+
classes={mergedClassNames}
|
|
62
|
+
/>
|
|
63
|
+
);
|
|
64
|
+
});
|
|
65
|
+
_Badge.displayName = "Badge";
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Recursica Badge component wrapping Mui's Badge.
|
|
69
|
+
*
|
|
70
|
+
* Supports polymorphism via the `component` prop or `renderRoot` for custom element rendering.
|
|
71
|
+
*/
|
|
72
|
+
export const Badge = _Badge as any;
|
|
@@ -1,6 +1,26 @@
|
|
|
1
|
-
/*
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/* HARDCODED VALUES:
|
|
2
|
+
- align-items: center
|
|
3
|
+
*/
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
/*
|
|
5
|
+
.root {
|
|
6
|
+
/* HARDCODE: Basic structural flex layout for breadcrumbs */
|
|
7
|
+
display: flex;
|
|
8
|
+
align-items: center;
|
|
9
|
+
|
|
10
|
+
/* Base style resets */
|
|
11
|
+
background-color: transparent;
|
|
12
|
+
color: inherit;
|
|
13
|
+
|
|
14
|
+
/* Apply global breadcrumb properties */
|
|
15
|
+
padding: var(--recursica_ui-kit_components_breadcrumb_properties_padding);
|
|
16
|
+
|
|
17
|
+
/* Mantine's breadcrumbs uses gap on the root or pseudo classes, but standard gap is safest since flex is used */
|
|
18
|
+
gap: var(--recursica_ui-kit_components_breadcrumb_properties_item-gap);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.separator {
|
|
22
|
+
/* Separator base resets if needed */
|
|
23
|
+
display: flex;
|
|
24
|
+
align-items: center;
|
|
25
|
+
justify-content: center;
|
|
26
|
+
}
|