@edifice.io/react 2.5.5-develop-pedago.20260112142155 → 2.5.5-develop-pedago.20260113163234

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.
@@ -1,5 +1,5 @@
1
1
  import { ReactNode } from 'react';
2
- import { UserProfile } from '@edifice.io/client';
2
+ import { IWebApp, UserProfile } from '@edifice.io/client';
3
3
  export type BadgeRef = HTMLSpanElement;
4
4
  /** Badge variant : notification */
5
5
  export type NotificationBadgeVariant = {
@@ -29,12 +29,15 @@ export type LinkBadgeVariant = {
29
29
  /**
30
30
  * Badge variant : beta.
31
31
  * Beta Badge is used to indicate that a feature is in beta phase.
32
- * The color prop allows to customize the badge color to match the app color.
33
- * Defaults to black if not provided.
32
+ * Beta Badge has a fixed text 'BÊTA' unless children is provided.
33
+ * If app is provided, the color of the Beta Badge is derived from the application colors.
34
+ * Example:
35
+ * <Badge variant={{ type: 'beta', app: myApp }} />
36
+ * where myApp is of type IWebApp.
34
37
  */
35
38
  export type BetaBadgeVariant = {
36
39
  type: 'beta';
37
- color?: string;
40
+ app?: IWebApp;
38
41
  };
39
42
  export type BadgeVariants = NotificationBadgeVariant | ContentBadgeVariant | ProfileBadgeVariant | ChipBadgeVariant | LinkBadgeVariant | BetaBadgeVariant;
40
43
  export interface BadgeProps extends React.ComponentPropsWithRef<'span'> {
@@ -1,6 +1,7 @@
1
1
  import { jsxs, jsx } from "react/jsx-runtime";
2
2
  import { forwardRef } from "react";
3
3
  import clsx from "clsx";
4
+ import useEdificeIcons from "../../hooks/useEdificeIcons/useEdificeIcons.js";
4
5
  const Badge = /* @__PURE__ */ forwardRef(({
5
6
  className,
6
7
  variant = {
@@ -10,17 +11,19 @@ const Badge = /* @__PURE__ */ forwardRef(({
10
11
  children,
11
12
  ...restProps
12
13
  }, ref) => {
13
- const classes = clsx("badge rounded-pill", (variant.type === "content" || variant.type === "user") && "background" in variant ? "bg-gray-200" : (variant.type === "content" || variant.type === "user") && !("background" in variant) ? "border border-0" : "", variant.type === "content" && `text-${variant.level}`, variant.type === "notification" && `badge-notification bg-${variant.level} text-light border border-0`, variant.type === "user" && `badge-profile-${variant.profile.toLowerCase()}`, variant.type === "link" && "badge-link border border-0", variant.type === "chip" && "bg-gray-200", className);
14
- return /* @__PURE__ */ jsxs("span", { ref, className: classes, style: (() => {
15
- if (variant.type !== "beta") return;
16
- const color = variant.color ?? "#000000";
17
- return {
18
- borderColor: color,
19
- color,
20
- backgroundColor: `${color}10`
21
- // the 2 last hexadecimal numbers are for opacity
22
- };
23
- })(), ...restProps, children: [
14
+ const {
15
+ getIconClass,
16
+ getBackgroundLightIconClass,
17
+ getBorderIconClass
18
+ } = useEdificeIcons();
19
+ let badgeColorClassName = "";
20
+ if (variant.type === "beta" && variant.app) {
21
+ const colorAppClassName = getIconClass(variant.app), backgroundLightAppClassName = getBackgroundLightIconClass(variant.app), borderAppClassName = getBorderIconClass(variant.app);
22
+ badgeColorClassName = `${colorAppClassName} ${backgroundLightAppClassName} ${borderAppClassName}`;
23
+ }
24
+ console.log(badgeColorClassName);
25
+ const classes = clsx("badge rounded-pill", (variant.type === "content" || variant.type === "user") && "background" in variant ? "bg-gray-200" : (variant.type === "content" || variant.type === "user") && !("background" in variant) ? "border border-0" : "", variant.type === "content" && `text-${variant.level}`, variant.type === "notification" && `badge-notification bg-${variant.level} text-light border border-0`, variant.type === "user" && `badge-profile-${variant.profile.toLowerCase()}`, variant.type === "link" && "badge-link border border-0", variant.type === "chip" && "bg-gray-200", variant.type === "beta" && badgeColorClassName, className);
26
+ return /* @__PURE__ */ jsxs("span", { ref, className: classes, ...restProps, children: [
24
27
  variant.type === "chip" && /* @__PURE__ */ jsx("div", { className: "d-flex fw-800 align-items-center", children }),
25
28
  variant.type === "beta" && (children ?? "BÊTA"),
26
29
  variant.type !== "chip" && variant.type !== "beta" && children
@@ -3,6 +3,7 @@ export default function useEdificeIcons(): {
3
3
  getIconClass: (app: IWebApp | string) => string;
4
4
  getBackgroundIconClass: (app: IWebApp | string) => string;
5
5
  getBackgroundLightIconClass: (app: IWebApp | string) => string;
6
+ getBorderIconClass: (app: IWebApp | string) => string;
6
7
  getIconCode: (app: IWebApp | string | undefined) => string;
7
8
  getWidgetIconClass: (widget: IWidget) => string;
8
9
  isIconUrl: (icon: string) => string | boolean;
@@ -78,6 +78,10 @@ function useEdificeIcons() {
78
78
  const appCode = getIconCode(app);
79
79
  return appCode ? `bg-light-${appCode}` : "bg-light-placeholder";
80
80
  }
81
+ function getBorderIconClass(app) {
82
+ const appCode = getIconCode(app);
83
+ return appCode ? `border-app-${appCode}` : "border-app-placeholder";
84
+ }
81
85
  function getWidgetIconClass(widget) {
82
86
  return iconOfWidget[widget.platformConf.name];
83
87
  }
@@ -85,6 +89,7 @@ function useEdificeIcons() {
85
89
  getIconClass,
86
90
  getBackgroundIconClass,
87
91
  getBackgroundLightIconClass,
92
+ getBorderIconClass,
88
93
  getIconCode,
89
94
  getWidgetIconClass,
90
95
  isIconUrl
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edifice.io/react",
3
- "version": "2.5.5-develop-pedago.20260112142155",
3
+ "version": "2.5.5-develop-pedago.20260113163234",
4
4
  "description": "Edifice React Library",
5
5
  "keywords": [
6
6
  "react",
@@ -134,9 +134,9 @@
134
134
  "react-slugify": "^3.0.3",
135
135
  "swiper": "^10.1.0",
136
136
  "ua-parser-js": "^1.0.36",
137
- "@edifice.io/bootstrap": "2.5.5-develop-pedago.20260112142155",
138
- "@edifice.io/tiptap-extensions": "2.5.5-develop-pedago.20260112142155",
139
- "@edifice.io/utilities": "2.5.5-develop-pedago.20260112142155"
137
+ "@edifice.io/bootstrap": "2.5.5-develop-pedago.20260113163234",
138
+ "@edifice.io/tiptap-extensions": "2.5.5-develop-pedago.20260113163234",
139
+ "@edifice.io/utilities": "2.5.5-develop-pedago.20260113163234"
140
140
  },
141
141
  "devDependencies": {
142
142
  "@babel/plugin-transform-react-pure-annotations": "^7.23.3",
@@ -167,8 +167,8 @@
167
167
  "vite": "^5.4.11",
168
168
  "vite-plugin-dts": "^4.1.0",
169
169
  "vite-tsconfig-paths": "^5.0.1",
170
- "@edifice.io/client": "2.5.5-develop-pedago.20260112142155",
171
- "@edifice.io/config": "2.5.5-develop-pedago.20260112142155"
170
+ "@edifice.io/client": "2.5.5-develop-pedago.20260113163234",
171
+ "@edifice.io/config": "2.5.5-develop-pedago.20260113163234"
172
172
  },
173
173
  "peerDependencies": {
174
174
  "@react-spring/web": "^9.7.5",