@squiz/resource-browser 1.69.1 → 2.1.8-rc.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.
Files changed (141) hide show
  1. package/CHANGELOG.md +88 -35
  2. package/LICENSE.md +15 -0
  3. package/README.md +9 -0
  4. package/jest.config.ts +22 -21
  5. package/lib/Hooks/useSelectedState.d.ts +15 -0
  6. package/lib/Hooks/useSelectedState.js +16 -0
  7. package/lib/Hooks/useSources.d.ts +5 -4
  8. package/lib/Hooks/useSources.js +25 -1
  9. package/lib/MainContainer/MainContainer.d.ts +17 -0
  10. package/lib/MainContainer/MainContainer.js +61 -0
  11. package/lib/Plugin/Plugin.d.ts +13 -0
  12. package/lib/Plugin/Plugin.js +17 -0
  13. package/lib/ResourceBrowserContext/ResourceBrowserContext.d.ts +2 -3
  14. package/lib/ResourceBrowserContext/ResourceBrowserContext.js +4 -17
  15. package/lib/ResourceBrowserInput/ResourceBrowserInput.d.ts +24 -0
  16. package/lib/ResourceBrowserInput/ResourceBrowserInput.js +16 -0
  17. package/lib/ResourcePicker/ResourcePicker.d.ts +6 -4
  18. package/lib/ResourcePicker/ResourcePicker.js +14 -8
  19. package/lib/ResourcePicker/States/Selected.d.ts +10 -4
  20. package/lib/ResourcePicker/States/Selected.js +11 -32
  21. package/lib/SourceDropdown/SourceDropdown.d.ts +5 -11
  22. package/lib/SourceDropdown/SourceDropdown.js +20 -99
  23. package/lib/SourceList/SourceList.d.ts +5 -16
  24. package/lib/SourceList/SourceList.js +14 -75
  25. package/lib/index.css +42 -202
  26. package/lib/index.d.ts +7 -7
  27. package/lib/index.js +69 -13
  28. package/lib/types.d.ts +41 -59
  29. package/package.json +82 -80
  30. package/src/Hooks/useSelectedState.spec.ts +46 -0
  31. package/src/Hooks/useSelectedState.ts +22 -0
  32. package/src/Hooks/useSources.spec.ts +30 -12
  33. package/src/Hooks/useSources.ts +33 -4
  34. package/src/Icons/CircledLoopIcon.tsx +8 -8
  35. package/src/MainContainer/MainContainer.spec.tsx +203 -0
  36. package/src/MainContainer/MainContainer.stories.tsx +62 -0
  37. package/src/MainContainer/MainContainer.tsx +101 -0
  38. package/src/Plugin/Plugin.spec.tsx +46 -0
  39. package/src/Plugin/Plugin.tsx +20 -0
  40. package/src/ResourceBrowserContext/ResourceBrowserContext.spec.tsx +65 -106
  41. package/src/ResourceBrowserContext/ResourceBrowserContext.tsx +24 -39
  42. package/src/ResourceBrowserInput/ResourceBrowserInput.spec.tsx +192 -0
  43. package/src/ResourceBrowserInput/ResourceBrowserInput.tsx +81 -0
  44. package/src/ResourcePicker/ResourcePicker.spec.tsx +159 -116
  45. package/src/ResourcePicker/ResourcePicker.stories.tsx +28 -24
  46. package/src/ResourcePicker/ResourcePicker.tsx +79 -59
  47. package/src/ResourcePicker/States/Error.tsx +8 -8
  48. package/src/ResourcePicker/States/Loading.tsx +3 -3
  49. package/src/ResourcePicker/States/Selected.tsx +66 -73
  50. package/src/ResourcePicker/mock-image-resource.json +25 -47
  51. package/src/ResourcePicker/mock-resource.json +11 -13
  52. package/src/ResourcePicker/resource-picker.scss +13 -13
  53. package/src/SourceDropdown/SourceDropdown.spec.tsx +65 -391
  54. package/src/SourceDropdown/SourceDropdown.stories.tsx +21 -24
  55. package/src/SourceDropdown/SourceDropdown.tsx +80 -258
  56. package/src/SourceList/SourceList.spec.tsx +37 -430
  57. package/src/SourceList/SourceList.stories.tsx +17 -37
  58. package/src/SourceList/SourceList.tsx +28 -155
  59. package/src/__mocks__/MockModels.ts +56 -25
  60. package/src/__mocks__/PluginExample.tsx +98 -0
  61. package/src/__mocks__/StorybookHelpers.tsx +141 -0
  62. package/src/__mocks__/renderWithContext.tsx +14 -18
  63. package/src/__mocks__/sample-sources.json +32 -0
  64. package/src/index.scss +18 -8
  65. package/src/index.spec.tsx +277 -99
  66. package/src/index.stories.tsx +65 -39
  67. package/src/index.tsx +119 -57
  68. package/src/types.ts +54 -63
  69. package/tailwind.config.cjs +92 -92
  70. package/vite.config.js +12 -12
  71. package/lib/Hooks/useCategorisedSources.d.ts +0 -14
  72. package/lib/Hooks/useCategorisedSources.js +0 -38
  73. package/lib/Hooks/useChildResources.d.ts +0 -16
  74. package/lib/Hooks/useChildResources.js +0 -13
  75. package/lib/Hooks/usePreselectedResourcePath.d.ts +0 -20
  76. package/lib/Hooks/usePreselectedResourcePath.js +0 -31
  77. package/lib/Hooks/useRecentLocations.d.ts +0 -5
  78. package/lib/Hooks/useRecentLocations.js +0 -38
  79. package/lib/Hooks/useRecentResourcesPaths.d.ts +0 -20
  80. package/lib/Hooks/useRecentResourcesPaths.js +0 -30
  81. package/lib/Hooks/useResource.d.ts +0 -28
  82. package/lib/Hooks/useResource.js +0 -23
  83. package/lib/Hooks/useResourcePath.d.ts +0 -16
  84. package/lib/Hooks/useResourcePath.js +0 -64
  85. package/lib/Icons/HistoryIcon.d.ts +0 -4
  86. package/lib/Icons/HistoryIcon.js +0 -13
  87. package/lib/PreviewPanel/PreviewPanel.d.ts +0 -5
  88. package/lib/PreviewPanel/PreviewPanel.js +0 -8
  89. package/lib/PreviewPanel/details/MatrixResource.d.ts +0 -7
  90. package/lib/PreviewPanel/details/MatrixResource.js +0 -35
  91. package/lib/ResourceBreadcrumb/ResourceBreadcrumb.d.ts +0 -9
  92. package/lib/ResourceBreadcrumb/ResourceBreadcrumb.js +0 -54
  93. package/lib/ResourceList/ResourceList.d.ts +0 -18
  94. package/lib/ResourceList/ResourceList.js +0 -49
  95. package/lib/ResourcePickerContainer/ResourcePickerContainer.d.ts +0 -17
  96. package/lib/ResourcePickerContainer/ResourcePickerContainer.js +0 -166
  97. package/lib/StatusIndicator/StatusIndicator.d.ts +0 -8
  98. package/lib/StatusIndicator/StatusIndicator.js +0 -27
  99. package/lib/utils/findBestMatchLineage.d.ts +0 -2
  100. package/lib/utils/findBestMatchLineage.js +0 -28
  101. package/lib/utils/uuid.d.ts +0 -1
  102. package/lib/utils/uuid.js +0 -6
  103. package/src/Hooks/useCategorisedSources.spec.ts +0 -39
  104. package/src/Hooks/useCategorisedSources.ts +0 -46
  105. package/src/Hooks/useChildResources.spec.ts +0 -29
  106. package/src/Hooks/useChildResources.ts +0 -21
  107. package/src/Hooks/usePreselectedResourcePath.ts +0 -54
  108. package/src/Hooks/useRecentLocations.spec.ts +0 -81
  109. package/src/Hooks/useRecentLocations.ts +0 -44
  110. package/src/Hooks/useRecentResourcesPaths.ts +0 -54
  111. package/src/Hooks/useResource.spec.ts +0 -61
  112. package/src/Hooks/useResource.ts +0 -38
  113. package/src/Hooks/useResourcePath.spec.ts +0 -120
  114. package/src/Hooks/useResourcePath.ts +0 -76
  115. package/src/Icons/HistoryIcon.tsx +0 -17
  116. package/src/PreviewPanel/PreviewPanel.spec.tsx +0 -198
  117. package/src/PreviewPanel/PreviewPanel.stories.tsx +0 -76
  118. package/src/PreviewPanel/PreviewPanel.tsx +0 -6
  119. package/src/PreviewPanel/details/MatrixResource.tsx +0 -54
  120. package/src/PreviewPanel/details/matrix-resource.scss +0 -16
  121. package/src/ResourceBreadcrumb/ResourceBreadcrumb.spec.tsx +0 -133
  122. package/src/ResourceBreadcrumb/ResourceBreadcrumb.stories.tsx +0 -24
  123. package/src/ResourceBreadcrumb/ResourceBreadcrumb.tsx +0 -79
  124. package/src/ResourceBreadcrumb/resource-breadcrumb.scss +0 -28
  125. package/src/ResourceBreadcrumb/sample-hierarchy.json +0 -27
  126. package/src/ResourceList/ResourceList.spec.tsx +0 -202
  127. package/src/ResourceList/ResourceList.stories.tsx +0 -40
  128. package/src/ResourceList/ResourceList.tsx +0 -83
  129. package/src/ResourceList/sample-resources.json +0 -851
  130. package/src/ResourcePickerContainer/ResourcePickerContainer.spec.tsx +0 -780
  131. package/src/ResourcePickerContainer/ResourcePickerContainer.stories.tsx +0 -45
  132. package/src/ResourcePickerContainer/ResourcePickerContainer.tsx +0 -290
  133. package/src/SourceList/sample-sources.json +0 -251
  134. package/src/StatusIndicator/StatusIndicator.stories.tsx +0 -83
  135. package/src/StatusIndicator/StatusIndicator.tsx +0 -38
  136. package/src/__mocks__/JestHelpers.ts +0 -65
  137. package/src/__mocks__/StorybookHelpers.ts +0 -128
  138. package/src/__mocks__/jestHelpers.spec.ts +0 -38
  139. package/src/utils/findBestMatchLineage.spec.ts +0 -81
  140. package/src/utils/findBestMatchLineage.ts +0 -30
  141. package/src/utils/uuid.ts +0 -5
