cozy-ui 140.2.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,18 @@
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
+
8
+ # [140.3.0](https://github.com/cozy/cozy-ui/compare/v140.2.0...v140.3.0) (2026-07-16)
9
+
10
+
11
+ ### Features
12
+
13
+ * Add ColorList component ([ade8132](https://github.com/cozy/cozy-ui/commit/ade8132))
14
+ * Reexport ImageList, ImageListItem and ImageListItemBar ([7480e4b](https://github.com/cozy/cozy-ui/commit/7480e4b))
15
+
1
16
  # [140.2.0](https://github.com/cozy/cozy-ui/compare/v140.1.2...v140.2.0) (2026-07-09)
2
17
 
3
18
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-ui",
3
- "version": "140.2.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
@@ -0,0 +1,37 @@
1
+ ```jsx
2
+ import { useState } from 'react'
3
+ import ColorList from 'cozy-ui/transpiled/react/ColorList'
4
+ import DemoProvider from 'cozy-ui/docs/components/DemoProvider'
5
+ import { useBreakpoints } from 'cozy-ui/transpiled/react/providers/Breakpoints'
6
+ import Variants from 'cozy-ui/docs/components/Variants'
7
+
8
+ const initialVariants = [{ medium: false }]
9
+
10
+ const ColorPickerDemo = ({ variant }) => {
11
+ const { isMobile } = useBreakpoints()
12
+ const [selectedColor, setSelectedColor] = useState('')
13
+
14
+ return (
15
+ <div style={{ width: (variant.medium || isMobile) ? '100%' : 180 }}>
16
+ <ColorList
17
+ size={variant.medium ? 'medium' : undefined}
18
+ selectedColor={selectedColor}
19
+ onClick={color => {
20
+ console.info('color :', color)
21
+ setSelectedColor(color)
22
+ }}
23
+ />
24
+ </div>
25
+ )
26
+ }
27
+
28
+ ;
29
+
30
+ <DemoProvider>
31
+ <Variants initialVariants={initialVariants} screenshotAllVariants>
32
+ {variant => (
33
+ <ColorPickerDemo variant={variant}/>
34
+ )}
35
+ </Variants>
36
+ </DemoProvider>
37
+ ```
@@ -0,0 +1,22 @@
1
+ export const COLORS = [
2
+ '#273891',
3
+ '#7E57E3',
4
+ '#9E83E8',
5
+ '#91CEF6',
6
+ '#2D83FF', // file-folder color, don't remove it
7
+ '#006BD8',
8
+ '#038199',
9
+ '#51B588',
10
+ '#457D6C',
11
+ '#1EBBCC',
12
+ '#E0465C',
13
+ '#ED20A4',
14
+ '#ED768D',
15
+ '#B85B17',
16
+ '#EDA91D',
17
+ '#BA8144',
18
+ '#ED916B',
19
+ '#EDC661',
20
+ '#131326',
21
+ '#646580'
22
+ ]
@@ -0,0 +1,60 @@
1
+ import { Icon, Check } from '@linagora/twake-icons'
2
+ import propTypes from 'prop-types'
3
+ import React from 'react'
4
+
5
+ import { COLORS } from './helpers'
6
+ import Avatar from '../Avatar'
7
+ import ButtonBase from '../ButtonBase'
8
+ import ImageList from '../ImageList'
9
+ import ImageListItem from '../ImageListItem'
10
+ import { useBreakpoints } from '../providers/Breakpoints'
11
+
12
+ const sizeToPx = {
13
+ small: 21,
14
+ medium: 41
15
+ }
16
+
17
+ const ColorList = ({ size, selectedColor, onClick }) => {
18
+ const { isMobile } = useBreakpoints()
19
+ const _size = size || (isMobile ? 'medium' : 'small')
20
+
21
+ return (
22
+ <ImageList
23
+ cols={_size === 'medium' ? 5 : 7}
24
+ rowHeight={sizeToPx[_size]}
25
+ gap={_size === 'medium' ? 16 : 5}
26
+ >
27
+ {COLORS.map(color => (
28
+ <ImageListItem
29
+ key={color}
30
+ className="u-ta-center"
31
+ classes={{ item: 'u-ov-visible' }}
32
+ >
33
+ <ButtonBase
34
+ className="u-bdrs-circle"
35
+ component="div"
36
+ onClick={() => onClick?.(color)}
37
+ >
38
+ <Avatar color={color} size={sizeToPx[_size]}>
39
+ {selectedColor?.toUpperCase() === color ? (
40
+ <Icon icon={Check} size={_size === 'medium' ? 19 : 10} />
41
+ ) : (
42
+ ' '
43
+ )}
44
+ </Avatar>
45
+ </ButtonBase>
46
+ </ImageListItem>
47
+ ))}
48
+ </ImageList>
49
+ )
50
+ }
51
+
52
+ ColorList.propTypes = {
53
+ size: propTypes.oneOf(['small', 'medium']),
54
+ selectedColor: propTypes.string,
55
+ onClick: propTypes.func
56
+ }
57
+
58
+ export { COLORS }
59
+
60
+ export default ColorList
@@ -0,0 +1,3 @@
1
+ import MuiImageList from '@material-ui/core/ImageList'
2
+
3
+ export default MuiImageList
@@ -0,0 +1,3 @@
1
+ import MuiImageListItem from '@material-ui/core/ImageListItem'
2
+
3
+ export default MuiImageListItem
@@ -0,0 +1,3 @@
1
+ import MuiImageListItemBar from '@material-ui/core/ImageListItemBar'
2
+
3
+ export default MuiImageListItemBar
package/react/index.js CHANGED
@@ -13,6 +13,7 @@ export {
13
13
  } from './Nav'
14
14
  export { default as ListItemText } from './ListItemText'
15
15
  export { default as Spinner } from './Spinner'
16
+ export { default as ColorList } from './ColorList'
16
17
  export { default as Accordion } from './Accordion'
17
18
  export { default as AccordionSummary } from './AccordionSummary'
18
19
  export { default as AccordionDetails } from './AccordionDetails'
@@ -25,7 +25,7 @@ import 'cozy-ui/transpiled/react/stylesheet.css'
25
25
 
26
26
  ## What This Skill Provides
27
27
 
28
- * 90+ React components with examples and extracted props.
28
+ * 91+ React components with examples and extracted props.
29
29
  * CSS utility classes for spacing, typography, colors, layout, and component-specific classes.
30
30
  * Cozy theming conventions built on Material-UI v4.
31
31
  * Import patterns for `cozy-ui/transpiled/react` and `cozy-ui/dist`.
@@ -17,7 +17,7 @@ Generated reference for React components available in cozy-ui. Use this file to
17
17
  - **Utils**: [DropdownText](#dropdowntext), [MuiCozyTheme](#muicozytheme)
18
18
  - **Hooks & Providers**: [Breakpoints (providers/Breakpoints)](#breakpoints-providers-breakpoints), [ConfirmDialog (providers/ConfirmDialog)](#confirmdialog-providers-confirmdialog), [CozyTheme (providers/CozyTheme)](#cozytheme-providers-cozytheme), [Selection (providers/Selection)](#selection-providers-selection), [useConfirmExit (hooks/useConfirmExit)](#useconfirmexit-hooks-useconfirmexit)
19
19
  - **Labs**: [IconGrid (Labs/IconGrid)](#icongrid-labs-icongrid), [Labs](#labs), [PasswordInput (Labs/PasswordInput)](#passwordinput-labs-passwordinput)
20
- - **Other**: [Autocomplete](#autocomplete), [BottomSheet](#bottomsheet), [ColorPickerCustom](#colorpickercustom), [providers](#providers)
20
+ - **Other**: [Autocomplete](#autocomplete), [BottomSheet](#bottomsheet), [ColorList](#colorlist), [ColorPickerCustom](#colorpickercustom), [providers](#providers)
21
21
 
22
22
  ## Buttons
23
23
 
@@ -1824,6 +1824,13 @@ import BottomSheet from 'cozy-ui/transpiled/react/BottomSheet'
1824
1824
  ```
1825
1825
 
1826
1826
 
1827
+ ### ColorList
1828
+
1829
+ ```jsx
1830
+ import ColorList from 'cozy-ui/transpiled/react/ColorList'
1831
+ ```
1832
+
1833
+
1827
1834
  ### ColorPickerCustom
1828
1835
 
1829
1836
  With saturation, hue and hex input for manual input or copy/paste.
@@ -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;
@@ -0,0 +1 @@
1
+ export const COLORS: string[];
@@ -0,0 +1,2 @@
1
+ export var COLORS = ['#273891', '#7E57E3', '#9E83E8', '#91CEF6', '#2D83FF', // file-folder color, don't remove it
2
+ '#006BD8', '#038199', '#51B588', '#457D6C', '#1EBBCC', '#E0465C', '#ED20A4', '#ED768D', '#B85B17', '#EDA91D', '#BA8144', '#ED916B', '#EDC661', '#131326', '#646580'];
@@ -0,0 +1,16 @@
1
+ export { COLORS };
2
+ export default ColorList;
3
+ import { COLORS } from "./helpers";
4
+ declare function ColorList({ size, selectedColor, onClick }: {
5
+ size: any;
6
+ selectedColor: any;
7
+ onClick: any;
8
+ }): JSX.Element;
9
+ declare namespace ColorList {
10
+ namespace propTypes {
11
+ const size: propTypes.Requireable<string>;
12
+ const selectedColor: propTypes.Requireable<string>;
13
+ const onClick: propTypes.Requireable<(...args: any[]) => any>;
14
+ }
15
+ }
16
+ import propTypes_1 from "prop-types";
@@ -0,0 +1,58 @@
1
+ import { Icon, Check } from '@linagora/twake-icons';
2
+ import propTypes from 'prop-types';
3
+ import React from 'react';
4
+ import { COLORS } from "cozy-ui/transpiled/react/ColorList/helpers";
5
+ import Avatar from "cozy-ui/transpiled/react/Avatar";
6
+ import ButtonBase from "cozy-ui/transpiled/react/ButtonBase";
7
+ import ImageList from "cozy-ui/transpiled/react/ImageList";
8
+ import ImageListItem from "cozy-ui/transpiled/react/ImageListItem";
9
+ import { useBreakpoints } from "cozy-ui/transpiled/react/providers/Breakpoints";
10
+ var sizeToPx = {
11
+ small: 21,
12
+ medium: 41
13
+ };
14
+
15
+ var ColorList = function ColorList(_ref) {
16
+ var size = _ref.size,
17
+ selectedColor = _ref.selectedColor,
18
+ _onClick = _ref.onClick;
19
+
20
+ var _useBreakpoints = useBreakpoints(),
21
+ isMobile = _useBreakpoints.isMobile;
22
+
23
+ var _size = size || (isMobile ? 'medium' : 'small');
24
+
25
+ return /*#__PURE__*/React.createElement(ImageList, {
26
+ cols: _size === 'medium' ? 5 : 7,
27
+ rowHeight: sizeToPx[_size],
28
+ gap: _size === 'medium' ? 16 : 5
29
+ }, COLORS.map(function (color) {
30
+ return /*#__PURE__*/React.createElement(ImageListItem, {
31
+ key: color,
32
+ className: "u-ta-center",
33
+ classes: {
34
+ item: 'u-ov-visible'
35
+ }
36
+ }, /*#__PURE__*/React.createElement(ButtonBase, {
37
+ className: "u-bdrs-circle",
38
+ component: "div",
39
+ onClick: function onClick() {
40
+ return _onClick === null || _onClick === void 0 ? void 0 : _onClick(color);
41
+ }
42
+ }, /*#__PURE__*/React.createElement(Avatar, {
43
+ color: color,
44
+ size: sizeToPx[_size]
45
+ }, (selectedColor === null || selectedColor === void 0 ? void 0 : selectedColor.toUpperCase()) === color ? /*#__PURE__*/React.createElement(Icon, {
46
+ icon: Check,
47
+ size: _size === 'medium' ? 19 : 10
48
+ }) : ' ')));
49
+ }));
50
+ };
51
+
52
+ ColorList.propTypes = {
53
+ size: propTypes.oneOf(['small', 'medium']),
54
+ selectedColor: propTypes.string,
55
+ onClick: propTypes.func
56
+ };
57
+ export { COLORS };
58
+ export default ColorList;
@@ -0,0 +1,2 @@
1
+ export default MuiImageList;
2
+ import MuiImageList from "@material-ui/core/ImageList";
@@ -0,0 +1,2 @@
1
+ import MuiImageList from '@material-ui/core/ImageList';
2
+ export default MuiImageList;
@@ -0,0 +1,2 @@
1
+ export default MuiImageListItem;
2
+ import MuiImageListItem from "@material-ui/core/ImageListItem";
@@ -0,0 +1,2 @@
1
+ import MuiImageListItem from '@material-ui/core/ImageListItem';
2
+ export default MuiImageListItem;
@@ -0,0 +1,2 @@
1
+ export default MuiImageListItemBar;
2
+ import MuiImageListItemBar from "@material-ui/core/ImageListItemBar";
@@ -0,0 +1,2 @@
1
+ import MuiImageListItemBar from '@material-ui/core/ImageListItemBar';
2
+ export default MuiImageListItemBar;
@@ -2,6 +2,7 @@ export { default as Badge } from "./Badge";
2
2
  export { default as Sidebar } from "./Sidebar";
3
3
  export { default as ListItemText } from "./ListItemText";
4
4
  export { default as Spinner } from "./Spinner";
5
+ export { default as ColorList } from "./ColorList";
5
6
  export { default as Accordion } from "./Accordion";
6
7
  export { default as AccordionSummary } from "./AccordionSummary";
7
8
  export { default as AccordionDetails } from "./AccordionDetails";
@@ -5,6 +5,7 @@ export { default as Sidebar } from './Sidebar';
5
5
  export { default as Nav, NavItem, NavIcon, NavText, NavDesktopLimiter, NavLink, genNavLink } from './Nav';
6
6
  export { default as ListItemText } from './ListItemText';
7
7
  export { default as Spinner } from './Spinner';
8
+ export { default as ColorList } from './ColorList';
8
9
  export { default as Accordion } from './Accordion';
9
10
  export { default as AccordionSummary } from './AccordionSummary';
10
11
  export { default as AccordionDetails } from './AccordionDetails';