@agilant/toga-blox 1.0.25 → 1.0.27
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/dist/components/ImageContainer/ImageContainer.js +2 -6
- package/dist/components/ImageContainer/ImageContainer.stories.js +12 -1
- package/dist/components/ImageContainer/ImageContainer.test.js +3 -3
- package/dist/components/ImageContainer/ImageContainer.types.d.ts +2 -1
- package/dist/components/Text/Text.js +2 -2
- package/dist/components/Text/Text.stories.js +7 -0
- package/dist/components/Text/Text.test.js +7 -1
- package/dist/components/Text/Text.types.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
const ImageContainer = (props) => {
|
|
3
|
-
const { imageUrl, backgroundColor, borderRadius, size, alternativeText, userInitials, additionalClasses,
|
|
4
|
-
return (_jsx("div", { style: {
|
|
5
|
-
backgroundColor: inlineBackgroundColor
|
|
6
|
-
? inlineBackgroundColor
|
|
7
|
-
: backgroundColor,
|
|
8
|
-
}, className: `${borderRadius} ${backgroundColor} ${size} flex items-center justify-center overflow-hidden ${additionalClasses}`, children: imageUrl ? (_jsx("img", { src: imageUrl, alt: alternativeText, className: `${size}` })) : (_jsx("p", { className: `text-xs text-white w-full h-full flex justify-center items-center `, children: userInitials || "N/A" })) }));
|
|
3
|
+
const { imageUrl, backgroundColor, borderRadius, size, alternativeText, userInitials, additionalClasses, style, imageClasses, } = props;
|
|
4
|
+
return (_jsx("div", { style: style, className: `${borderRadius} ${backgroundColor} ${size} flex items-center justify-center overflow-hidden ${additionalClasses}`, children: imageUrl ? (_jsx("img", { src: imageUrl, alt: alternativeText, className: `${imageClasses}` })) : (_jsx("p", { className: `text-xs text-white w-full h-full flex justify-center items-center `, children: userInitials || "N/A" })) }));
|
|
9
5
|
};
|
|
10
6
|
export default ImageContainer;
|
|
@@ -40,6 +40,17 @@ export default {
|
|
|
40
40
|
control: "none",
|
|
41
41
|
description: "Additional styling classes of the image container.",
|
|
42
42
|
},
|
|
43
|
+
tyle: {
|
|
44
|
+
control: {
|
|
45
|
+
type: "object", // Text input control
|
|
46
|
+
},
|
|
47
|
+
description: "Inline CSS styles to be added.",
|
|
48
|
+
defaultValue: "",
|
|
49
|
+
},
|
|
50
|
+
imageClasses: {
|
|
51
|
+
control: "none",
|
|
52
|
+
description: "Additional styling classes of the image.",
|
|
53
|
+
},
|
|
43
54
|
},
|
|
44
55
|
};
|
|
45
56
|
const Template = (args) => (_jsx(ImageContainer, { ...args }));
|
|
@@ -73,5 +84,5 @@ WithInlineBackgroundColor.args = {
|
|
|
73
84
|
size: "h-14 w-14",
|
|
74
85
|
alternativeText: "",
|
|
75
86
|
userInitials: "AS",
|
|
76
|
-
|
|
87
|
+
style: { backgroundColor: "hsl(354,94%,74%)" },
|
|
77
88
|
};
|
|
@@ -21,10 +21,10 @@ describe("ImageContainer Component", () => {
|
|
|
21
21
|
expect(imageElement).toHaveClass("rounded-full");
|
|
22
22
|
});
|
|
23
23
|
});
|
|
24
|
-
describe("ImageContainer -
|
|
25
|
-
test("applies
|
|
24
|
+
describe("ImageContainer - inline styles ", () => {
|
|
25
|
+
test("applies inline style BackgroundColor style when provided", () => {
|
|
26
26
|
const inlineBackgroundColor = "rgb(255, 0, 0)";
|
|
27
|
-
render(_jsx(ImageContainer, { imageUrl: "",
|
|
27
|
+
render(_jsx(ImageContainer, { imageUrl: "", style: { backgroundColor: inlineBackgroundColor }, borderRadius: "rounded-full", size: "w-10 h-10", userInitials: "AB", additionalClasses: "shadow-md" }));
|
|
28
28
|
const container = screen.getByText("AB").parentElement;
|
|
29
29
|
expect(container).toHaveStyle(`background-color: ${inlineBackgroundColor}`);
|
|
30
30
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
const Text = ({ size = "text-base", color = "text-black", tag = "span", text, fontFamily = "font-sans", additionalClasses = "", ...props }) => {
|
|
2
|
+
const Text = ({ size = "text-base", color = "text-black", tag = "span", text, fontFamily = "font-sans", additionalClasses = "", style = {}, ...props }) => {
|
|
3
3
|
const ElementTag = tag;
|
|
4
4
|
const className = `
|
|
5
5
|
${size}
|
|
@@ -7,6 +7,6 @@ const Text = ({ size = "text-base", color = "text-black", tag = "span", text, fo
|
|
|
7
7
|
${fontFamily}
|
|
8
8
|
${additionalClasses}
|
|
9
9
|
`;
|
|
10
|
-
return (_jsx(ElementTag, { "data-testid": "text", className: className, ...props, children: text }));
|
|
10
|
+
return (_jsx(ElementTag, { "data-testid": "text", className: className, style: style, ...props, children: text }));
|
|
11
11
|
};
|
|
12
12
|
export default Text;
|
|
@@ -61,6 +61,13 @@ export default {
|
|
|
61
61
|
description: "Additional Tailwind CSS classes to be added.",
|
|
62
62
|
defaultValue: "",
|
|
63
63
|
},
|
|
64
|
+
style: {
|
|
65
|
+
control: {
|
|
66
|
+
type: "object", // Text input control
|
|
67
|
+
},
|
|
68
|
+
description: "Inline CSS styles to be added.",
|
|
69
|
+
defaultValue: "",
|
|
70
|
+
},
|
|
64
71
|
},
|
|
65
72
|
tags: ["autodocs"],
|
|
66
73
|
parameters: {
|
|
@@ -4,7 +4,7 @@ import { describe, expect, beforeEach, test } from "vitest";
|
|
|
4
4
|
import Text from "./Text";
|
|
5
5
|
describe("<Text />", () => {
|
|
6
6
|
beforeEach(() => {
|
|
7
|
-
render(_jsx(Text, { text: "Testing", size: "text-md", color: "text-red-500", tag: "h1", fontFamily: "font-sans" }));
|
|
7
|
+
render(_jsx(Text, { text: "Testing", size: "text-md", color: "text-red-500", tag: "h1", fontFamily: "font-sans", style: { fontSize: "24px" } }));
|
|
8
8
|
});
|
|
9
9
|
test("renders Text component", () => {
|
|
10
10
|
expect(screen.getByTestId("text")).toBeInTheDocument();
|
|
@@ -28,4 +28,10 @@ describe("<Text />", () => {
|
|
|
28
28
|
const textElement = screen.getByTestId("text");
|
|
29
29
|
expect(textElement.tagName).toBe("H1");
|
|
30
30
|
});
|
|
31
|
+
test("applies inline styles correctly", () => {
|
|
32
|
+
const textElement = screen.getByTestId("text");
|
|
33
|
+
expect(textElement).toHaveStyle({
|
|
34
|
+
fontSize: "24px",
|
|
35
|
+
});
|
|
36
|
+
});
|
|
31
37
|
});
|