@@ -1,62 +1,66 @@
1
1
  import React from 'react';
2
2
  import { StoryFn, Meta } from '@storybook/react';
3
3
 
4
- import ResourcePicker, { ResourcePickerProps } from './ResourcePicker';
5
- import mockResource from './mock-resource.json';
4
+ import { ResourcePicker, ResourcePickerProps } from './ResourcePicker';
5
+ import { createPlugins } from '../__mocks__/StorybookHelpers';
6
+
6
7
  import mockImageResource from './mock-image-resource.json';
8
+ import mockResource from './mock-resource.json';
7
9
 
8
10
  export default {
9
- title: 'Resource picker field',
10
- component: ResourcePicker,
11
+ title: 'Resource picker field',
12
+ component: ResourcePicker,
11
13
  } as Meta<typeof ResourcePicker>;
12
14
 
13
15
  const Template: StoryFn<ResourcePickerProps> = (args: ResourcePickerProps) => (
14
- <div className="w-[400px] m-3">
15
- <ResourcePicker {...args}>{() => <>Resource browser here</>}</ResourcePicker>
16
- </div>
16
+ <div className="w-[400px] m-3">
17
+ <ResourcePicker plugins={createPlugins(0)} {...args}>
18
+ {() => <>Resource browser here</>}
19
+ </ResourcePicker>
20
+ </div>
17
21
  );
