@agilant/toga-blox 1.0.23 → 1.0.25

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.
@@ -3,7 +3,6 @@ import { render, screen, fireEvent } from "@testing-library/react";
3
3
  import { describe, expect, test, vi } from "vitest";
4
4
  import Button from "./BaseButton";
5
5
  import { MemoryRouter } from "react-router-dom";
6
- import { getFontAwesomeIcon } from "../../utils/getFontAwesomeIcon";
7
6
  import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
8
7
  import { faCheck } from "@fortawesome/free-solid-svg-icons";
9
8
  describe("Button", () => {
@@ -22,7 +21,6 @@ describe("Button", () => {
22
21
  expect(screen.getByText("Default Button")).toHaveTextContent("Default Button");
23
22
  });
24
23
  test("renders the button with an icon", () => {
25
- const icon = getFontAwesomeIcon("check");
26
24
  render(_jsx(Button, { text: "Search Button", icon: _jsx(FontAwesomeIcon, { icon: faCheck }) }));
27
25
  const buttonElement = screen.getByText("Search Button");
28
26
  expect(buttonElement).toHaveTextContent("Search Button");
@@ -1,7 +1,10 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  const ImageContainer = (props) => {
3
- const { imageUrl, backgroundColor, borderRadius, size, alternativeText, userInitials, additionalClasses, } = props;
4
- console.log(`${borderRadius} ${backgroundColor} ${size} flex items-center justify-center overflow-hidden ${additionalClasses}`, "in component ");
5
- return (_jsx("div", { 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, inlineBackgroundColor, } = props;
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" })) }));
6
9
  };
7
10
  export default ImageContainer;
@@ -4,3 +4,4 @@ export default _default;
4
4
  export declare const Default: any;
5
5
  export declare const ProfileIcon: any;
6
6
  export declare const WithoutImage: any;
7
+ export declare const WithInlineBackgroundColor: any;
@@ -66,3 +66,12 @@ WithoutImage.args = {
66
66
  userInitials: "AS",
67
67
  backgroundColor: "bg-gray-500",
68
68
  };
69
+ export const WithInlineBackgroundColor = Template.bind({});
70
+ WithInlineBackgroundColor.args = {
71
+ imageUrl: "",
72
+ borderRadius: "rounded-full",
73
+ size: "h-14 w-14",
74
+ alternativeText: "",
75
+ userInitials: "AS",
76
+ inlineBackgroundColor: "hsl(354,94%,74%)",
77
+ };
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { describe, it, expect } from "vitest";
3
- import { render } from "@testing-library/react";
2
+ import { describe, it, expect, test } from "vitest";
3
+ import { render, screen } from "@testing-library/react";
4
4
  import ImageContainer from "./ImageContainer";
5
5
  describe("ImageContainer Component", () => {
6
6
  const testUrl = "https://via.placeholder.com/150";
@@ -21,3 +21,43 @@ describe("ImageContainer Component", () => {
21
21
  expect(imageElement).toHaveClass("rounded-full");
22
22
  });
23
23
  });
24
+ describe("ImageContainer - inlineBackgroundColor", () => {
25
+ test("applies inlineBackgroundColor style when provided", () => {
26
+ const inlineBackgroundColor = "rgb(255, 0, 0)";
27
+ render(_jsx(ImageContainer, { imageUrl: "", inlineBackgroundColor: inlineBackgroundColor, borderRadius: "rounded-full", size: "w-10 h-10", userInitials: "AB", additionalClasses: "shadow-md" }));
28
+ const container = screen.getByText("AB").parentElement;
29
+ expect(container).toHaveStyle(`background-color: ${inlineBackgroundColor}`);
30
+ });
31
+ test("does not apply inline style when inlineBackgroundColor is not provided but applies backgroundColor prop", () => {
32
+ const backgroundColor = "bg-blue-500";
33
+ render(_jsx(ImageContainer, { imageUrl: "", backgroundColor: backgroundColor, borderRadius: "rounded-full", size: "w-10 h-10", userInitials: "AB", additionalClasses: "shadow-md" }));
34
+ const container = screen.getByText("AB").parentElement;
35
+ expect(container).not.toHaveStyle(`background-color: ${backgroundColor}`);
36
+ });
37
+ });
38
+ describe("ImageContainer - userInitials", () => {
39
+ test("renders userInitials when imageUrl is not provided", () => {
40
+ render(_jsx(ImageContainer, { imageUrl: "", userInitials: "AB", borderRadius: "rounded-full", size: "w-10 h-10", backgroundColor: "bg-blue-500" }));
41
+ // Assert that user initials are displayed
42
+ const initials = screen.getByText("AB");
43
+ expect(initials).toBeInTheDocument();
44
+ expect(initials).toHaveTextContent("AB");
45
+ });
46
+ test("renders default fallback text when userInitials is not provided", () => {
47
+ render(_jsx(ImageContainer, { imageUrl: "", userInitials: "", borderRadius: "rounded-full", size: "w-10 h-10", backgroundColor: "bg-blue-500" }));
48
+ // Assert that default fallback text is displayed
49
+ const fallbackText = screen.getByText("N/A");
50
+ expect(fallbackText).toBeInTheDocument();
51
+ expect(fallbackText).toHaveTextContent("N/A");
52
+ });
53
+ test("does not render userInitials when imageUrl is provided", () => {
54
+ render(_jsx(ImageContainer, { imageUrl: "https://via.placeholder.com/150", userInitials: "AB", borderRadius: "rounded-full", size: "w-10 h-10", backgroundColor: "bg-blue-500" }));
55
+ // Assert that user initials are not displayed
56
+ const initials = screen.queryByText("AB");
57
+ expect(initials).not.toBeInTheDocument();
58
+ // Assert that the image is displayed instead
59
+ const image = screen.getByRole("img");
60
+ expect(image).toBeInTheDocument();
61
+ expect(image).toHaveAttribute("src", "https://via.placeholder.com/150");
62
+ });
63
+ });
@@ -6,4 +6,5 @@ export interface ImageContainerProps {
6
6
  alternativeText?: string;
7
7
  userInitials?: string;
8
8
  additionalClasses?: string;
9
+ inlineBackgroundColor?: string;
9
10
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@agilant/toga-blox",
3
3
  "private": false,
4
- "version": "1.0.23",
4
+ "version": "1.0.25",
5
5
  "description": "",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",