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.
@@ -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
- * <InfoCard
7
- * title="Getting Started"
8
- * url="/docs/getting-started"
9
- * icon="BookOpen"
10
- * img="/images/cover.jpg"
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
- * <InfoCard
55
- * title="Getting Started"
56
- * url="/docs/getting-started"
57
- * icon="BookOpen"
58
- * img="/images/cover.jpg"
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
- const renderIcon = () => {
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;;AACb,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAEvC,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAE/C,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,WAAW;Q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ACvC,CAAC;aAAM,IAAI,IAAI,CAAC,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YAChD,OAAO,CACN,cACC,MAAM,EAAE,EAAE,EACV,KAAK,EAAE,EAAE,EACT,GAAG,EAAE,IAAI,CAAC,OAAO,EACjB,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE;oBACd,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC;gBACxC,CAAC,GACA,CACF,CAAC;QACH,CAAC;IACF,CAAC,CAAC;IAEF,OAAO,CACN,aAAG,IAAI,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE,CAAC,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,aACxE,cAAK,SAAS,EAAE,MAAM,CAAC,YAAY,YAClC,cAAK,SAAS,EAAE,MAAM,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAC,qBAAqB,GAAG,GAC/D,EACN,eAAK,SAAS,EAAE,MAAM,CAAC,OAAO,aAC5B,UAAU,EAAE,EACb,KAAC,IAAI,IAAC,IAAI,EAAC,IAAI,EAAC,QAAQ,QAAC,MAAM,kBAC7B,KAAK,GACA,IACF,IACH,CACJ,CAAC;AACH,CAAC,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,EA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AK,SAAS,EAAE,MAAM,CAAC,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 { IconNames } from '../../../components/ui';
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?: IconNames | {
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,2 @@
1
+ import { DynamicIconProps } from './dynamic-icon.types';
2
+ export declare const DynamicIcon: ({ icon, size }: DynamicIconProps) => import("react/jsx-runtime").JSX.Element | undefined;
@@ -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,6 @@
1
+ import { IconNames, IconSizes } from '../../components';
2
+ import { NotionIcon } from '../../types';
3
+ export type DynamicIconProps = {
4
+ icon?: IconNames | NotionIcon;
5
+ size?: IconSizes;
6
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=dynamic-icon.types.js.map
@@ -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,2 @@
1
+ export type { DynamicIconProps } from './dynamic-icon.types';
2
+ export { DynamicIcon } from './dynamic-icon';
@@ -0,0 +1,2 @@
1
+ export { DynamicIcon } from './dynamic-icon';
2
+ //# sourceMappingURL=index.js.map
@@ -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,4 +1,5 @@
1
1
  export * from './conditional-wrapper';
2
+ export * from './dynamic-icon';
2
3
  export * from './image';
3
4
  export * from './link-wrapper';
4
5
  export * from './optional-icon-button';
@@ -1,5 +1,6 @@
1
1
  // Export Internal Components
2
2
  export * from './conditional-wrapper';
3
+ export * from './dynamic-icon';
3
4
  export * from './image';
4
5
  export * from './link-wrapper';
5
6
  export * from './optional-icon-button';
@@ -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"}
@@ -1,2 +1,3 @@
1
1
  export type { DeepPartial } from './deep-partial.types';
2
2
  export type { Override, Prettify } from './type-production.types';
3
+ export type { NotionIcon } from './notion-icon.types';
@@ -0,0 +1,15 @@
1
+ export type NotionIcon = {
2
+ type: 'emoji';
3
+ emoji: string;
4
+ } | {
5
+ type: 'external';
6
+ external: {
7
+ url: string;
8
+ };
9
+ } | {
10
+ type: 'icon';
11
+ icon: {
12
+ name: string;
13
+ color: string;
14
+ };
15
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=notion-icon.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notion-icon.types.js","sourceRoot":"","sources":["../../../src/types/utility/notion-icon.types.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "thread-ui",
3
- "version": "0.7.8",
3
+ "version": "0.7.9",
4
4
  "author": "Andrew Fisher",
5
5
  "description": "UI Library for React Applications.",
6
6
  "license": "MIT",