18
22
 
19
23
  export const Empty = Template.bind({});
20
24
  Empty.args = {
21
- resource: null,
22
- allowedTypes: undefined,
23
- isLoading: false,
24
- isError: false,
25
- isDisabled: false,
25
+ resource: null,
26
+ allowedTypes: undefined,
27
+ isLoading: false,
28
+ isError: false,
29
+ isDisabled: false,
26
30
  };
27
31
 
28
32
  export const ImagePicker = Template.bind({});
29
33
  ImagePicker.args = {
30
- ...Empty.args,
31
- allowedTypes: ['image'],
34
+ ...Empty.args,
35
+ allowedTypes: ['image'],
32
36
  };
33
37
 
34
38
  export const Loading = Template.bind({});
35
39
  Loading.args = {
36
- ...Empty.args,
37
- isLoading: true,
40
+ ...Empty.args,
41
+ isLoading: true,
38
42
  };
39
43
 
40
44
  export const Error = Template.bind({});
41
45
  Error.args = {
42
- ...Empty.args,
43
- error: new window.Error('Failed to retrieve asset info due to a Component Service API key problem.'),
46
+ ...Empty.args,
47
+ error: new window.Error('Failed to retrieve asset info due to a Component Service API key problem.'),
44
48
  };
45
49
 
