@ews-admin/global-design-system 1.31.0 → 1.32.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ews-admin/global-design-system",
3
- "version": "1.31.0",
3
+ "version": "1.32.0",
4
4
  "description": "EWS Global Design System - Reusable components for EWS applications",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",
@@ -32,6 +32,7 @@
32
32
  "@eslint/js": "^9.36.0",
33
33
  "@rollup/plugin-babel": "^6.0.4",
34
34
  "@rollup/plugin-commonjs": "^25.0.7",
35
+ "@rollup/plugin-image": "^3.0.3",
35
36
  "@rollup/plugin-node-resolve": "^15.2.3",
36
37
  "@rollup/plugin-typescript": "^11.1.5",
37
38
  "@storybook/addon-essentials": "^7.5.0",
Binary file
Binary file
Binary file
@@ -1,5 +1,7 @@
1
+ import type { SyntheticEvent } from "react";
1
2
  import { cn } from "../../utils";
2
3
  import type { LogoProps } from "./Logo.types";
4
+ import { logoAssets } from "./logoAssets";
3
5
 
4
6
  const Logo = ({
5
7
  size = "md",
@@ -26,19 +28,19 @@ const Logo = ({
26
28
  xl: "h-16 w-16",
27
29
  };
28
30
 
29
- // Get the appropriate logo image based on variant or custom source
30
- // For iconOnly, always use favicon.ico unless customSrc is provided
31
- const logoSrc =
32
- customSrc ||
33
- (iconOnly
34
- ? "/favicon.ico"
35
- : variant === "white"
36
- ? "/image/logoWhite.png"
37
- : variant === "fullWhite"
38
- ? "/image/logoFullWhite.png"
39
- : variant === "favicon"
40
- ? "/favicon.ico"
41
- : "/image/logo.png");
31
+ // Bundled logo per variant (MED-1629); customSrc wins. iconOnly always uses the icon.
32
+ const logoSrc = customSrc || (iconOnly ? logoAssets.favicon : logoAssets[variant]);
33
+ const fallbackSrc = iconOnly ? logoAssets.favicon : logoAssets.normal;
34
+
35
+ // On a load error, fall back to the bundled logo once, then hide the image (keeps layout).
36
+ const handleError = (e: SyntheticEvent<HTMLImageElement>) => {
37
+ const img = e.currentTarget;
38
+ if (img.getAttribute("src") !== fallbackSrc) {
39
+ img.src = fallbackSrc;
40
+ } else {
41
+ img.style.visibility = "hidden";
42
+ }
43
+ };
42
44
 
43
45
  const isClickable = clickable || !!onClick;
44
46
 
@@ -69,12 +71,7 @@ const Logo = ({
69
71
  src={logoSrc}
70
72
  alt={alt}
71
73
  className="object-contain w-full h-full"
72
- onError={(e) => {
73
- // Fallback to favicon if image fails to load
74
- if (logoSrc !== "/favicon.ico") {
75
- (e.target as unknown as { src: string }).src = "/favicon.ico";
76
- }
77
- }}
74
+ onError={handleError}
78
75
  />
79
76
  </div>
80
77
  );
@@ -107,12 +104,7 @@ const Logo = ({
107
104
  src={logoSrc}
108
105
  alt={alt}
109
106
  className="object-contain w-auto h-full"
110
- onError={(e) => {
111
- // Fallback to favicon if image fails to load
112
- if (logoSrc !== "/favicon.ico") {
113
- (e.target as unknown as { src: string }).src = "/favicon.ico";
114
- }
115
- }}
107
+ onError={handleError}
116
108
  />
117
109
  </div>
118
110
  );
@@ -0,0 +1,16 @@
1
+ /**
2
+ * MED-1629: the Medecine360 logos ship with the package (inlined as data URIs by
3
+ * @rollup/plugin-image), so consuming apps need no `/image/logo*.png` in their public folder.
4
+ * Sized to 2x the largest rendered height (Logo xl = 96px, icon xl = 64px).
5
+ */
6
+ import logoIcon from "../../assets/logo/logoIcon.png";
7
+ import logo from "../../assets/logo/logo.png";
8
+ import logoFullWhite from "../../assets/logo/logoFullWhite.png";
9
+ import logoWhite from "../../assets/logo/logoWhite.png";
10
+
11
+ export const logoAssets = {
12
+ normal: logo,
13
+ white: logoWhite,
14
+ fullWhite: logoFullWhite,
15
+ favicon: logoIcon,
16
+ } as const;
@@ -0,0 +1,5 @@
1
+ /** MED-1629: image imports resolve to a URL string (an inlined data URI in the Rollup build). */
2
+ declare module "*.png" {
3
+ const src: string;
4
+ export default src;
5
+ }