@squiz/resource-browser 1.69.2 → 2.1.9-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.
- package/CHANGELOG.md +89 -38
- package/LICENSE.md +15 -0
- package/README.md +9 -0
- package/jest.config.ts +22 -21
- package/lib/Hooks/useSelectedState.d.ts +15 -0
- package/lib/Hooks/useSelectedState.js +16 -0
- package/lib/Hooks/useSources.d.ts +6 -6
- package/lib/Hooks/useSources.js +26 -1
- package/lib/MainContainer/MainContainer.d.ts +17 -0
- package/lib/MainContainer/MainContainer.js +61 -0
- package/lib/Plugin/Plugin.d.ts +13 -0
- package/lib/Plugin/Plugin.js +17 -0
- package/lib/ResourceBrowserContext/ResourceBrowserContext.d.ts +2 -3
- package/lib/ResourceBrowserContext/ResourceBrowserContext.js +4 -17
- package/lib/ResourceBrowserInput/ResourceBrowserInput.d.ts +24 -0
- package/lib/ResourceBrowserInput/ResourceBrowserInput.js +16 -0
- package/lib/ResourcePicker/ResourcePicker.d.ts +6 -4
- package/lib/ResourcePicker/ResourcePicker.js +14 -8
- package/lib/ResourcePicker/States/Selected.d.ts +10 -4
- package/lib/ResourcePicker/States/Selected.js +11 -32
- package/lib/SourceDropdown/SourceDropdown.d.ts +5 -11
- package/lib/SourceDropdown/SourceDropdown.js +20 -99
- package/lib/SourceList/SourceList.d.ts +5 -16
- package/lib/SourceList/SourceList.js +14 -75
- package/lib/index.css +42 -202
- package/lib/index.d.ts +7 -7
- package/lib/index.js +69 -13
- package/lib/types.d.ts +41 -59
- package/package.json +82 -80
- package/src/Hooks/useSelectedState.spec.ts +46 -0
- package/src/Hooks/useSelectedState.ts +22 -0
- package/src/Hooks/useSources.spec.ts +60 -13
- package/src/Hooks/useSources.ts +35 -5
- package/src/Icons/CircledLoopIcon.tsx +8 -8
- package/src/MainContainer/MainContainer.spec.tsx +203 -0
- package/src/MainContainer/MainContainer.stories.tsx +62 -0
- package/src/MainContainer/MainContainer.tsx +101 -0
- package/src/Plugin/Plugin.spec.tsx +46 -0
- package/src/Plugin/Plugin.tsx +20 -0
- package/src/ResourceBrowserContext/ResourceBrowserContext.spec.tsx +65 -106
- package/src/ResourceBrowserContext/ResourceBrowserContext.tsx +24 -39
- package/src/ResourceBrowserInput/ResourceBrowserInput.spec.tsx +192 -0
- package/src/ResourceBrowserInput/ResourceBrowserInput.tsx +81 -0
- package/src/ResourcePicker/ResourcePicker.spec.tsx +159 -116
- package/src/ResourcePicker/ResourcePicker.stories.tsx +28 -24
- package/src/ResourcePicker/ResourcePicker.tsx +79 -59
- package/src/ResourcePicker/States/Error.tsx +8 -8
- package/src/ResourcePicker/States/Loading.tsx +3 -3
- package/src/ResourcePicker/States/Selected.tsx +66 -73
- package/src/ResourcePicker/mock-image-resource.json +25 -47
- package/src/ResourcePicker/mock-resource.json +11 -13
- package/src/ResourcePicker/resource-picker.scss +13 -13
- package/src/SourceDropdown/SourceDropdown.spec.tsx +65 -391
- package/src/SourceDropdown/SourceDropdown.stories.tsx +21 -24
- package/src/SourceDropdown/SourceDropdown.tsx +80 -258
- package/src/SourceList/SourceList.spec.tsx +37 -430
- package/src/SourceList/SourceList.stories.tsx +17 -37
- package/src/SourceList/SourceList.tsx +28 -155
- package/src/__mocks__/MockModels.ts +56 -25
- package/src/__mocks__/PluginExample.tsx +98 -0
- package/src/__mocks__/StorybookHelpers.tsx +141 -0
- package/src/__mocks__/renderWithContext.tsx +14 -18
- package/src/__mocks__/sample-sources.json +32 -0
- package/src/index.scss +18 -8
- package/src/index.spec.tsx +277 -99
- package/src/index.stories.tsx +65 -39
- package/src/index.tsx +119 -57
- package/src/types.ts +54 -63
- package/tailwind.config.cjs +92 -92
- package/vite.config.js +12 -12
- package/lib/Hooks/useCategorisedSources.d.ts +0 -14
- package/lib/Hooks/useCategorisedSources.js +0 -38
- package/lib/Hooks/useChildResources.d.ts +0 -16
- package/lib/Hooks/useChildResources.js +0 -13
- package/lib/Hooks/usePreselectedResourcePath.d.ts +0 -20
- package/lib/Hooks/usePreselectedResourcePath.js +0 -31
- package/lib/Hooks/useRecentLocations.d.ts +0 -5
- package/lib/Hooks/useRecentLocations.js +0 -38
- package/lib/Hooks/useRecentResourcesPaths.d.ts +0 -20
- package/lib/Hooks/useRecentResourcesPaths.js +0 -30
- package/lib/Hooks/useResource.d.ts +0 -28
- package/lib/Hooks/useResource.js +0 -25
- package/lib/Hooks/useResourcePath.d.ts +0 -16
- package/lib/Hooks/useResourcePath.js +0 -64
- package/lib/Icons/HistoryIcon.d.ts +0 -4
- package/lib/Icons/HistoryIcon.js +0 -13
- package/lib/PreviewPanel/PreviewPanel.d.ts +0 -5
- package/lib/PreviewPanel/PreviewPanel.js +0 -8
- package/lib/PreviewPanel/details/MatrixResource.d.ts +0 -7
- package/lib/PreviewPanel/details/MatrixResource.js +0 -35
- package/lib/ResourceBreadcrumb/ResourceBreadcrumb.d.ts +0 -9
- package/lib/ResourceBreadcrumb/ResourceBreadcrumb.js +0 -54
- package/lib/ResourceList/ResourceList.d.ts +0 -18
- package/lib/ResourceList/ResourceList.js +0 -49
- package/lib/ResourcePickerContainer/ResourcePickerContainer.d.ts +0 -17
- package/lib/ResourcePickerContainer/ResourcePickerContainer.js +0 -166
- package/lib/StatusIndicator/StatusIndicator.d.ts +0 -8
- package/lib/StatusIndicator/StatusIndicator.js +0 -27
- package/lib/utils/findBestMatchLineage.d.ts +0 -2
- package/lib/utils/findBestMatchLineage.js +0 -28
- package/lib/utils/uuid.d.ts +0 -1
- package/lib/utils/uuid.js +0 -6
- package/src/Hooks/useCategorisedSources.spec.ts +0 -39
- package/src/Hooks/useCategorisedSources.ts +0 -46
- package/src/Hooks/useChildResources.spec.ts +0 -29
- package/src/Hooks/useChildResources.ts +0 -21
- package/src/Hooks/usePreselectedResourcePath.ts +0 -54
- package/src/Hooks/useRecentLocations.spec.ts +0 -81
- package/src/Hooks/useRecentLocations.ts +0 -44
- package/src/Hooks/useRecentResourcesPaths.ts +0 -54
- package/src/Hooks/useResource.spec.ts +0 -61
- package/src/Hooks/useResource.ts +0 -40
- package/src/Hooks/useResourcePath.spec.ts +0 -120
- package/src/Hooks/useResourcePath.ts +0 -76
- package/src/Icons/HistoryIcon.tsx +0 -17
- package/src/PreviewPanel/PreviewPanel.spec.tsx +0 -198
- package/src/PreviewPanel/PreviewPanel.stories.tsx +0 -76
- package/src/PreviewPanel/PreviewPanel.tsx +0 -6
- package/src/PreviewPanel/details/MatrixResource.tsx +0 -54
- package/src/PreviewPanel/details/matrix-resource.scss +0 -16
- package/src/ResourceBreadcrumb/ResourceBreadcrumb.spec.tsx +0 -133
- package/src/ResourceBreadcrumb/ResourceBreadcrumb.stories.tsx +0 -24
- package/src/ResourceBreadcrumb/ResourceBreadcrumb.tsx +0 -79
- package/src/ResourceBreadcrumb/resource-breadcrumb.scss +0 -28
- package/src/ResourceBreadcrumb/sample-hierarchy.json +0 -27
- package/src/ResourceList/ResourceList.spec.tsx +0 -202
- package/src/ResourceList/ResourceList.stories.tsx +0 -40
- package/src/ResourceList/ResourceList.tsx +0 -83
- package/src/ResourceList/sample-resources.json +0 -851
- package/src/ResourcePickerContainer/ResourcePickerContainer.spec.tsx +0 -780
- package/src/ResourcePickerContainer/ResourcePickerContainer.stories.tsx +0 -45
- package/src/ResourcePickerContainer/ResourcePickerContainer.tsx +0 -290
- package/src/SourceList/sample-sources.json +0 -251
- package/src/StatusIndicator/StatusIndicator.stories.tsx +0 -83
- package/src/StatusIndicator/StatusIndicator.tsx +0 -38
- package/src/__mocks__/JestHelpers.ts +0 -65
- package/src/__mocks__/StorybookHelpers.ts +0 -128
- package/src/__mocks__/jestHelpers.spec.ts +0 -38
- package/src/utils/findBestMatchLineage.spec.ts +0 -81
- package/src/utils/findBestMatchLineage.ts +0 -30
- 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,
|
5
|
-
import
|
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
|
-
|
10
|
-
|
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
|
-
|
15
|
-
|
16
|
-
|
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
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
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
|
-
|
31
|
-
|
34
|
+
...Empty.args,
|
35
|
+
allowedTypes: ['image'],
|
32
36
|
};
|
33
37
|
|
34
38
|
export const Loading = Template.bind({});
|
35
39
|
Loading.args = {
|
36
|
-
|
37
|
-
|
40
|
+
...Empty.args,
|
41
|
+
isLoading: true,
|
38
42
|
};
|
39
43
|
|
40
44
|
export const Error = Template.bind({});
|
41
45
|
Error.args = {
|
42
|
-
|
43
|
-
|
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
|
-
|
49
|
-
|
52
|
+
...Empty.args,
|
53
|
+
resource: mockResource,
|
50
54
|
};
|
51
55
|
|
52
56
|
export const SelectedImage = Template.bind({});
|
53
57
|
SelectedImage.args = {
|
54
|
-
|
55
|
-
|
58
|
+
...Empty.args,
|
59
|
+
resource: mockImageResource,
|
56
60
|
};
|
57
61
|
|
58
62
|
export const Disabled = Template.bind({});
|
59
63
|
Disabled.args = {
|
60
|
-
|
61
|
-
|
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/
|
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
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
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
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
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
|
-
|
33
|
-
|
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
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
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
|
-
|
6
|
-
|
7
|
-
|
5
|
+
error: Error;
|
6
|
+
isDisabled?: boolean;
|
7
|
+
onClear: () => void;
|
8
8
|
};
|
9
9
|
|
10
10
|
export const ErrorState = ({ error, isDisabled, onClear }: ErrorStateProps) => (
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
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
|
-
|
6
|
-
|
7
|
-
|
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
|
3
|
-
import {
|
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
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
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
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
22
|
+
resource,
|
23
|
+
showThumbnail,
|
24
|
+
icon,
|
25
|
+
label,
|
26
|
+
description,
|
27
|
+
isDisabled,
|
28
|
+
onClear,
|
29
|
+
resourcePickerContainer,
|
30
|
+
isModalOpen,
|
31
|
+
onModalStateChange,
|
21
32
|
}: SelectedStateProps) => {
|
22
|
-
|
23
|
-
|
24
|
-
|
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
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
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
|
-
|
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
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
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
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
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
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
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
|
}
|