cozy-ui 140.3.0 → 140.4.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/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # [140.4.0](https://github.com/cozy/cozy-ui/compare/v140.3.0...v140.4.0) (2026-07-16)
2
+
3
+
4
+ ### Features
5
+
6
+ * **Avatar:** Add colorToGradient func ([1b1c442](https://github.com/cozy/cozy-ui/commit/1b1c442))
7
+
1
8
  # [140.3.0](https://github.com/cozy/cozy-ui/compare/v140.2.0...v140.3.0) (2026-07-16)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-ui",
3
- "version": "140.3.0",
3
+ "version": "140.4.0",
4
4
  "description": "Cozy apps UI SDK",
5
5
  "engines": {
6
6
  "node": "24.x"
@@ -1,3 +1,5 @@
1
+ import { darken, lighten, rgbToHex } from '@material-ui/core/styles'
2
+
1
3
  export const sizeToFontSize = {
2
4
  xs: 8,
3
5
  s: 11,
@@ -58,3 +60,18 @@ export const nameToColor = (name = '') => {
58
60
  const key = makeKey(colors, name)
59
61
  return colors[key]
60
62
  }
63
+
64
+ /**
65
+ * Transorms a color to a css gradient to be used as background color
66
+ * @param {string} color - Color to be transformed
67
+ * @returns {string} css linear-gradient
68
+ */
69
+ export const colorToGradient = color => {
70
+ if (!/^#[0-9A-Fa-f]{6}$/.test(color)) {
71
+ throw new Error('Color must be an 6-HEX color')
72
+ }
73
+
74
+ return `linear-gradient(136deg, ${rgbToHex(
75
+ lighten(color, 0.17)
76
+ )} 14.84%, ${rgbToHex(darken(color, 0.15))} 96.03%)`
77
+ }
@@ -3,7 +3,12 @@ import cx from 'classnames'
3
3
  import PropTypes from 'prop-types'
4
4
  import React from 'react'
5
5
 
6
- import { colorMapping, supportedColors, nameToColor } from './helpers'
6
+ import {
7
+ colorMapping,
8
+ supportedColors,
9
+ nameToColor,
10
+ colorToGradient
11
+ } from './helpers'
7
12
  import { makeStyles } from '../styles'
8
13
  import { capitalize } from '../utils/index'
9
14
 
@@ -77,4 +82,6 @@ Avatar.defaultProps = {
77
82
  size: 'm'
78
83
  }
79
84
 
85
+ export { colorToGradient }
86
+
80
87
  export default Avatar
@@ -32,3 +32,4 @@ export namespace colorMapping {
32
32
  const moonBlue: string;
33
33
  }
34
34
  export function nameToColor(name?: string): string;
35
+ export function colorToGradient(color: string): string;
@@ -1,3 +1,4 @@
1
+ import { darken, lighten, rgbToHex } from '@material-ui/core/styles';
1
2
  export var sizeToFontSize = {
2
3
  xs: 8,
3
4
  s: 11,
@@ -46,4 +47,17 @@ export var nameToColor = function nameToColor() {
46
47
  var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
47
48
  var key = makeKey(colors, name);
48
49
  return colors[key];
50
+ };
51
+ /**
52
+ * Transorms a color to a css gradient to be used as background color
53
+ * @param {string} color - Color to be transformed
54
+ * @returns {string} css linear-gradient
55
+ */
56
+
57
+ export var colorToGradient = function colorToGradient(color) {
58
+ if (!/^#[0-9A-Fa-f]{6}$/.test(color)) {
59
+ throw new Error('Color must be an 6-HEX color');
60
+ }
61
+
62
+ return "linear-gradient(136deg, ".concat(rgbToHex(lighten(color, 0.17)), " 14.84%, ").concat(rgbToHex(darken(color, 0.15)), " 96.03%)");
49
63
  };
@@ -1,4 +1,6 @@
1
+ export { colorToGradient };
1
2
  export default Avatar;
3
+ import { colorToGradient } from "./helpers";
2
4
  declare function Avatar({ className, color, size, border, innerBorder, disabled, display, textColor, ...props }: {
3
5
  [x: string]: any;
4
6
  className: any;
@@ -7,7 +7,7 @@ import AvatarMui from '@material-ui/core/Avatar';
7
7
  import cx from 'classnames';
8
8
  import PropTypes from 'prop-types';
9
9
  import React from 'react';
10
- import { colorMapping, supportedColors, nameToColor } from "cozy-ui/transpiled/react/Avatar/helpers";
10
+ import { colorMapping, supportedColors, nameToColor, colorToGradient } from "cozy-ui/transpiled/react/Avatar/helpers";
11
11
  import { makeStyles } from "cozy-ui/transpiled/react/styles";
12
12
  import { capitalize } from "cozy-ui/transpiled/react/utils/index";
13
13
  var useStyles = makeStyles(function (theme) {
@@ -80,4 +80,5 @@ Avatar.defaultProps = {
80
80
  display: 'initial',
81
81
  size: 'm'
82
82
  };
83
+ export { colorToGradient };
83
84
  export default Avatar;