@moda/om 17.1.0 → 17.3.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.
@@ -11,7 +11,7 @@ export declare type ColorSwatchProps = Omit<Omit<React.ButtonHTMLAttributes<HTML
11
11
  selected?: boolean;
12
12
  soldOut?: boolean;
13
13
  onSale?: boolean;
14
- onClick?(color: string): void;
15
- onMouseEnter?(color: string): void;
14
+ onClick?(color: string, title?: string): void;
15
+ onMouseEnter?(color: string, title?: string): void;
16
16
  };
17
17
  export declare const ColorSwatch: React.FC<ColorSwatchProps>;
@@ -13,6 +13,7 @@ export declare const SKU_COLORS: {
13
13
  'rose gold': string;
14
14
  'royal blue': string;
15
15
  animal: undefined;
16
+ berry: string;
16
17
  black: string;
17
18
  blue: string;
18
19
  bronze: string;
@@ -43,7 +44,9 @@ export declare const SKU_COLORS: {
43
44
  silver: string;
44
45
  stripe: undefined;
45
46
  tan: string;
47
+ taupe: string;
46
48
  turquoise: string;
49
+ universal: undefined;
47
50
  white: string;
48
51
  yellow: string;
49
52
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moda/om",
3
- "version": "17.1.0",
3
+ "version": "17.3.0",
4
4
  "description": "Moda Operandi design system",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
@@ -18,8 +18,8 @@ export type ColorSwatchProps = Omit<
18
18
  selected?: boolean;
19
19
  soldOut?: boolean;
20
20
  onSale?: boolean;
21
- onClick?(color: string): void;
22
- onMouseEnter?(color: string): void;
21
+ onClick?(color: string, title?: string): void;
22
+ onMouseEnter?(color: string, title?: string): void;
23
23
  };
24
24
 
25
25
  export const ColorSwatch: React.FC<ColorSwatchProps> = ({
@@ -35,26 +35,33 @@ export const ColorSwatch: React.FC<ColorSwatchProps> = ({
35
35
  onClick,
36
36
  onMouseEnter,
37
37
  disabled,
38
+ title,
38
39
  ...rest
39
40
  }) => {
40
41
  const handleClick = useCallback(
41
42
  (_event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {
42
- onClick && onClick(color);
43
+ onClick && onClick(color, title);
43
44
  },
44
- [color, onClick]
45
+ [color, title, onClick]
45
46
  );
46
47
 
47
48
  const handleMouseEnter = useCallback(
48
49
  (_event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {
49
- onMouseEnter && onMouseEnter(color);
50
+ onMouseEnter && onMouseEnter(color, title);
50
51
  },
51
- [color, onMouseEnter]
52
+ [color, title, onMouseEnter]
52
53
  );
53
54
 
54
- const backgroundColor = SKU_COLORS[color as SkuColor];
55
+ const backgroundColor = SKU_COLORS[color as SkuColor] ?? color;
56
+
57
+ const isWhite =
58
+ !backgroundUrl &&
59
+ (!backgroundColor.startsWith('#') ||
60
+ backgroundColor.toLowerCase() === '#fff' ||
61
+ backgroundColor.toLowerCase() === '#ffffff');
55
62
 
56
63
  const styles: React.CSSProperties = {
57
- backgroundColor: backgroundColor ?? color,
64
+ backgroundColor,
58
65
  ...(backgroundUrl
59
66
  ? {
60
67
  backgroundImage: `url(${backgroundUrl})`,
@@ -68,7 +75,7 @@ export const ColorSwatch: React.FC<ColorSwatchProps> = ({
68
75
  className={classNames(
69
76
  `ColorSwatch`,
70
77
  {
71
- 'ColorSwatch--light': !backgroundColor || backgroundColor === '#fff',
78
+ 'ColorSwatch--light': isWhite,
72
79
  'ColorSwatch--small': size === 'small',
73
80
  'ColorSwatch--hover': hover,
74
81
  'ColorSwatch--focus': focus,
@@ -81,6 +88,7 @@ export const ColorSwatch: React.FC<ColorSwatchProps> = ({
81
88
  onClick={handleClick}
82
89
  onMouseEnter={handleMouseEnter}
83
90
  disabled={disabled}
91
+ title={title}
84
92
  {...rest}
85
93
  >
86
94
  <div className="ColorSwatch__chip" style={styles} />
@@ -13,6 +13,7 @@ export const SKU_COLORS = {
13
13
  'rose gold': '#b76e79',
14
14
  'royal blue': '#0049ff',
15
15
  animal: undefined,
16
+ berry: '#8f1e47',
16
17
  black: '#000',
17
18
  blue: '#3755a4',
18
19
  bronze: '#cd7f2e',
@@ -43,7 +44,9 @@ export const SKU_COLORS = {
43
44
  silver: '#c0c0c0',
44
45
  stripe: undefined,
45
46
  tan: '#baa094',
47
+ taupe: '#483c32',
46
48
  turquoise: '#1e83a8',
49
+ universal: undefined,
47
50
  white: '#fff',
48
51
  yellow: '#ffca44'
49
52
  };