46
50
  export const Selected = Template.bind({});
47
51
  Selected.args = {
48
- ...Empty.args,
49
- resource: mockResource,
52
+ ...Empty.args,
53
+ resource: mockResource,
50
54
  };
51
55
 
52
56
  export const SelectedImage = Template.bind({});
53
57
  SelectedImage.args = {
54
- ...Empty.args,
55
- resource: mockImageResource,
58
+ ...Empty.args,
59
+ resource: mockImageResource,
56
60
  };
57
61
 
58
62
  export const Disabled = Template.bind({});
59
63
  Disabled.args = {
60
- ...Empty.args,
61
- isDisabled: true,
64
+ ...Empty.args,
65
+ isDisabled: true,
62
66
  };
@@ -3,75 +3,95 @@ import AdsClickRoundedIcon from '@mui/icons-material/AdsClickRounded';
3
3
  import AddCircleOutlineRoundedIcon from '@mui/icons-material/AddCircleOutlineRounded';
4
4
  import PhotoLibraryRoundedIcon from '@mui/icons-material/PhotoLibraryRounded';
5
5
  import { DOMAttributes } from '@react-types/shared';
6
- import { ModalTrigger } from '@squiz/generic-browser-lib';
7
- import { Resource } from '../types';
6
+ import { ModalTrigger } from '@squiz/resource-browser-ui-lib';
8
7
  import { ErrorState } from './States/Error';
9
8
  import { LoadingState } from './States/Loading';
10
9
  import { SelectedState } from './States/Selected';
10
+ import { useSelectedState } from '../Hooks/useSelectedState';
11
+
12
+ import { ResourceBrowserResource, ResourceBrowserPlugin } from '../types';
11
13
  import clsx from 'clsx';
12
14
 
13
15
  export type ResourcePickerProps = {
14
- resource: Resource | null;
15
- allowedTypes: string[] | undefined;
16
- error: Error | null;
17
- isLoading: boolean;
18
- isDisabled?: boolean;
19
- children: (onClose: () => void, titleProps: DOMAttributes) => React.ReactElement;
20
- onClear: () => void;
16
+ resource: ResourceBrowserResource | null;
17
+ plugin: ResourceBrowserPlugin | null;
18
+ allowedTypes: string[] | undefined;
19
+ error: Error | null;
20
+ isLoading: boolean;
21
+ isDisabled?: boolean;
22
+ children: (onClose: () => void, titleProps: DOMAttributes) => React.ReactElement;
23
+ onClear: () => void;
24
+ isModalOpen: boolean;
25
+ onModalStateChange(isOpen: boolean): void;
21
26
  };
22
27
 
