@dxos/plugin-preview 0.8.3-staging.0fa589b → 0.8.4-main.1068cf700f

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.
Files changed (115) hide show
  1. package/dist/lib/browser/chunk-XLN6KTHK.mjs +17 -0
  2. package/dist/lib/browser/chunk-XLN6KTHK.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +38 -43
  4. package/dist/lib/browser/index.mjs.map +4 -4
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/preview-popover-5YUZCO2D.mjs +82 -0
  7. package/dist/lib/browser/preview-popover-5YUZCO2D.mjs.map +7 -0
  8. package/dist/lib/browser/react-surface-W3FAIVY7.mjs +251 -0
  9. package/dist/lib/browser/react-surface-W3FAIVY7.mjs.map +7 -0
  10. package/dist/lib/node-esm/chunk-2G4FUGDA.mjs +19 -0
  11. package/dist/lib/node-esm/chunk-2G4FUGDA.mjs.map +7 -0
  12. package/dist/lib/node-esm/index.mjs +38 -43
  13. package/dist/lib/node-esm/index.mjs.map +4 -4
  14. package/dist/lib/node-esm/meta.json +1 -1
  15. package/dist/lib/node-esm/preview-popover-7QRYVL73.mjs +84 -0
  16. package/dist/lib/node-esm/preview-popover-7QRYVL73.mjs.map +7 -0
  17. package/dist/lib/node-esm/react-surface-IO5DHYZB.mjs +252 -0
  18. package/dist/lib/node-esm/react-surface-IO5DHYZB.mjs.map +7 -0
  19. package/dist/types/src/PreviewPlugin.d.ts +2 -1
  20. package/dist/types/src/PreviewPlugin.d.ts.map +1 -1
  21. package/dist/types/src/capabilities/index.d.ts +2 -2
  22. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  23. package/dist/types/src/capabilities/preview-popover/index.d.ts +3 -0
  24. package/dist/types/src/capabilities/preview-popover/index.d.ts.map +1 -0
  25. package/dist/types/src/capabilities/preview-popover/preview-popover.d.ts +5 -0
  26. package/dist/types/src/capabilities/preview-popover/preview-popover.d.ts.map +1 -0
  27. package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
  28. package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
  29. package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
  30. package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
  31. package/dist/types/src/cards/FormCard.d.ts +7 -0
  32. package/dist/types/src/cards/FormCard.d.ts.map +1 -0
  33. package/dist/types/src/cards/OrganizationCard.d.ts +5 -0
  34. package/dist/types/src/cards/OrganizationCard.d.ts.map +1 -0
  35. package/dist/types/src/cards/PersonCard.d.ts +5 -0
  36. package/dist/types/src/cards/PersonCard.d.ts.map +1 -0
  37. package/dist/types/src/cards/ProjectCard.d.ts +5 -0
  38. package/dist/types/src/cards/ProjectCard.d.ts.map +1 -0
  39. package/dist/types/src/cards/TaskCard.d.ts +5 -0
  40. package/dist/types/src/cards/TaskCard.d.ts.map +1 -0
  41. package/dist/types/src/cards/index.d.ts +6 -0
  42. package/dist/types/src/cards/index.d.ts.map +1 -0
  43. package/dist/types/src/index.d.ts +0 -1
  44. package/dist/types/src/index.d.ts.map +1 -1
  45. package/dist/types/src/meta.d.ts +2 -3
  46. package/dist/types/src/meta.d.ts.map +1 -1
  47. package/dist/types/src/stories/Card.stories.d.ts +32 -0
  48. package/dist/types/src/stories/Card.stories.d.ts.map +1 -0
  49. package/dist/types/src/stories/testing.d.ts +19 -0
  50. package/dist/types/src/stories/testing.d.ts.map +1 -0
  51. package/dist/types/src/translations.d.ts +12 -6
  52. package/dist/types/src/translations.d.ts.map +1 -1
  53. package/dist/types/tsconfig.tsbuildinfo +1 -1
  54. package/package.json +46 -30
  55. package/src/PreviewPlugin.tsx +15 -27
  56. package/src/capabilities/index.ts +2 -4
  57. package/src/capabilities/preview-popover/index.ts +7 -0
  58. package/src/capabilities/preview-popover/preview-popover.ts +90 -0
  59. package/src/capabilities/react-surface/index.ts +7 -0
  60. package/src/capabilities/react-surface/react-surface.tsx +97 -0
  61. package/src/cards/FormCard.tsx +56 -0
  62. package/src/cards/OrganizationCard.tsx +29 -0
  63. package/src/cards/PersonCard.tsx +47 -0
  64. package/src/cards/ProjectCard.tsx +22 -0
  65. package/src/cards/TaskCard.tsx +40 -0
  66. package/src/{components → cards}/index.ts +3 -1
  67. package/src/index.ts +0 -1
  68. package/src/meta.ts +8 -5
  69. package/src/stories/Card.stories.tsx +76 -0
  70. package/src/stories/testing.tsx +84 -0
  71. package/src/translations.ts +12 -4
  72. package/dist/lib/browser/chunk-LFAK2TMG.mjs +0 -14
  73. package/dist/lib/browser/chunk-LFAK2TMG.mjs.map +0 -7
  74. package/dist/lib/browser/preview-popover-NRFVC4QQ.mjs +0 -69
  75. package/dist/lib/browser/preview-popover-NRFVC4QQ.mjs.map +0 -7
  76. package/dist/lib/browser/react-surface-J2R6Q33B.mjs +0 -272
  77. package/dist/lib/browser/react-surface-J2R6Q33B.mjs.map +0 -7
  78. package/dist/lib/node/chunk-XGHMBEIV.cjs +0 -37
  79. package/dist/lib/node/chunk-XGHMBEIV.cjs.map +0 -7
  80. package/dist/lib/node/index.cjs +0 -85
  81. package/dist/lib/node/index.cjs.map +0 -7
  82. package/dist/lib/node/meta.json +0 -1
  83. package/dist/lib/node/preview-popover-HIXRYF6L.cjs +0 -88
  84. package/dist/lib/node/preview-popover-HIXRYF6L.cjs.map +0 -7
  85. package/dist/lib/node/react-surface-ZSNNAKBG.cjs +0 -290
  86. package/dist/lib/node/react-surface-ZSNNAKBG.cjs.map +0 -7
  87. package/dist/lib/node-esm/chunk-7BPXNL44.mjs +0 -16
  88. package/dist/lib/node-esm/chunk-7BPXNL44.mjs.map +0 -7
  89. package/dist/lib/node-esm/preview-popover-HBGSL64N.mjs +0 -71
  90. package/dist/lib/node-esm/preview-popover-HBGSL64N.mjs.map +0 -7
  91. package/dist/lib/node-esm/react-surface-UKEVHG5K.mjs +0 -273
  92. package/dist/lib/node-esm/react-surface-UKEVHG5K.mjs.map +0 -7
  93. package/dist/types/src/Preview.stories.d.ts +0 -127
  94. package/dist/types/src/Preview.stories.d.ts.map +0 -1
  95. package/dist/types/src/capabilities/preview-popover.d.ts +0 -4
  96. package/dist/types/src/capabilities/preview-popover.d.ts.map +0 -1
  97. package/dist/types/src/capabilities/react-surface.d.ts +0 -4
  98. package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
  99. package/dist/types/src/components/ContactCard.d.ts +0 -7
  100. package/dist/types/src/components/ContactCard.d.ts.map +0 -1
  101. package/dist/types/src/components/OrganizationCard.d.ts +0 -5
  102. package/dist/types/src/components/OrganizationCard.d.ts.map +0 -1
  103. package/dist/types/src/components/ProjectCard.d.ts +0 -5
  104. package/dist/types/src/components/ProjectCard.d.ts.map +0 -1
  105. package/dist/types/src/components/index.d.ts +0 -4
  106. package/dist/types/src/components/index.d.ts.map +0 -1
  107. package/dist/types/src/types.d.ts +0 -6
  108. package/dist/types/src/types.d.ts.map +0 -1
  109. package/src/Preview.stories.tsx +0 -147
  110. package/src/capabilities/preview-popover.ts +0 -74
  111. package/src/capabilities/react-surface.tsx +0 -130
  112. package/src/components/ContactCard.tsx +0 -70
  113. package/src/components/OrganizationCard.tsx +0 -41
  114. package/src/components/ProjectCard.tsx +0 -20
  115. package/src/types.ts +0 -11
