thread-ui 0.7.8 → 0.7.9
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/dist/components/media/info-card/info-card.d.ts +7 -7
- package/dist/components/media/info-card/info-card.js +9 -22
- package/dist/components/media/info-card/info-card.js.map +1 -1
- package/dist/components/media/info-card/info-card.types.d.ts +2 -5
- package/dist/internal-components/dynamic-icon/dynamic-icon.d.ts +2 -0
- package/dist/internal-components/dynamic-icon/dynamic-icon.js +28 -0
- package/dist/internal-components/dynamic-icon/dynamic-icon.js.map +1 -0
- package/dist/internal-components/dynamic-icon/dynamic-icon.types.d.ts +6 -0
- package/dist/internal-components/dynamic-icon/dynamic-icon.types.js +2 -0
- package/dist/internal-components/dynamic-icon/dynamic-icon.types.js.map +1 -0
- package/dist/internal-components/dynamic-icon/index.d.ts +2 -0
- package/dist/internal-components/dynamic-icon/index.js +2 -0
- package/dist/internal-components/dynamic-icon/index.js.map +1 -0
- package/dist/internal-components/index.d.ts +1 -0
- package/dist/internal-components/index.js +1 -0
- package/dist/internal-components/index.js.map +1 -1
- package/dist/types/utility/index.d.ts +1 -0
- package/dist/types/utility/notion-icon.types.d.ts +15 -0
- package/dist/types/utility/notion-icon.types.js +2 -0
- package/dist/types/utility/notion-icon.types.js.map +1 -0
- package/package.json +1 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { InfoCardProps } from './info-card.types';
|
|
2
2
|
/**
|
|
3
|
-
* Linked card displaying a cover image, title, and icon. Supports named icons, emojis, and SVGs.
|
|
3
|
+
* Linked card displaying a cover image, title, and icon. Supports named icons, emojis, and external SVGs.
|
|
4
4
|
*
|
|
5
5
|
* @example
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* />
|
|
6
|
+
* // Named icon
|
|
7
|
+
* <InfoCard title="Getting Started" url="/docs" icon="BookOpen" img="/cover.jpg" />
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* // Emoji
|
|
11
|
+
* <InfoCard title="Recipes" url="/recipes" icon={{ type: 'emoji', emoji: '🍋' }} img="/cover.jpg" />
|
|
12
12
|
*/
|
|
13
13
|
export declare const InfoCard: ({ title, url, icon, img }: InfoCardProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { Icon } from '../../../components/ui';
|
|
4
3
|
import { css, cx } from '../../../styled-system/css';
|
|
5
4
|
import { Text } from '../../../components/typography';
|
|
5
|
+
import { DynamicIcon } from '../../../internal-components';
|
|
6
6
|
const styles = {
|
|
7
7
|
card: css({
|
|
8
8
|
margin: 'auto',
|
|
@@ -48,30 +48,17 @@ const styles = {
|
|
|
48
48
|
}),
|
|
49
49
|
};
|
|
50
50
|
/**
|
|
51
|
-
* Linked card displaying a cover image, title, and icon. Supports named icons, emojis, and SVGs.
|
|
51
|
+
* Linked card displaying a cover image, title, and icon. Supports named icons, emojis, and external SVGs.
|
|
52
52
|
*
|
|
53
53
|
* @example
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
* />
|
|
54
|
+
* // Named icon
|
|
55
|
+
* <InfoCard title="Getting Started" url="/docs" icon="BookOpen" img="/cover.jpg" />
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* // Emoji
|
|
59
|
+
* <InfoCard title="Recipes" url="/recipes" icon={{ type: 'emoji', emoji: '🍋' }} img="/cover.jpg" />
|
|
60
60
|
*/
|
|
61
61
|
export const InfoCard = ({ title, url, icon, img }) => {
|
|
62
|
-
|
|
63
|
-
if (!icon) {
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
if (typeof icon === 'string') {
|
|
67
|
-
return _jsx(Icon, { name: icon, size: 24 });
|
|
68
|
-
}
|
|
69
|
-
else if (icon.type === 'svg' && icon.content) {
|
|
70
|
-
return (_jsx("img", { height: 24, width: 24, src: icon.content, onError: (e) => {
|
|
71
|
-
e.currentTarget.style.display = 'none';
|
|
72
|
-
} }));
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
return (_jsxs("a", { href: url, className: cx(styles.cardContent, styles.link, styles.card), children: [_jsx("div", { className: styles.imageWrapper, children: _jsx("img", { className: styles.image, src: img, alt: "Article Cover Image" }) }), _jsxs("div", { className: styles.caption, children: [renderIcon(), _jsx(Text, { size: "sm", truncate: true, inline: true, children: title })] })] }));
|
|
62
|
+
return (_jsxs("a", { href: url, className: cx(styles.cardContent, styles.link, styles.card), children: [_jsx("div", { className: styles.imageWrapper, children: _jsx("img", { className: styles.image, src: img, alt: "Article Cover Image" }) }), _jsxs("div", { className: styles.caption, children: [_jsx(DynamicIcon, { icon: icon, size: 24 }), _jsx(Text, { size: "sm", truncate: true, inline: true, children: title })] })] }));
|
|
76
63
|
};
|
|
77
64
|
//# sourceMappingURL=info-card.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"info-card.js","sourceRoot":"","sources":["../../../../src/components/media/info-card/info-card.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;
|
|
1
|
+
{"version":3,"file":"info-card.js","sourceRoot":"","sources":["../../../../src/components/media/info-card/info-card.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAGb,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpD,MAAM,MAAM,GAAG;IACd,IAAI,EAAE,GAAG,CAAC;QACT,MAAM,EAAE,MAAM;QACd,MAAM,EAAE,OAAO;QACf,YAAY,EAAE,IAAI;QAClB,WAAW,EAAE,IAAI;QACjB,WAAW,EAAE,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KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAC,qBAAqB,GAAG,GAC/D,EACN,eAAK,SAAS,EAAE,MAAM,CAAC,OAAO,aAC7B,KAAC,WAAW,IAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,GAAI,EACrC,KAAC,IAAI,IAAC,IAAI,EAAC,IAAI,EAAC,QAAQ,QAAC,MAAM,kBAC7B,KAAK,GACA,IACF,IACH,CACJ,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DynamicIconProps } from '../../../internal-components';
|
|
2
2
|
export type InfoCardProps = {
|
|
3
3
|
/** Card title displayed in the caption bar */
|
|
4
4
|
title: string;
|
|
@@ -11,10 +11,7 @@ export type InfoCardProps = {
|
|
|
11
11
|
* icon={{ type: 'emoji', content: '1F4C4' }}
|
|
12
12
|
* icon={{ type: 'svg', content: '/icons/article.svg' }}
|
|
13
13
|
*/
|
|
14
|
-
icon?:
|
|
15
|
-
type: 'emoji' | 'svg';
|
|
16
|
-
content: string;
|
|
17
|
-
};
|
|
14
|
+
icon?: DynamicIconProps['icon'];
|
|
18
15
|
/** Cover image URL displayed in the card */
|
|
19
16
|
img: string;
|
|
20
17
|
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Icon } from '../../components';
|
|
4
|
+
const emoji = (code) => {
|
|
5
|
+
if (code.codePointAt(0) > 255)
|
|
6
|
+
return code;
|
|
7
|
+
return String.fromCodePoint(parseInt(code.replace('U+', ''), 16));
|
|
8
|
+
};
|
|
9
|
+
export const DynamicIcon = ({ icon, size = 24 }) => {
|
|
10
|
+
if (!icon)
|
|
11
|
+
return;
|
|
12
|
+
if (typeof icon === 'string') {
|
|
13
|
+
return _jsx(Icon, { name: icon, size: size });
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
if (icon.type === 'emoji') {
|
|
17
|
+
return (_jsx("span", { role: "image", style: { height: size, width: size }, children: emoji(icon.emoji) }));
|
|
18
|
+
}
|
|
19
|
+
if (icon.type === 'external') {
|
|
20
|
+
return (_jsx("img", { height: size, width: size, src: icon.external.url, onError: (e) => {
|
|
21
|
+
e.currentTarget.style.display = 'none';
|
|
22
|
+
} }));
|
|
23
|
+
}
|
|
24
|
+
if (icon.type === 'icon')
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=dynamic-icon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dynamic-icon.js","sourceRoot":"","sources":["../../../src/internal-components/dynamic-icon/dynamic-icon.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AACb,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAGpC,MAAM,KAAK,GAAG,CAAC,IAAY,EAAE,EAAE;IAC9B,IAAI,IAAI,CAAC,WAAW,CAAC,CAAC,CAAE,GAAG,GAAG;QAAE,OAAO,IAAI,CAAC;IAC5C,OAAO,MAAM,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;AACnE,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,EAAE,IAAI,EAAE,IAAI,GAAG,EAAE,EAAoB,EAAE,EAAE;IACpE,IAAI,CAAC,IAAI;QAAE,OAAO;IAElB,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,KAAC,IAAI,IAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,GAAI,CAAC;IACzC,CAAC;SAAM,CAAC;QACP,IAAI,IAAI,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;YAC3B,OAAO,CACN,eAAM,IAAI,EAAC,OAAO,EAAC,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,YACrD,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,GACZ,CACP,CAAC;QACH,CAAC;QACD,IAAI,IAAI,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;YAC9B,OAAO,CACN,cACC,MAAM,EAAE,IAAI,EACZ,KAAK,EAAE,IAAI,EACX,GAAG,EAAE,IAAI,CAAC,QAAQ,CAAC,GAAG,EACtB,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE;oBACd,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC;gBACxC,CAAC,GACA,CACF,CAAC;QACH,CAAC;QACD,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM;YAAE,OAAO;IAClC,CAAC;AACF,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dynamic-icon.types.js","sourceRoot":"","sources":["../../../src/internal-components/dynamic-icon/dynamic-icon.types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/internal-components/dynamic-icon/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/internal-components/index.ts"],"names":[],"mappings":"AAAA,6BAA6B;AAC7B,cAAc,uBAAuB,CAAC;AACtC,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,wBAAwB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/internal-components/index.ts"],"names":[],"mappings":"AAAA,6BAA6B;AAC7B,cAAc,uBAAuB,CAAC;AACtC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,wBAAwB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notion-icon.types.js","sourceRoot":"","sources":["../../../src/types/utility/notion-icon.types.ts"],"names":[],"mappings":""}
|