23
- const ResourcePicker = ({
24
- resource,
25
- allowedTypes,
26
- error,
27
- isLoading,
28
- isDisabled,
29
- children,
30
- onClear,
28
+ export const ResourcePicker = ({
29
+ resource,
30
+ plugin,
31
+ allowedTypes,
32
+ error: externalError,
33
+ isLoading: isExternalLoading,
34
+ isDisabled,
35
+ children,
36
+ onClear,
37
+ isModalOpen,
38
+ onModalStateChange,
31
39
  }: ResourcePickerProps) => {
32
- const isImagePicker = allowedTypes && allowedTypes.length === 1 && allowedTypes.includes('image');
33
- const isEmpty = resource === null && !isLoading && !error;
40
+ const { data: selectedState, error, isLoading } = useSelectedState({ resource, plugin });
41
+
42
+ const isImagePicker = allowedTypes && allowedTypes.length === 1 && allowedTypes.includes('image');
43
+ const isEmpty = resource === null && !isExternalLoading && !externalError;
34
44
 
35
- return (
36
- <div className={clsx('resource-picker', isDisabled && 'resource-picker--disabled')}>
37
- {isImagePicker ? (
38
- <PhotoLibraryRoundedIcon aria-hidden className="w-6 h-6" />
39
- ) : (
40
- <AdsClickRoundedIcon aria-hidden className="w-6 h-6" />
41
- )}
42
- {isEmpty ? (
43
- <ModalTrigger
44
- showLabel={true}
45
- label={isImagePicker ? `Choose image` : `Choose asset`}
46
- icon={
47
- <AddCircleOutlineRoundedIcon
48
- aria-hidden
49
- className={`!w-4 !h-4 text-blue-300 ${isDisabled ? 'text-gray-600' : ''}`}
50
- />
51
- }
52
- isDisabled={isDisabled}
53
- scope="squiz-rb-scope"
54
- >
55
- {children}
56
- </ModalTrigger>
57
- ) : (
58
- <div className="resource-picker-info">
59
- <div className="resource-picker-info__layout">
60
- {isLoading && <LoadingState />}
61
- {error && <ErrorState error={error} isDisabled={isDisabled} onClear={onClear} />}
62
- {resource && (
63
- <SelectedState
64
- resource={resource}
65
- isDisabled={isDisabled}
66
- onClear={onClear}
67
- resourcePickerContainer={children}
68
- />
45
+ return (
46
+ <div className={clsx('resource-picker', isDisabled && 'resource-picker--disabled')}>
47
+ {isImagePicker ? (
48
+ <PhotoLibraryRoundedIcon aria-hidden className="w-6 h-6" />
49
+ ) : (
50
+ <AdsClickRoundedIcon aria-hidden className="w-6 h-6" />
51
+ )}
52
+ {isEmpty ? (
53
+ <ModalTrigger
54
+ overlayTriggerState={{
55
+ isOpen: isModalOpen,
56
+ onOpenChange: onModalStateChange,
57
+ }}
58
+ showLabel={true}
59
+ label={isImagePicker ? `Choose image` : `Choose asset`}
60
+ icon={
61
+ <AddCircleOutlineRoundedIcon
62
+ aria-hidden
63
+ className={`!w-4 !h-4 text-blue-300 ${isDisabled ? 'text-gray-600' : ''}`}
64
+ />
65
+ }
66
+ isDisabled={isDisabled}
67
+ scope="squiz-rb-scope"
68
+ >
69
+ {children}
70
+ </ModalTrigger>
71
+ ) : (
72
+ <div className="resource-picker-info">
73
+ <div className="resource-picker-info__layout">
74
+ {(isExternalLoading || isLoading) && <LoadingState />}
75
+ {(externalError || error) && (
76
+ <ErrorState error={(externalError as Error) || (error as Error)} isDisabled={isDisabled} onClear={onClear} />
77
+ )}
78
+ {!isExternalLoading && resource && selectedState && (
79
+ <SelectedState
80
+ isModalOpen={isModalOpen}
81
+ onModalStateChange={onModalStateChange}
82
+ resource={resource}
83
+ showThumbnail={selectedState?.showThumbnail || false}
84
+ icon={selectedState?.icon}
85
+ label={selectedState?.label}
86
+ description={selectedState?.description}
87
+ isDisabled={isDisabled}
88
+ onClear={onClear}
89
+ resourcePickerContainer={children}
90
+ />
91
+ )}
92
+ </div>
93
+ </div>
69
94
  )}
70
- </div>
71
95
  </div>
72
- )}
73
- </div>
74
- );
96
+ );
75
97
  };
76
-
77
- export default ResourcePicker;
@@ -2,15 +2,15 @@ import React from 'react';
2
2
  import { Icon, IconOptions, ResetButton } from '@squiz/generic-browser-lib';
3
3
 
4
4
  export type ErrorStateProps = {
5
- error: Error;
6
- isDisabled?: boolean;
7
- onClear: () => void;
5
+ error: Error;
6
+ isDisabled?: boolean;
7
+ onClear: () => void;
8
8
  };
9
9
 
10
10
  export const ErrorState = ({ error, isDisabled, onClear }: ErrorStateProps) => (
11
- <>
12
- <Icon icon={'error' as IconOptions} aria-hidden className="w-6 h-6 text-red-300" />
13
- <div className="text-red-300 w-full">{error.message}</div>
14
- <ResetButton isDisabled={isDisabled} onClick={onClear} />
15
- </>
11
+ <>
12
+ <Icon icon={'error' as IconOptions} aria-hidden className="w-6 h-6 text-red-300" />
13
+ <div className="text-red-300 w-full">{error.message}</div>
14
+ <ResetButton isDisabled={isDisabled} onClick={onClear} />
15
+ </>
16
16
  );
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import { Spinner } from '@squiz/generic-browser-lib';
3
3
 
4
4
  export const LoadingState = () => (
5
- <div className="col-start-2 col-end-2">
6
- <Spinner label="Loading selection" className="m-2" />
7
- </div>
5
+ <div className="col-start-2 col-end-2">
6
+ <Spinner label="Loading selection" className="m-2" />
7
+ </div>
8
8
  );
@@ -1,84 +1,77 @@
1
- import React from 'react';
2
- import prettyBytes from 'pretty-bytes';
3
- import { Icon, IconOptions, ModalTrigger, ResetButton } from '@squiz/generic-browser-lib';
1
+ import React, { ReactElement } from 'react';
2
+ import { ResetButton } from '@squiz/generic-browser-lib';
3
+ import { ModalTrigger } from '@squiz/resource-browser-ui-lib';
4
+ import { ResourceBrowserResource } from '../../types';
4
5
 
5
- import { Resource } from '../../types';
6
- import StatusIndicator from '../../StatusIndicator/StatusIndicator';
7
6
  import { CircledLoopIcon } from '../../Icons/CircledLoopIcon';
8
7
 
9
8
  export type SelectedStateProps = {
10
- resource: Resource;
11
- isDisabled?: boolean;
12
- onClear: () => void;
13
- resourcePickerContainer: any;
9
+ resource: ResourceBrowserResource;
10
+ showThumbnail: boolean;
11
+ icon: ReactElement | undefined;
12
+ label: string;
13
+ description: Array<ReactElement>;
14
+ isDisabled?: boolean;
15
+ onClear: () => void;
16
+ resourcePickerContainer: any;
17
+ isModalOpen?: boolean;
18
+ onModalStateChange?(isOpen: boolean): void;
14
19
  };
15
20
 
16
21
  export const SelectedState = ({
17
- resource: { id, type, name, status, squizImage, url },
18
- isDisabled,
19
- onClear,
20
- resourcePickerContainer,
22
+ resource,
23
+ showThumbnail,
24
+ icon,
25
+ label,
26
+ description,
27
+ isDisabled,
28
+ onClear,
29
+ resourcePickerContainer,
30
+ isModalOpen,
31
+ onModalStateChange,
21
32
  }: SelectedStateProps) => {
22
- const fileSize = squizImage?.imageVariations?.original?.byteSize;
23
- const fileWidth = squizImage?.imageVariations?.original?.width;
24
- const fileHeight = squizImage?.imageVariations?.original?.height;
33
+ const modalController = {
34
+ isOpen: isModalOpen,
35
+ onOpenChange: onModalStateChange,
36
+ };
37
+ const replaceAsset = (
38
+ <ModalTrigger
39
+ overlayTriggerState={isModalOpen && onModalStateChange ? modalController : undefined}
40
+ showLabel={false}
41
+ label="Replace selection"
42
+ containerClasses="text-gray-500 hover:text-gray-800 focus:text-gray-800 disabled:text-gray-500 disabled:cursor-not-allowed"
43
+ icon={<CircledLoopIcon aria-hidden className="m-1" />}
44
+ isDisabled={isDisabled}
45
+ scope="squiz-rb-scope"
46
+ >
47
+ {resourcePickerContainer}
48
+ </ModalTrigger>
49
+ );
25
50
 
26
- const replaceAsset = (
27
- <ModalTrigger
28
- showLabel={false}
29
- label="Replace selection"
30
- containerClasses="text-gray-500 hover:text-gray-800 focus:text-gray-800 disabled:text-gray-500 disabled:cursor-not-allowed"
31
- icon={<CircledLoopIcon aria-hidden className="m-1" />}
32
- isDisabled={isDisabled}
33
- scope="squiz-rb-scope"
34
- >
35
- {resourcePickerContainer}
36
- </ModalTrigger>
37
- );
38
-
39
- return (
40
- <>
41
- {/* Left column */}
42
- {type.code === 'image' && url ? (
43
- <div className="checkered-bg w-[56px] h-[56px] overflow-hidden flex justify-center items-center rounded">
44
- <img src={url} className="w-full h-full object-cover object-center" alt={name} />
45
- </div>
46
- ) : (
47
- <Icon icon={type.code as IconOptions} resourceSource="matrix" className="w-4 h-4 mt-1 flex self-start" />
48
- )}
49
- {/* Center columns */}
50
- <div className="justify-self-start self-center w-full overflow-hidden break-words">
51
- <span>{name}</span>
52
- <dl className="col-start-2 col-end-2 flex flex-row gap-1 justify-self-start items-center font-normal text-sm">
53
- <div>
54
- <dt className="hidden">Status: {status.name}</dt>
55
- <dd className="flex items-center">
56
- <StatusIndicator status={status} />
57
- </dd>
58
- </div>
59
-
60
- <div>
61
- <dt className="hidden">Asset ID</dt>
62
- <dd className="text-gray-700">#{id}</dd>
63
- </div>
64
- </dl>
65
-
66
- {fileSize && (
67
- <dl className="col-start-2 col-end-2 flex flex-row gap-1 justify-self-start items-center font-normal text-sm">
68
- <div>
69
- <dt className="hidden">Asset size</dt>
70
- <dd className="text-gray-600">
71
- {prettyBytes(fileSize)}, {fileWidth} x {fileHeight}px
72
- </dd>
51
+ return (
52
+ <>
53
+ {/* Left column */}
54
+ {showThumbnail && resource.squizImage ? (
55
+ <div className="checkered-bg w-[56px] h-[56px] overflow-hidden flex justify-center items-center rounded">
56
+ <img
57
+ src={resource.squizImage.imageVariations.original.url || resource.url}
58
+ className="w-full h-full object-cover object-center"
59
+ alt={resource.squizImage.name || resource.name}
60
+ />
61
+ </div>
62
+ ) : (
63
+ <div className="w-4 h-4 mt-1 flex self-start overflow-hidden">{icon}</div>
64
+ )}
65
+ {/* Center columns */}
66
+ <div className="justify-self-start self-center w-full overflow-hidden break-words">
67
+ {label}
68
+ {description}
69
+ </div>
70
+ {/* End column */}
71
+ <div className="flex">
72
+ {replaceAsset}
73
+ <ResetButton isDisabled={isDisabled} onClick={onClear} />
73
74
  </div>
74
- </dl>
75
- )}
76
- </div>
77
- {/* End column */}
78
- <div className="flex">
79
- {replaceAsset}
80
- <ResetButton isDisabled={isDisabled} onClick={onClear} />
81
- </div>
82
- </>
83
- );
75
+ </>
76
+ );
84
77
  };
@@ -1,51 +1,29 @@
1
1
  {
2
- "id": "45104",
3
- "type": {
4
- "code": "image",
5
- "name": "Image"
6
- },
7
- "name": "DfBFfNQyB77dQMJYU4eH.jpg",
8
- "status": {
9
- "code": "under_construction",
10
- "name": "Under Construction"
11
- },
12
- "url": "https://picsum.photos/200/150",
13
- "urls": ["https://picsum.photos/200/150", "http://picsum.photos/200/150"],
14
- "childCount": 0,
15
- "squizImage": {
16
- "name": "Fancy music",
17
- "alt": "",
18
- "caption": "",
19
- "imageVariations": {
20
- "original": {
21
- "url": "",
22
- "width": 400,
23
- "height": 400,
24
- "byteSize": 37174,
25
- "mimeType": "image/",
26
- "aspectRatio": "4:3",
27
- "sha1Hash": ""
28
- },
29
- "aspectRatios": [
30
- {
31
- "url": "",
32
- "width": 100,
33
- "height": 100,
34
- "byteSize": 4628,
35
- "mimeType": "image/",
36
- "aspectRatio": "4:3",
37
- "sha1Hash": ""
38
- },
39
- {
40
- "url": "",
41
- "width": 104,
42
- "height": 96,
43
- "byteSize": 5718,
44
- "mimeType": "image/",
45
- "aspectRatio": "4:3",
46
- "sha1Hash": ""
2
+ "id": "45104",
3
+ "source": {
4
+ "id": "c90feac1-55f3-4e1f-9b56-c22829e3f510",
5
+ "type": "dam"
6
+ },
7
+ "type": {
8
+ "code": "image",
9
+ "name": "Image"
10
+ },
11
+ "name": "DfBFfNQyB77dQMJYU4eH.jpg",
12
+ "url": "https://picsum.photos/200/150",
13
+ "squizImage": {
14
+ "name": "Fancy music",
15
+ "alt": "",
16
+ "caption": "",
17
+ "imageVariations": {
18
+ "original": {
19
+ "url": "",
20
+ "width": 400,
21
+ "height": 400,
22
+ "byteSize": 37174,
23
+ "mimeType": "image/",
24
+ "aspectRatio": "4:3",
25
+ "sha1Hash": ""
26
+ }
47
27
  }
48
- ]
49
28
  }
50
- }
51
29
  }
@@ -1,15 +1,13 @@
1
1
  {
2
- "id": "1345",
3
- "name": "Products",
4
- "type": {
5
- "code": "page_standard",
6
- "name": "Standard Page"
7
- },
8
- "status": {
9
- "code": "under_construction",
10
- "name": "Under construction"
11
- },
12
- "url": "http://my-squiz.net/assets/1",
13
- "urls": [],
14
- "childCount": 0
2
+ "id": "1345",
3
+ "name": "Products",
4
+ "source": {
5
+ "id": "1111",
6
+ "type": "dam"
7
+ },
8
+ "type": {
9
+ "code": "page_standard",
10
+ "name": "Standard Page"
11
+ },
12
+ "url": "http://my-squiz.net/assets/1"
15
13
  }
@@ -1,16 +1,16 @@
1
1
  .resource-picker {
2
- @apply grid grid-cols-[24px_1fr] gap-2 bg-white;
3
- @apply border-2 border-gray-300;
4
- @apply text-gray-500 rounded p-2;
5
- &-info {
6
- @apply w-full p-2 bg-gray-100 rounded-md;
7
- @apply text-gray-900 text-base text-md font-semibold;
8
- &__layout {
9
- @apply grid grid-cols-[auto_1fr_auto] gap-2;
10
- @apply justify-items-center;
2
+ @apply grid grid-cols-[24px_1fr] gap-2 bg-white;
3
+ @apply border-2 border-gray-300;
4
+ @apply text-gray-500 rounded p-2;
5
+ &-info {
6
+ @apply w-full p-2 bg-gray-100 rounded-md;
7
+ @apply text-gray-900 text-base text-md font-semibold;
8
+ &__layout {
9
+ @apply grid grid-cols-[auto_1fr_auto] gap-2;
10
+ @apply justify-items-center;
11
+ }
12
+ }
13
+ &--disabled {
14
+ @apply bg-gray-50 border-0 cursor-not-allowed;
11
15
  }
12
- }
13
- &--disabled {
14
- @apply bg-gray-50 border-0 cursor-not-allowed;
15
- }
16
16
  }