@@ -1,147 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- import '@dxos-theme';
6
-
7
- import { type Meta } from '@storybook/react';
8
- import React, { type FC } from 'react';
9
-
10
- import { Obj, Ref } from '@dxos/echo';
11
- import { faker } from '@dxos/random';
12
- import { Icon, Popover } from '@dxos/react-ui';
13
- import { DataType } from '@dxos/schema';
14
- import { withTheme, withLayout } from '@dxos/storybook-utils';
15
-
16
- import { ContactCard, OrganizationCard, ProjectCard } from './components';
17
- import translations from './translations';
18
- import { type PreviewProps } from './types';
19
-
20
- faker.seed(1234);
21
-
22
- type StoryProps = {
23
- Component: FC<PreviewProps<any>>;
24
- icon: string;
25
- subject: any;
26
- };
27
-
28
- const meta: Meta<StoryProps> = {
29
- title: 'plugins/plugin-preview/Preview',
30
- render: ({ Component, icon, ...args }) => {
31
- return (
32
- <Popover.Root open>
33
- <Popover.Content>
34
- <Popover.Viewport>
35
- <Component {...args} role='popover' />
36
- </Popover.Viewport>
37
- <Popover.Arrow />
38
- </Popover.Content>
39
- <Popover.Trigger>
40
- <Icon icon={icon} size={5} />
41
- </Popover.Trigger>
42
- </Popover.Root>
43
- );
44
- },
45
- decorators: [withTheme, withLayout()],
46
- parameters: {
47
- layout: 'centered',
48
- translations,
49
- },
50
- };
51
-
52
- export default meta;
53
-
54
- const omitImage = ({ image, ...rest }: any) => rest;
55
-
56
- const data = (() => {
57
- const organization = Obj.make(DataType.Organization, {
58
- name: faker.company.name(),
59
- image:
60
- 'https://plus.unsplash.com/premium_photo-1672116452571-896980a801c8?q=80&w=2671&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
61
- website: faker.internet.url(),
62
- description: faker.lorem.paragraph(),
63
- });
64
-
65
- const contact = Obj.make(DataType.Person, {
66
- fullName: faker.person.fullName(),
67
- image:
68
- 'https://plus.unsplash.com/premium_photo-1664536392779-049ba8fde933?q=80&w=2574&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
69
- organization: Ref.make(organization),
70
- emails: [
71
- {
72
- label: 'Work',
73
- value: faker.internet.email(),
74
- },
75
- {
76
- label: 'Work',
77
- value: faker.internet.email(),
78
- },
79
- {
80
- label: 'Work',
81
- value: faker.internet.email(),
82
- },
83
- ],
84
- });
85
-
86
- const project = Obj.make(DataType.Project, {
87
- name: faker.person.fullName(),
88
- image: 'https://dxos.network/dxos-logotype-blue.png',
89
- description: faker.lorem.paragraph(),
90
- });
91
-
92
- return { organization, contact, project };
93
- })();
94
-
95
- export const ContactWithImage = {
96
- args: {
97
- Component: ContactCard,
98
- icon: 'ph--user--regular',
99
- subject: data.contact,
100
- role: 'popover',
101
- },
102
- };
103
-
104
- export const ContactNoImage = {
105
- args: {
106
- Component: ContactCard,
107
- icon: 'ph--user--regular',
108
- subject: omitImage(data.contact),
109
- role: 'popover',
110
- },
111
- };
112
-
113
- export const OrganizationWithImage = {
114
- args: {
115
- Component: OrganizationCard,
116
- icon: 'ph--building-office--regular',
117
- subject: data.organization,
118
- role: 'popover',
119
- },
120
- };
121
-
122
- export const OrganizationNoImage = {
123
- args: {
124
- Component: OrganizationCard,
125
- icon: 'ph--building-office--regular',
126
- subject: omitImage(data.organization),
127
- role: 'popover',
128
- },
129
- };
130
-
131
- export const ProjectWithImage = {
132
- args: {
133
- Component: ProjectCard,
134
- icon: 'ph--building--regular',
135
- subject: data.project,
136
- role: 'popover',
137
- },
138
- };
139
-
140
- export const ProjectNoImage = {
141
- args: {
142
- Component: ProjectCard,
143
- icon: 'ph--building--regular',
144
- subject: omitImage(data.project),
145
- role: 'popover',
146
- },
147
- };
@@ -1,74 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import { Capabilities, LayoutAction, contributes, createIntent, type PluginContext } from '@dxos/app-framework';
6
- import { addEventListener } from '@dxos/async';
7
- import { type Client, resolveRef } from '@dxos/client';
8
- import { parseId, type Space } from '@dxos/client/echo';
9
- import { DXN } from '@dxos/keys';
10
- import { type DxRefTagActivate } from '@dxos/lit-ui';
11
- import { log } from '@dxos/log';
12
- import { ClientCapabilities } from '@dxos/plugin-client';
13
- import { type PreviewLinkRef, type PreviewLinkTarget } from '@dxos/react-ui-editor';
14
-
15
- const customEventOptions = { capture: true, passive: false };
16
-
17
- const handlePreviewLookup = async (
18
- client: Client,
19
- defaultSpace: Space,
20
- { ref, label }: PreviewLinkRef,
21
- ): Promise<PreviewLinkTarget | null> => {
22
- try {
23
- const dxn = DXN.parse(ref);
24
- if (!dxn) {
25
- return null;
26
- }
27
-
28
- const object = await resolveRef(client, dxn, defaultSpace);
29
- return { label, object };
30
- } catch (err) {
31
- return null;
32
- }
33
- };
34
-
35
- export default (context: PluginContext) => {
36
- // TODO(wittjosiah): Factor out lookup handlers to other plugins to make not ECHO-specific.
37
- const handleDxRefTagActivate = async ({ refId, label, trigger }: DxRefTagActivate) => {
38
- const { dispatchPromise: dispatch } = context.getCapability(Capabilities.IntentDispatcher);
39
- const client = context.getCapability(ClientCapabilities.Client);
40
- const [layout] = context.getCapabilities(Capabilities.Layout);
41
- const { spaceId } = parseId(layout.workspace);
42
- const space = (spaceId && client.spaces.get(spaceId)) ?? client.spaces.default;
43
- const result = await handlePreviewLookup(client, space, { ref: refId, label });
44
- if (!result) {
45
- return;
46
- }
47
-
48
- await dispatch(
49
- createIntent(LayoutAction.UpdatePopover, {
50
- part: 'popover',
51
- subject: result.object,
52
- options: {
53
- state: true,
54
- variant: 'virtual',
55
- anchor: trigger,
56
- },
57
- }),
58
- );
59
- };
60
-
61
- let cleanup: () => void;
62
- if (document.defaultView) {
63
- cleanup = addEventListener(
64
- document.defaultView,
65
- 'dx-ref-tag-activate' as any,
66
- handleDxRefTagActivate,
67
- customEventOptions,
68
- );
69
- } else {
70
- log.warn('No default view found');
71
- }
72
-
73
- return contributes(Capabilities.Null, null, () => cleanup());
74
- };
@@ -1,130 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import React, { useCallback } from 'react';
6
-
7
- import {
8
- Capabilities,
9
- LayoutAction,
10
- Surface,
11
- contributes,
12
- createIntent,
13
- createSurface,
14
- useIntentDispatcher,
15
- } from '@dxos/app-framework';
16
- import { fullyQualifiedId, getSchema, getSpace } from '@dxos/client/echo';
17
- import { Obj, Filter } from '@dxos/echo';
18
- import { type JsonPath, setValue } from '@dxos/echo-schema';
19
- import { useTranslation } from '@dxos/react-ui';
20
- import { Form } from '@dxos/react-ui-form';
21
- import { Card } from '@dxos/react-ui-stack';
22
- import { TableType } from '@dxos/react-ui-table';
23
- import { descriptionMessage, mx } from '@dxos/react-ui-theme';
24
- import { DataType } from '@dxos/schema';
25
-
26
- import { ContactCard, OrganizationCard, ProjectCard } from '../components';
27
- import { PREVIEW_PLUGIN } from '../meta';
28
-
29
- export default () =>
30
- contributes(Capabilities.ReactSurface, [
31
- //
32
- // Specific schema types.
33
- //
34
- createSurface({
35
- id: `${PREVIEW_PLUGIN}/schema-popover--contact`,
36
- role: ['popover', 'card--kanban', 'card--document', 'card'],
37
- filter: (data): data is { subject: DataType.Person } => Obj.instanceOf(DataType.Person, data.subject),
38
- component: ({ data, role }) => {
39
- const { dispatchPromise: dispatch } = useIntentDispatcher();
40
- const handleOrgClick = useCallback(
41
- async (org: DataType.Organization) => {
42
- const space = getSpace(org);
43
- const tablesQuery = await space?.db.query(Filter.type(TableType)).run();
44
- const currentSpaceOrgTable = tablesQuery?.objects.find((table) => {
45
- return table.view?.target?.query?.typename === DataType.Organization.typename;
46
- });
47
- await dispatch(
48
- createIntent(LayoutAction.UpdatePopover, {
49
- part: 'popover',
50
- options: {
51
- state: false,
52
- anchorId: '',
53
- },
54
- }),
55
- );
56
- if (currentSpaceOrgTable) {
57
- return dispatch(
58
- createIntent(LayoutAction.Open, {
59
- part: 'main',
60
- subject: [fullyQualifiedId(currentSpaceOrgTable)],
61
- options: { workspace: space?.id },
62
- }),
63
- );
64
- }
65
- },
66
- [dispatch],
67
- );
68
- return (
69
- <ContactCard role={role} subject={data.subject} onOrgClick={handleOrgClick}>
70
- {role === 'popover' && <Surface role='related' data={data} />}
71
- </ContactCard>
72
- );
73
- },
74
- }),
75
- createSurface({
76
- id: `${PREVIEW_PLUGIN}/schema-popover--organization`,
77
- role: ['popover', 'card--kanban', 'card--document', 'card'],
78
- filter: (data): data is { subject: DataType.Organization } => Obj.instanceOf(DataType.Organization, data.subject),
79
- component: ({ data, role }) => (
80
- <OrganizationCard role={role} subject={data.subject}>
81
- {role === 'popover' && <Surface role='related' data={data} />}
82
- </OrganizationCard>
83
- ),
84
- }),
85
- createSurface({
86
- id: `${PREVIEW_PLUGIN}/schema-popover--project`,
87
- role: ['popover', 'card--kanban', 'card--document', 'card'],
88
- filter: (data): data is { subject: DataType.Project } => Obj.instanceOf(DataType.Project, data.subject),
89
- component: ({ data, role }) => <ProjectCard subject={data.subject} role={role} />,
90
- }),
91
-
92
- //
93
- // Fallback for any object.
94
- //
95
- createSurface({
96
- id: `${PREVIEW_PLUGIN}/fallback-popover`,
97
- role: ['popover', 'card--kanban', 'card--document', 'card'],
98
- position: 'fallback',
99
- filter: (data): data is { subject: Obj.Any } => Obj.isObject(data.subject),
100
- component: ({ data, role }) => {
101
- const schema = getSchema(data.subject);
102
- const { t } = useTranslation(PREVIEW_PLUGIN);
103
- if (!schema) {
104
- // TODO(burdon): Use Alert.
105
- return <p className={mx(descriptionMessage)}>{t('unable to create preview message')}</p>;
106
- }
107
-
108
- const handleSave = useCallback((values: any, { changed }: { changed: Record<string, boolean> }) => {
109
- const changedPaths = Object.keys(changed).filter((path) => changed[path]);
110
- for (const path of changedPaths) {
111
- const value = values[path];
112
- setValue(data.subject, path as JsonPath, value);
113
- }
114
- }, []);
115
-
116
- return (
117
- <Card.Container role={role}>
118
- <Form
119
- schema={schema}
120
- values={data.subject}
121
- readonly={role === 'popover'}
122
- onSave={handleSave}
123
- autoSave
124
- {...(role === 'card--kanban' && { outerSpacing: 'blockStart-0' })}
125
- />
126
- </Card.Container>
127
- );
128
- },
129
- }),
130
- ]);
@@ -1,70 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import React, { Fragment } from 'react';
6
-
7
- import { Icon, Avatar, Button } from '@dxos/react-ui';
8
- import { Card, cardHeading, cardText } from '@dxos/react-ui-stack';
9
- import { mx } from '@dxos/react-ui-theme';
10
- import { type DataType } from '@dxos/schema';
11
-
12
- import { type PreviewProps } from '../types';
13
-
14
- export const ContactCard = ({
15
- children,
16
- subject: { fullName, image, organization, emails },
17
- onOrgClick,
18
- role,
19
- }: PreviewProps<DataType.Person> & { onOrgClick?: (org: DataType.Organization) => void }) => {
20
- const organizationName = organization && typeof organization === 'object' ? organization.target?.name : organization;
21
- return (
22
- <Card.Container role={role}>
23
- <Avatar.Root>
24
- <Card.Text role='group' classNames='grid gap-3 grid-cols-[min-content_1fr]'>
25
- <Avatar.Content imgSrc={image} icon='ph--user--regular' size={16} hue='neutral' />
26
- <div role='none' className='bs-min self-center'>
27
- <Avatar.Label asChild>
28
- <h2 className={cardHeading}>{fullName}</h2>
29
- </Avatar.Label>
30
- </div>
31
- </Card.Text>
32
- </Avatar.Root>
33
- {organizationName && (
34
- <Card.Chrome>
35
- {typeof organization === 'object' && onOrgClick ? (
36
- <Button variant='ghost' classNames='gap-2 text-start' onClick={() => onOrgClick(organization.target!)}>
37
- <Icon icon='ph--buildings--regular' size={5} classNames='text-subdued' />
38
- <span className='min-is-0 flex-1 truncate'>{organizationName}</span>
39
- <Icon icon='ph--arrow-right--regular' />
40
- </Button>
41
- ) : (
42
- <p className='dx-button gap-2' data-variant='ghost'>
43
- <Icon icon='ph--buildings--regular' size={5} classNames='text-subdued' />
44
- <span className='min-is-0 flex-1 truncate'>{organizationName}</span>
45
- </p>
46
- )}
47
- </Card.Chrome>
48
- )}
49
- <dl
50
- className={mx(
51
- cardText,
52
- 'grid gap-2 grid-cols-[min-content_1fr] [&_dt]:text-subdued [&_dt]:pbs-0.5 [&_dd]:min-is-0',
53
- )}
54
- >
55
- {emails?.length &&
56
- emails.map(({ label, value }) => (
57
- <Fragment key={value}>
58
- <dt>
59
- <Icon icon='ph--at--regular' size={5} />
60
- </dt>
61
- <dd key={value} className='break-words'>
62
- {value}
63
- </dd>
64
- </Fragment>
65
- ))}
66
- </dl>
67
- {children}
68
- </Card.Container>
69
- );
70
- };
@@ -1,41 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import React from 'react';
6
-
7
- import { Icon } from '@dxos/react-ui';
8
- import { Card } from '@dxos/react-ui-stack';
9
- import { type DataType } from '@dxos/schema';
10
-
11
- import { type PreviewProps } from '../types';
12
-
13
- export const OrganizationCard = ({
14
- children,
15
- subject: { name, image, description, website },
16
- role,
17
- }: PreviewProps<DataType.Organization>) => {
18
- return (
19
- <Card.Container role={role}>
20
- <Card.Poster alt={name!} {...(image ? { image } : { icon: 'ph--building-office--regular' })} />
21
- <Card.Heading>{name}</Card.Heading>
22
- {description && <Card.Text classNames='line-clamp-2'>{description}</Card.Text>}
23
- {website && (
24
- <Card.Chrome>
25
- <a
26
- className='dx-button dx-focus-ring gap-2'
27
- data-variant='ghost'
28
- href={website}
29
- target='_blank'
30
- rel='noreferrer'
31
- >
32
- <Icon icon='ph--link--regular' size={5} classNames='text-subdued' />
33
- <span className='grow'>{website}</span>
34
- <Icon icon='ph--arrow-square-out--regular' />
35
- </a>
36
- </Card.Chrome>
37
- )}
38
- {children}
39
- </Card.Container>
40
- );
41
- };
@@ -1,20 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import React from 'react';
6
-
7
- import { Card } from '@dxos/react-ui-stack';
8
- import { type DataType } from '@dxos/schema';
9
-
10
- import { type PreviewProps } from '../types';
11
-
12
- export const ProjectCard = ({ subject: { name, image, description }, role }: PreviewProps<DataType.Project>) => {
13
- return (
14
- <Card.Container role={role}>
15
- {image && <Card.Poster image={image} alt={name} aspect='auto' />}
16
- <Card.Heading>{name}</Card.Heading>
17
- {description && <Card.Text classNames='line-clamp-2'>{description}</Card.Text>}
18
- </Card.Container>
19
- );
20
- };
package/src/types.ts DELETED
@@ -1,11 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import { type PropsWithChildren } from 'react';
6
-
7
- // TODO(burdon): Better place for these defs?
8
- export type PreviewProps<T extends object> = PropsWithChildren<{
9
- subject: T;
10
- role?: string;
11
- }>;