@linagora/twake-icons 2.4.1 → 2.6.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 +14 -0
- package/dist/Icon/index.d.ts +7 -4
- package/dist/Icon/index.js +37 -30
- package/dist/Icon/styles.d.ts +1 -2
- package/dist/Icon/styles.js +0 -5
- package/dist/utils/getFileTypeIcon.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# @linagora/twake-icons [2.6.0](https://github.com/linagora/twake-ui/compare/@linagora/twake-icons@2.5.0...@linagora/twake-icons@2.6.0) (2026-06-22)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **twake-icons:** Change TS config to target ES2019 ([3ddd5c5](https://github.com/linagora/twake-ui/commit/3ddd5c56e0cb3fadd7fd8b5ef17b9034fbbce828))
|
|
7
|
+
|
|
8
|
+
# @linagora/twake-icons [2.5.0](https://github.com/linagora/twake-ui/compare/@linagora/twake-icons@2.4.1...@linagora/twake-icons@2.5.0) (2026-06-22)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* **twake-icons:** Use exact code from cozy-ui ([cf5ae51](https://github.com/linagora/twake-ui/commit/cf5ae517a3e37006c62a10c28116ceb3ea92a670))
|
|
14
|
+
|
|
1
15
|
## @linagora/twake-icons [2.4.1](https://github.com/linagora/twake-ui/compare/@linagora/twake-icons@2.4.0...@linagora/twake-icons@2.4.1) (2026-06-18)
|
|
2
16
|
|
|
3
17
|
|
package/dist/Icon/index.d.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
export interface IconProps extends SVGAttributes<
|
|
3
|
-
icon: string | ComponentType<SVGAttributes<
|
|
1
|
+
import { type ComponentType, type ReactElement, type SVGAttributes } from 'react';
|
|
2
|
+
export interface IconProps extends SVGAttributes<SVGSVGElement> {
|
|
3
|
+
icon: string | ComponentType<SVGAttributes<SVGSVGElement>> | ReactElement;
|
|
4
|
+
width?: number | string;
|
|
5
|
+
height?: number | string;
|
|
4
6
|
size?: number | string;
|
|
5
7
|
color?: string;
|
|
8
|
+
preserveColor?: boolean;
|
|
6
9
|
rotate?: number;
|
|
7
10
|
spin?: boolean;
|
|
8
11
|
}
|
|
9
|
-
declare function Icon(
|
|
12
|
+
declare function Icon(props: IconProps): ReactElement | null;
|
|
10
13
|
export default Icon;
|
package/dist/Icon/index.js
CHANGED
|
@@ -1,39 +1,46 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { iconSpinStyle } from './styles';
|
|
3
|
+
const DEFAULT_SIZE = '16';
|
|
4
|
+
const iconStyle = {
|
|
5
|
+
fill: 'currentColor',
|
|
6
|
+
transform: 'translateZ(0)'
|
|
7
|
+
};
|
|
8
|
+
function makeSvgObject(icon) {
|
|
9
|
+
const anchor = icon.startsWith('#') ? icon : `#${icon}`;
|
|
10
|
+
function SvgObject(props) {
|
|
11
|
+
return (React.createElement("svg", { ...props },
|
|
12
|
+
React.createElement("use", { href: anchor })));
|
|
13
|
+
}
|
|
14
|
+
SvgObject.displayName = 'SvgObject';
|
|
15
|
+
return SvgObject;
|
|
16
|
+
}
|
|
17
|
+
function isFunction(value) {
|
|
4
18
|
return typeof value === 'function';
|
|
5
19
|
}
|
|
6
|
-
function Icon(
|
|
20
|
+
function Icon(props) {
|
|
21
|
+
const { icon, width, height, color, style, className, preserveColor, rotate, size, spin, ...restProps } = props;
|
|
7
22
|
if (!icon)
|
|
8
23
|
return null;
|
|
9
|
-
if (React.isValidElement(icon))
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
selfStyle.fill = color;
|
|
15
|
-
}
|
|
16
|
-
if (rotate) {
|
|
17
|
-
selfStyle.transform = `rotate(${rotate}deg)`;
|
|
18
|
-
}
|
|
19
|
-
if (spin) {
|
|
20
|
-
selfStyle.animation = iconSpinStyle.animation;
|
|
24
|
+
if (React.isValidElement(icon)) {
|
|
25
|
+
const isIconComp = icon.type === Icon;
|
|
26
|
+
const isImg = icon.type === 'img';
|
|
27
|
+
if (isIconComp || isImg)
|
|
28
|
+
return icon;
|
|
21
29
|
}
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
width:
|
|
25
|
-
|
|
30
|
+
const isPngPath = typeof icon === 'string' && icon.includes('.png');
|
|
31
|
+
if (isPngPath)
|
|
32
|
+
return (React.createElement("img", { src: icon, className: className, style: style, width: width || size || DEFAULT_SIZE, height: height || size || DEFAULT_SIZE, ...restProps }));
|
|
33
|
+
const Svg = isFunction(icon) ? icon : makeSvgObject(icon);
|
|
34
|
+
const _style = {
|
|
35
|
+
...iconStyle,
|
|
36
|
+
...style,
|
|
37
|
+
...(color ? { fill: color } : {}),
|
|
38
|
+
...(preserveColor ? { fill: 'inherit' } : {}),
|
|
39
|
+
...(rotate ? { transform: `rotate(${rotate}deg)` } : {}),
|
|
40
|
+
...(spin ? iconSpinStyle : {})
|
|
26
41
|
};
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
if (typeof icon !== 'string')
|
|
32
|
-
return null;
|
|
33
|
-
if (typeof icon !== 'string')
|
|
34
|
-
return null;
|
|
35
|
-
const anchor = icon.includes('#') ? icon : `#${icon}`;
|
|
36
|
-
return (React.createElement("svg", { className: className, style: styleWithSize, width: resolvedSizeNum, height: resolvedSizeNum, ...restProps },
|
|
37
|
-
React.createElement("use", { href: anchor })));
|
|
42
|
+
return Svg ? (
|
|
43
|
+
// eslint-disable-next-line react-hooks/static-components
|
|
44
|
+
React.createElement(Svg, { className: className, style: _style, width: width || size || DEFAULT_SIZE, height: height || size || DEFAULT_SIZE, ...restProps })) : null;
|
|
38
45
|
}
|
|
39
46
|
export default Icon;
|
package/dist/Icon/styles.d.ts
CHANGED
package/dist/Icon/styles.js
CHANGED
|
@@ -9,11 +9,6 @@ if (typeof document !== 'undefined') {
|
|
|
9
9
|
`;
|
|
10
10
|
document.head.appendChild(style);
|
|
11
11
|
}
|
|
12
|
-
export const iconBaseStyle = {
|
|
13
|
-
fill: 'currentColor',
|
|
14
|
-
// Fix blurry icons on Firefox
|
|
15
|
-
transform: 'translateZ(0)'
|
|
16
|
-
};
|
|
17
12
|
export const iconSpinStyle = {
|
|
18
13
|
animation: 'twake-icon-spin 1s linear infinite'
|
|
19
14
|
};
|
|
@@ -8,7 +8,7 @@ import { mimeToIcon, defaultIcon } from './fileTypeIcons';
|
|
|
8
8
|
* @returns React node representing the file type icon
|
|
9
9
|
*/
|
|
10
10
|
export function getFileTypeIcon(filename, mimeType) {
|
|
11
|
-
const resolvedMimeType = mimeType
|
|
11
|
+
const resolvedMimeType = (mimeType === null || mimeType === void 0 ? void 0 : mimeType.split(';')[0].trim().toLowerCase()) || mime.getType(filename);
|
|
12
12
|
if (resolvedMimeType && mimeToIcon[resolvedMimeType]) {
|
|
13
13
|
return mimeToIcon[resolvedMimeType];
|
|
14
14
|
}
|