@wonderflow/react-components 14.2.0 → 14.2.2

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 +1 @@
1
- {"version":3,"file":"product-card.d.ts","sourceRoot":"","sources":["../../../src/components/product-card/product-card.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EACA,iBAAiB,EAE9B,MAAM,OAAO,CAAC;AASf,OAAO,EAAqB,0BAA0B,EAAE,MAAM,2CAA2C,CAAC;AAC1G,OAAO,EAAqB,0BAA0B,EAAE,sBAAsB,EAAE,MAAM,2CAA2C,CAAC;AAClI,OAAO,EAAmB,wBAAwB,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AACxH,OAAO,EAAoB,yBAAyB,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;AAE7H,oBAAY,gBAAgB,GAAG,cAAc,CAAC,iBAAiB,CAAC;IAC9D;;OAEG;IACH,SAAS,CAAC,EAAE,UAAU,GAAG,YAAY,CAAC;IACtC;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;OAEG;IACH,cAAc,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACjC;;OAEG;IACH,MAAM,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACzB;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB,CAAC,CAAC,GACD,IAAI,CAAC,qBAAqB,EAAE,OAAO,GAAG,QAAQ,CAAC,GAC/C,IAAI,CAAC,sBAAsB,EAAE,OAAO,GAAG,WAAW,GAAG,UAAU,GAAG,aAAa,CAAC,GAChF,IAAI,CAAC,oBAAoB,EAAE,QAAQ,GAAG,eAAe,GAAG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AAC,EAAE,OAAO,CAAC;IACpB;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB,CAAC,CAAC,GACD,IAAI,CAAC,qBAAqB,EAAE,OAAO,GAAG,QAAQ,CAAC,GAC/C,IAAI,CAAC,sBAAsB,EAAE,OAAO,GAAG,WAAW,GAAG,UAAU,GAAG,aAAa,CAAC,GAChF,IAAI,CAAC,oBAAoB,EAAE,QAAQ,GAAG,eAAe,GAAG,YAAY,GAAG,aAAa,GAAG,OAAO,GAAG,MAAM,GAAG,WAAW,GAAG,UAAU,GAAG,UAAU,GAAG,KAAK,GAAG,YAAY,GAAG,UAAU,GAAG,QAAQ,GAAG,KAAK,GAAG,SAAS,GAAG,UAAU,GAAG,UAAU,GAC9O,kBAAkB,CAAC,CAAA;AAuBnB,oBAAY,oBAAoB,GAAG,KAAK,CAAC,yBAAyB,CAAC,gBAAgB,CAAC,GAAG;IACrF,KAAK,EAAE,yBAAyB,CAAC;IACjC,IAAI,EAAE,wBAAwB,CAAC;IAC/B,MAAM,EAAE,0BAA0B,CAAC;IACnC,MAAM,EAAE,0BAA0B,CAAC;CACpC,CAAC;AAEF,eAAO,MAAM,WAAW,sBAwLE,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import tkns from '@wonderflow/tokens/platforms/web/tokens.json';
2
3
  import { useDebounce } from 'ahooks';
3
4
  import clsx from 'clsx';
4
5
  import { forwardRef, useRef, } from 'react';
@@ -9,29 +10,21 @@ import { ProductCardHeader } from './product-card-header/product-card-header';
9
10
  import { ProductCardKpis } from './product-card-kpis/product-card-kpis';
10
11
  import { ProductCardMedia } from './product-card-media/product-card-media';
11
12
  const getColorFromString = (input) => {
13
+ const colorPalette = tkns.color;
12
14
  // Generate a hash from the input string
13
15
  let hash = 0;
14
- let color = '#';
15
- const rgb = [];
16
16
  for (let i = 0; i < input.length; i += 1) {
17
17
  // eslint-disable-next-line no-bitwise
18
18
  hash = input.charCodeAt(i) + ((hash << 5) - hash);
19
19
  }
20
- for (let i = 0; i < 3; i += 1) {
21
- // eslint-disable-next-line no-bitwise
22
- const value = (hash >> (i * 8)) & 0xFF;
23
- rgb.push(value);
24
- color += (`00${value.toString(16)}`).slice(-2);
25
- }
26
- // Calculate luminance to check if the color is too light
27
- const [r, g, b] = rgb.map(v => v / 255);
28
- const luminance = 0.2126 * r + 0.7152 * g + 0.0722 * b;
29
- if (luminance > 0.8) {
30
- const darkenedRgb = rgb.map(v => Math.floor(v * 0.6));
31
- color = darkenedRgb.map(value => (`00${value.toString(16)}`).slice(-2)).join('');
32
- color = `#${color}`;
33
- }
34
- return color;
20
+ // Get all color keys
21
+ const colorKeys = Object.keys(colorPalette);
22
+ // Pick a color family based on the hash
23
+ const colorFamily = colorKeys[Math.abs(hash) % colorKeys.length];
24
+ // Return the first shade of the selected color family
25
+ const shades = colorPalette[colorFamily];
26
+ const firstShade = Object.values(shades)[5];
27
+ return `hsl(${firstShade})`;
35
28
  };
36
29
  export const ProductCard = forwardRef(({ direction = 'vertical', bordered = false, highlightOnHover = false, title, titleRows = 3, subtitle, menuActions, rating, feedbackCount, votesCount, votesRating, sentiment, nps, groups, tgw, priceMin, priceMax, currency, currencyDecimals, users, usersCap, skus, skusCap, kpiItems, kpisRowGap, ratio, source, footer, overlayActions, onClick, isLoading = false, hasColoredCover = false, className, style, children, ...otherProps }, forwardedRef) => {
37
30
  const hasOverlay = !!(overlayActions && !menuActions && !onClick && !isLoading);
@@ -1 +1 @@
1
- @layer components{.Card{background-color:var(--global-background);border-radius:.5rem;overflow:hidden;padding:0;position:relative}.Card[data-card-bordered=true]{border:1px solid var(--dimmed-1)}.Card[data-card-clickable=true]{cursor:pointer}.Row{height:100%;position:relative}.Content{flex-grow:1}.OverlayActions{background-color:var(--global-background);height:100%;opacity:0;position:absolute;transition:opacity .3s;width:100%;z-index:1}.OverlayActions:hover{opacity:1}.ColoredCard{height:125px;width:100%}}
1
+ @layer components{.Card{background-color:var(--global-background);border-radius:.5rem;overflow:hidden;padding:0;position:relative}.Card[data-card-bordered=true]{border:1px solid var(--dimmed-1)}.Card[data-card-clickable=true]{cursor:pointer}.Row{height:100%;position:relative}.Content{flex-grow:1}.OverlayActions{background-color:var(--global-background);height:100%;opacity:0;position:absolute;transition:opacity .3s;width:100%;z-index:1}.OverlayActions:hover{opacity:1}.ColoredCard{height:125px;max-height:125px;width:100%}}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wonderflow/react-components",
3
- "version": "14.2.0",
3
+ "version": "14.2.2",
4
4
  "description": "UI components from Wonderflow's Wanda design system",
5
5
  "author": "Wonderflow",
6
6
  "license": "Apache-2.0",
@@ -82,9 +82,9 @@
82
82
  "@types/react-dom": "17.0.14",
83
83
  "@types/react-table": "7.7.20",
84
84
  "@types/react-test-renderer": "18.0.7",
85
- "@wonderflow/config": "14.2.0",
86
- "@wonderflow/tokens": "14.2.0",
87
- "@wonderflow/charts": "14.2.0",
85
+ "@wonderflow/config": "14.2.2",
86
+ "@wonderflow/tokens": "14.2.2",
87
+ "@wonderflow/charts": "14.2.2",
88
88
  "@types/uuid": "9.0.8",
89
89
  "babel-loader": "8.2.5",
90
90
  "cpy-cli": "3.1.1",