@orangelogic/orange-dam-content-browser-sdk 2.1.52 → 2.1.54
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/.env +1 -0
- package/.eslintignore +2 -0
- package/.eslintrc.json +82 -0
- package/.releaserc +17 -0
- package/.travis.yml +20 -0
- package/CBSDKdemo.html +315 -0
- package/GitVersion.yml +18 -0
- package/azure-pipeline.yaml +93 -0
- package/clientlib.config.js +36 -0
- package/config/env.js +105 -0
- package/config/getHttpsConfig.js +67 -0
- package/config/jest/babelTransform.js +30 -0
- package/config/jest/cssTransform.js +14 -0
- package/config/jest/fileTransform.js +41 -0
- package/config/modules.js +135 -0
- package/config/paths.js +79 -0
- package/config/webpack/persistentCache/createEnvironmentHash.js +10 -0
- package/config/webpack.config.js +762 -0
- package/config/webpackDevServer.config.js +128 -0
- package/config-overrides.js +8 -0
- package/gab_extension/GAB.html +85 -0
- package/gab_extension/GoogleChrome/manifest.json +28 -0
- package/gab_extension/GoogleChrome/src/assets/icon48.png +0 -0
- package/gab_extension/GoogleChrome/src/background/index.js +6 -0
- package/gab_extension/GoogleChrome/src/scripts/index.js +347 -0
- package/gab_extension/MozillaFirefox/manifest.json +20 -0
- package/gab_extension/MozillaFirefox/src/assets/icon.png +0 -0
- package/gab_extension/MozillaFirefox/src/background/index.js +5 -0
- package/gab_extension/MozillaFirefox/src/scripts/index.js +347 -0
- package/gab_extension/README.md +11 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/Orange DAM Asset Browser Extension.xcodeproj/project.pbxproj +927 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/Orange DAM Asset Browser Extension.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/Orange DAM Asset Browser Extension.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/Orange DAM Asset Browser Extension.xcodeproj/project.xcworkspace/xcuserdata/oldevmac01.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/Orange DAM Asset Browser Extension.xcodeproj/xcuserdata/oldevmac01.xcuserdatad/xcschemes/xcschememanagement.plist +19 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/Shared (App)/Assets.xcassets/AccentColor.colorset/Contents.json +11 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/Shared (App)/Assets.xcassets/AppIcon.appiconset/Contents.json +63 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/Shared (App)/Assets.xcassets/Contents.json +6 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/Shared (App)/Assets.xcassets/LargeIcon.imageset/Contents.json +20 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/Shared (App)/Base.lproj/Main.html +23 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/Shared (App)/Resources/Icon.png +0 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/Shared (App)/Resources/Script.js +24 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/Shared (App)/Resources/Style.css +61 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/Shared (App)/ViewController.swift +81 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/Shared (Extension)/SafariWebExtensionHandler.swift +26 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/iOS (App)/AppDelegate.swift +24 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/iOS (App)/Base.lproj/LaunchScreen.storyboard +36 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/iOS (App)/Base.lproj/Main.storyboard +38 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/iOS (App)/Info.plist +27 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/iOS (App)/SceneDelegate.swift +18 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/iOS (Extension)/Info.plist +13 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/macOS (App)/AppDelegate.swift +21 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/macOS (App)/Base.lproj/Main.storyboard +125 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/macOS (App)/Info.plist +8 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/macOS (App)/Orange DAM Asset Browser Extension.entitlements +12 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/macOS (Extension)/Info.plist +13 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/macOS (Extension)/Orange DAM Asset Browser Extension.entitlements +10 -0
- package/package.json +8 -49
- package/public/index.html +92 -0
- package/scripts/build.js +218 -0
- package/scripts/start.js +154 -0
- package/scripts/test.js +53 -0
- package/src/App.tsx +98 -0
- package/src/AppContext.ts +18 -0
- package/src/GlobalConfigContext.ts +46 -0
- package/src/components/ArrayClamp/ArrayClamp.styled.ts +42 -0
- package/src/components/ArrayClamp/ArrayClamp.tsx +167 -0
- package/src/components/ArrayClamp/index.ts +1 -0
- package/src/components/Browser/Browser.styled.ts +82 -0
- package/src/components/Browser/Browser.tsx +284 -0
- package/src/components/Browser/BrowserItem.tsx +98 -0
- package/src/components/ControlBar/ControlBar.constants.tsx +66 -0
- package/src/components/ControlBar/ControlBar.styled.ts +82 -0
- package/src/components/ControlBar/ControlBar.tsx +528 -0
- package/src/components/ControlBar/Facet/Facet.tsx +113 -0
- package/src/components/ControlBar/Facet/index.ts +1 -0
- package/src/components/FormatDialog/CropPreviewer/CropPreviewer.tsx +224 -0
- package/{build/components/FormatDialog/CropPreviewer/index.d.ts → src/components/FormatDialog/CropPreviewer/index.ts} +1 -1
- package/src/components/FormatDialog/CustomRendition/CustomRendition.constants.ts +24 -0
- package/src/components/FormatDialog/CustomRendition/CustomRendition.styled.ts +57 -0
- package/src/components/FormatDialog/CustomRendition/CustomRendition.tsx +178 -0
- package/src/components/FormatDialog/CustomRendition/index.ts +1 -0
- package/src/components/FormatDialog/CustomRendition/transformations/Crop.tsx +249 -0
- package/src/components/FormatDialog/CustomRendition/transformations/Extension.tsx +54 -0
- package/src/components/FormatDialog/CustomRendition/transformations/Format.tsx +86 -0
- package/src/components/FormatDialog/CustomRendition/transformations/Resize.tsx +176 -0
- package/src/components/FormatDialog/CustomRendition/transformations/Rotate.tsx +101 -0
- package/{build/components/FormatDialog/CustomRendition/transformations/index.d.ts → src/components/FormatDialog/CustomRendition/transformations/index.ts} +1 -3
- package/src/components/FormatDialog/FormatDialog.styled.ts +137 -0
- package/src/components/FormatDialog/FormatDialog.tsx +1533 -0
- package/src/components/FormatDialog/Previewer/Previewer.styled.ts +31 -0
- package/src/components/FormatDialog/Previewer/Previewer.tsx +143 -0
- package/src/components/FormatDialog/Previewer/index.ts +1 -0
- package/src/components/FormatDialog/ProxyMenu/ProxyMenu.styled.ts +88 -0
- package/src/components/FormatDialog/ProxyMenu/ProxyMenu.tsx +74 -0
- package/src/components/FormatDialog/ProxyMenu/index.ts +1 -0
- package/src/components/FormatDialog/TrackingParameters/TrackingParameters.tsx +59 -0
- package/src/components/FormatDialog/TrackingParameters/index.ts +1 -0
- package/src/components/FormatDialog/index.ts +1 -0
- package/src/components/Header/Header.styled.ts +51 -0
- package/src/components/Header/Header.tsx +118 -0
- package/src/components/Loader/Loader.tsx +37 -0
- package/src/components/Loader/index.ts +1 -0
- package/src/components/NoResult/NoResult.tsx +37 -0
- package/src/components/NoResult/index.tsx +1 -0
- package/src/components/Result/AssetCard/AssetCard.styled.ts +120 -0
- package/src/components/Result/AssetCard/AssetCard.tsx +192 -0
- package/src/components/Result/AssetCard/AssetCardWrapper.styled.ts +35 -0
- package/src/components/Result/AssetCard/AssetCardWrapper.tsx +165 -0
- package/src/components/Result/AssetCard/index.ts +1 -0
- package/src/components/Result/AssetPreview/AssetPreview.styled.ts +108 -0
- package/src/components/Result/AssetPreview/AssetPreview.tsx +78 -0
- package/src/components/Result/AssetPreview/ImagePreview/ImagePreview.tsx +42 -0
- package/src/components/Result/AssetPreview/ImagePreview/index.ts +1 -0
- package/src/components/Result/AssetPreview/OtherPreview/OtherPreview.styled.ts +23 -0
- package/src/components/Result/AssetPreview/OtherPreview/OtherPreview.tsx +28 -0
- package/src/components/Result/AssetPreview/OtherPreview/index.ts +1 -0
- package/src/components/Result/AssetPreview/VideoPreview/VideoPreview.tsx +132 -0
- package/src/components/Result/AssetPreview/VideoPreview/index.ts +1 -0
- package/src/components/Result/AssetPreview/index.ts +1 -0
- package/src/consts/asset.ts +16 -0
- package/src/consts/data.ts +17 -0
- package/src/index.tsx +305 -0
- package/src/page/Authenticate/Authenticate.tsx +232 -0
- package/src/page/Authenticate/ConnectingBackground.tsx +44 -0
- package/src/page/Authenticate/index.tsx +94 -0
- package/src/page/Home/Home.styled.ts +46 -0
- package/src/page/Home/Home.tsx +941 -0
- package/src/react-web-component.d.ts +4617 -0
- package/src/store/assets/assets.api.ts +167 -0
- package/src/store/assets/assets.service.ts +223 -0
- package/src/store/assets/assets.slice.ts +104 -0
- package/src/store/auth/auth.service.ts +71 -0
- package/src/store/auth/auth.slice.ts +295 -0
- package/src/store/index.ts +27 -0
- package/src/store/search/search.api.ts +319 -0
- package/src/store/search/search.slice.ts +28 -0
- package/src/store/user/user.api.ts +29 -0
- package/src/styles.css +42 -0
- package/src/types/assets.ts +71 -0
- package/src/types/auth.ts +42 -0
- package/src/types/common.ts +11 -0
- package/src/types/download.ts +8 -0
- package/src/types/navigation.ts +3 -0
- package/src/types/search.ts +116 -0
- package/{build/types/storage.d.ts → src/types/storage.ts} +1 -1
- package/src/types/user.ts +6 -0
- package/src/utils/api.ts +186 -0
- package/src/utils/array.ts +25 -0
- package/src/utils/constants.ts +12 -0
- package/src/utils/fetch.ts +116 -0
- package/src/utils/getRequestUrl.ts +15 -0
- package/src/utils/hooks.ts +36 -0
- package/src/utils/icon.ts +22 -0
- package/src/utils/image.ts +157 -0
- package/src/utils/number.ts +11 -0
- package/src/utils/rotate.ts +23 -0
- package/src/utils/storage.ts +184 -0
- package/src/utils/string.ts +24 -0
- package/src/view/AssetsPicker.tsx +24 -0
- package/src/web-component.d.ts +8151 -0
- package/tsconfig.eslint.json +10 -0
- package/tsconfig.json +37 -0
- package/build/ApiService.d.ts +0 -15
- package/build/App.d.ts +0 -62
- package/build/AppContext.d.ts +0 -18
- package/build/GlobalConfigContext.d.ts +0 -32
- package/build/OrangeDAMContentBrowserSDK.min.css +0 -2
- package/build/OrangeDAMContentBrowserSDK.min.css.map +0 -1
- package/build/OrangeDAMContentBrowserSDK.min.js +0 -11468
- package/build/OrangeDAMContentBrowserSDK.min.js.map +0 -1
- package/build/asset-manifest.json +0 -13
- package/build/components/ArrayClamp/ArrayClamp.d.ts +0 -10
- package/build/components/ArrayClamp/ArrayClamp.styled.d.ts +0 -1
- package/build/components/ArrayClamp/index.d.ts +0 -1
- package/build/components/Browser/Browser.constants.d.ts +0 -3
- package/build/components/Browser/Browser.d.ts +0 -21
- package/build/components/Browser/Browser.styled.d.ts +0 -2
- package/build/components/Browser/BrowserItem.d.ts +0 -13
- package/build/components/Browser/LoadMoreButton.d.ts +0 -9
- package/build/components/ControlBar/ControlBar.constants.d.ts +0 -10
- package/build/components/ControlBar/ControlBar.d.ts +0 -23
- package/build/components/ControlBar/ControlBar.styled.d.ts +0 -1
- package/build/components/ControlBar/Facet/Facet.d.ts +0 -14
- package/build/components/ControlBar/Facet/index.d.ts +0 -1
- package/build/components/FormatDialog/CropPreviewer/CropPreviewer.d.ts +0 -41
- package/build/components/FormatDialog/CustomRendition/CustomRendition.constants.d.ts +0 -5
- package/build/components/FormatDialog/CustomRendition/CustomRendition.d.ts +0 -56
- package/build/components/FormatDialog/CustomRendition/CustomRendition.styled.d.ts +0 -1
- package/build/components/FormatDialog/CustomRendition/index.d.ts +0 -1
- package/build/components/FormatDialog/CustomRendition/transformations/Crop.d.ts +0 -26
- package/build/components/FormatDialog/CustomRendition/transformations/Extension.d.ts +0 -11
- package/build/components/FormatDialog/CustomRendition/transformations/Format.d.ts +0 -10
- package/build/components/FormatDialog/CustomRendition/transformations/Metadata.d.ts +0 -7
- package/build/components/FormatDialog/CustomRendition/transformations/Quality.d.ts +0 -7
- package/build/components/FormatDialog/CustomRendition/transformations/Resize.d.ts +0 -18
- package/build/components/FormatDialog/CustomRendition/transformations/Rotate.d.ts +0 -8
- package/build/components/FormatDialog/FormatDialog.d.ts +0 -49
- package/build/components/FormatDialog/FormatDialog.styled.d.ts +0 -3
- package/build/components/FormatDialog/Previewer/Previewer.d.ts +0 -17
- package/build/components/FormatDialog/Previewer/Previewer.styled.d.ts +0 -1
- package/build/components/FormatDialog/Previewer/index.d.ts +0 -1
- package/build/components/FormatDialog/ProxyMenu/ProxyMenu.d.ts +0 -20
- package/build/components/FormatDialog/ProxyMenu/ProxyMenu.styled.d.ts +0 -2
- package/build/components/FormatDialog/ProxyMenu/index.d.ts +0 -1
- package/build/components/FormatDialog/TrackingParameters/TrackingParameters.d.ts +0 -13
- package/build/components/FormatDialog/TrackingParameters/index.d.ts +0 -1
- package/build/components/FormatDialog/VersionHistory/VersionHistory.d.ts +0 -6
- package/build/components/FormatDialog/VersionHistory/VersionHistory.styled.d.ts +0 -1
- package/build/components/FormatDialog/VersionHistory/index.d.ts +0 -1
- package/build/components/FormatDialog/index.d.ts +0 -1
- package/build/components/Header/Header.d.ts +0 -15
- package/build/components/Header/Header.styled.d.ts +0 -5
- package/build/components/Loader/Loader.d.ts +0 -7
- package/build/components/Loader/index.d.ts +0 -1
- package/build/components/NoResult/NoResult.d.ts +0 -7
- package/build/components/NoResult/index.d.ts +0 -1
- package/build/components/Result/AssetCard/AssetCard.d.ts +0 -15
- package/build/components/Result/AssetCard/AssetCard.styled.d.ts +0 -2
- package/build/components/Result/AssetCard/AssetCardWrapper.d.ts +0 -18
- package/build/components/Result/AssetCard/AssetCardWrapper.styled.d.ts +0 -1
- package/build/components/Result/AssetCard/index.d.ts +0 -1
- package/build/components/Result/AssetPreview/AssetPreview.d.ts +0 -11
- package/build/components/Result/AssetPreview/AssetPreview.styled.d.ts +0 -1
- package/build/components/Result/AssetPreview/ImagePreview/ImagePreview.d.ts +0 -11
- package/build/components/Result/AssetPreview/ImagePreview/index.d.ts +0 -1
- package/build/components/Result/AssetPreview/OtherPreview/OtherPreview.d.ts +0 -9
- package/build/components/Result/AssetPreview/OtherPreview/OtherPreview.styled.d.ts +0 -1
- package/build/components/Result/AssetPreview/OtherPreview/index.d.ts +0 -1
- package/build/components/Result/AssetPreview/VideoPreview/VideoPreview.d.ts +0 -11
- package/build/components/Result/AssetPreview/VideoPreview/index.d.ts +0 -1
- package/build/components/Result/AssetPreview/index.d.ts +0 -1
- package/build/consts/asset.d.ts +0 -14
- package/build/consts/auth.d.ts +0 -4
- package/build/consts/data.d.ts +0 -21
- package/build/index.d.ts +0 -225
- package/build/index.html +0 -1
- package/build/page/Authenticate/Authenticate.d.ts +0 -2
- package/build/page/Authenticate/ConnectingBackground.d.ts +0 -8
- package/build/page/Authenticate/index.d.ts +0 -2
- package/build/page/Home/Home.d.ts +0 -6
- package/build/page/Home/Home.styled.d.ts +0 -2
- package/build/setupTests.d.ts +0 -1
- package/build/store/assets/assets.api.d.ts +0 -66
- package/build/store/assets/assets.service.d.ts +0 -23
- package/build/store/assets/assets.slice.d.ts +0 -65
- package/build/store/auth/auth.service.d.ts +0 -10
- package/build/store/auth/auth.slice.d.ts +0 -76
- package/build/store/index.d.ts +0 -368
- package/build/store/search/search.api.d.ts +0 -39
- package/build/store/search/search.slice.d.ts +0 -12
- package/build/store/user/user.api.d.ts +0 -5
- package/build/types/assets.d.ts +0 -68
- package/build/types/auth.d.ts +0 -35
- package/build/types/common.d.ts +0 -11
- package/build/types/download.d.ts +0 -8
- package/build/types/navigation.d.ts +0 -3
- package/build/types/search.d.ts +0 -148
- package/build/types/user.d.ts +0 -7
- package/build/utils/api.d.ts +0 -27
- package/build/utils/array.d.ts +0 -13
- package/build/utils/constants.d.ts +0 -11
- package/build/utils/function.d.ts +0 -1
- package/build/utils/getRequestUrl.d.ts +0 -1
- package/build/utils/hooks.d.ts +0 -1
- package/build/utils/icon.d.ts +0 -3
- package/build/utils/image.d.ts +0 -24
- package/build/utils/number.d.ts +0 -4
- package/build/utils/rotate.d.ts +0 -4
- package/build/utils/storage.d.ts +0 -23
- package/build/utils/string.d.ts +0 -12
- package/build/view/AssetsPicker.d.ts +0 -6
- /package/{build → public}/favicon.ico +0 -0
- /package/{build → public}/logo192.png +0 -0
- /package/{build → public}/logo512.png +0 -0
- /package/{build → public}/manifest.json +0 -0
- /package/{build → public}/robots.txt +0 -0
- /package/{build/components/Browser/index.d.ts → src/components/Browser/index.ts} +0 -0
- /package/{build/components/ControlBar/index.d.ts → src/components/ControlBar/index.ts} +0 -0
- /package/{build/components/Header/index.d.ts → src/components/Header/index.ts} +0 -0
- /package/{build/page/Home/index.d.ts → src/page/Home/index.ts} +0 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
|
|
3
|
+
import { ASSET_SIZE } from '@/consts/asset';
|
|
4
|
+
import { CxCardProps } from '@/react-web-component';
|
|
5
|
+
import { GridView } from '@/types/search';
|
|
6
|
+
|
|
7
|
+
export const Card = styled('cx-card')<CxCardProps>`
|
|
8
|
+
&.asset-card {
|
|
9
|
+
--border-color: transparent;
|
|
10
|
+
--border-radius: 0;
|
|
11
|
+
--border-width: 0;
|
|
12
|
+
--padding: 0;
|
|
13
|
+
--image-border-radius: var(--cx-border-radius-medium);
|
|
14
|
+
width: 100%;
|
|
15
|
+
|
|
16
|
+
&::part(base) {
|
|
17
|
+
box-shadow: none;
|
|
18
|
+
cursor: pointer;
|
|
19
|
+
overflow: hidden;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
&::part(image) {
|
|
23
|
+
aspect-ratio: 246/180;
|
|
24
|
+
position: relative;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
&::part(body) {
|
|
28
|
+
padding: var(--cx-spacing-x-small);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
&.selected {
|
|
32
|
+
--border-color: var(--cx-color-primary);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
cx-divider {
|
|
36
|
+
--color: var(--cx-color-neutral-500);
|
|
37
|
+
--spacing: 0;
|
|
38
|
+
--width: 10px;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
cx-space {
|
|
42
|
+
justify-content: space-between;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
&.asset-card--small {
|
|
46
|
+
max-width: ${ASSET_SIZE[GridView.Small].maxWidth}px;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
&.asset-card--medium {
|
|
50
|
+
max-width: ${ASSET_SIZE[GridView.Medium].maxWidth}px;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
&.asset-card--large {
|
|
54
|
+
max-width: ${ASSET_SIZE[GridView.Large].maxWidth}px;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.asset-card__checkbox {
|
|
59
|
+
background-color: var(--cx-color-neutral-0);
|
|
60
|
+
border-top-right-radius: var(--cx-border-radius-medium);
|
|
61
|
+
border-bottom-left-radius: var(--cx-border-radius-medium);
|
|
62
|
+
position: absolute;
|
|
63
|
+
top: var(--cx-spacing-3x-small);
|
|
64
|
+
right: var(--cx-spacing-3x-small);
|
|
65
|
+
display: flex;
|
|
66
|
+
align-items: center;
|
|
67
|
+
justify-content: center;
|
|
68
|
+
width: 28px;
|
|
69
|
+
height: 28px;
|
|
70
|
+
|
|
71
|
+
cx-checkbox {
|
|
72
|
+
line-height: normal;
|
|
73
|
+
|
|
74
|
+
&::part(label) {
|
|
75
|
+
display: none;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.asset-card__name {
|
|
81
|
+
flex: 1;
|
|
82
|
+
font-size: var(--cx-font-size-small);
|
|
83
|
+
|
|
84
|
+
&::part(content) {
|
|
85
|
+
word-break: break-all;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.asset-card__name--right {
|
|
90
|
+
text-align: right;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.asset-card__button {
|
|
94
|
+
&::part(base) {
|
|
95
|
+
font-size: var(--cx-font-size-medium);
|
|
96
|
+
padding: 0;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.asset-card__tags {
|
|
101
|
+
/* display: flex;
|
|
102
|
+
gap: var(--cx-spacing-3x-small); */
|
|
103
|
+
width: 100%;
|
|
104
|
+
height: 24px;
|
|
105
|
+
|
|
106
|
+
cx-tag {
|
|
107
|
+
max-width: 100%;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.asset-card__secondary-info {
|
|
112
|
+
color: var(--cx-color-neutral-500);
|
|
113
|
+
* {
|
|
114
|
+
line-height: var(--cx-line-height-small);
|
|
115
|
+
}
|
|
116
|
+
.asset-card__placeholder {
|
|
117
|
+
visibility: hidden;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
`;
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { FC, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
2
|
+
|
|
3
|
+
import ArrayClamp from '@/components/ArrayClamp';
|
|
4
|
+
import { ImageCardDisplayInfo } from '@/GlobalConfigContext';
|
|
5
|
+
import { Asset, GridView, MediaType } from '@/types/search';
|
|
6
|
+
import { isNullOrWhiteSpace } from '@/utils/string';
|
|
7
|
+
import { CxCard } from '@/web-component';
|
|
8
|
+
|
|
9
|
+
import AssetPreview from '../AssetPreview';
|
|
10
|
+
import { Card } from './AssetCard.styled';
|
|
11
|
+
|
|
12
|
+
type Props = {
|
|
13
|
+
id: string;
|
|
14
|
+
asset: Asset;
|
|
15
|
+
displayInfo: ImageCardDisplayInfo & { searchInDrive: boolean };
|
|
16
|
+
isSelected: boolean;
|
|
17
|
+
view: GridView;
|
|
18
|
+
onItemSelect: (asset: Asset) => void;
|
|
19
|
+
onMount?: (id: string) => void;
|
|
20
|
+
onLoaded?: (id: string) => void;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const AssetCard: FC<Props> = ({
|
|
24
|
+
id,
|
|
25
|
+
asset,
|
|
26
|
+
displayInfo,
|
|
27
|
+
isSelected,
|
|
28
|
+
view,
|
|
29
|
+
onItemSelect,
|
|
30
|
+
onMount,
|
|
31
|
+
onLoaded,
|
|
32
|
+
}) => {
|
|
33
|
+
const [imageLoaded, setImageLoaded] = useState(false);
|
|
34
|
+
const [isInViewport, setIsInViewport] = useState(false);
|
|
35
|
+
const cardRef = useRef<CxCard>(null);
|
|
36
|
+
const previewLoaded = imageLoaded || (asset.docType !== MediaType.Image && asset.docType !== MediaType.Video);
|
|
37
|
+
|
|
38
|
+
const onPreviewLoaded = useCallback(() => {
|
|
39
|
+
setImageLoaded(true);
|
|
40
|
+
if (onLoaded) {
|
|
41
|
+
onLoaded(id);
|
|
42
|
+
}
|
|
43
|
+
}, [id, onLoaded]);
|
|
44
|
+
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
if (onMount) {
|
|
47
|
+
onMount(id);
|
|
48
|
+
}
|
|
49
|
+
}, [onMount, id]);
|
|
50
|
+
|
|
51
|
+
const tags = useMemo(() => {
|
|
52
|
+
return asset?.tags.length > 0 ? asset?.tags.split(',').map((s) => s.trim()) : [];
|
|
53
|
+
}, [asset?.tags]);
|
|
54
|
+
|
|
55
|
+
const getTagTitle = useCallback((index: number) => {
|
|
56
|
+
if (displayInfo.tags && tags) {
|
|
57
|
+
return tags[index] || '';
|
|
58
|
+
}
|
|
59
|
+
return '';
|
|
60
|
+
}, [displayInfo.tags, tags]);
|
|
61
|
+
|
|
62
|
+
const assetClassNames = useMemo(() => {
|
|
63
|
+
const classNames: Record<string, boolean> = {
|
|
64
|
+
'asset-card': true,
|
|
65
|
+
selected: isSelected,
|
|
66
|
+
'asset-card--small': view === GridView.Small,
|
|
67
|
+
'asset-card--medium': view === GridView.Medium,
|
|
68
|
+
'asset-card--large': view === GridView.Large,
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
return Object.keys(classNames).filter((key) => classNames[key]).join(' ');
|
|
72
|
+
}, [isSelected, view]);
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
useEffect(() => {
|
|
76
|
+
const card = cardRef.current;
|
|
77
|
+
if (!card) return;
|
|
78
|
+
|
|
79
|
+
const observer = new IntersectionObserver((entries) => {
|
|
80
|
+
entries.forEach((entry) => {
|
|
81
|
+
if (entry.isIntersecting) {
|
|
82
|
+
setIsInViewport(true);
|
|
83
|
+
} else {
|
|
84
|
+
setIsInViewport(false);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
observer.observe(card);
|
|
90
|
+
|
|
91
|
+
return () => {
|
|
92
|
+
observer.unobserve(card);
|
|
93
|
+
};
|
|
94
|
+
}, []);
|
|
95
|
+
|
|
96
|
+
return (
|
|
97
|
+
<Card
|
|
98
|
+
ref={cardRef}
|
|
99
|
+
className={assetClassNames}
|
|
100
|
+
onClick={() => {
|
|
101
|
+
onItemSelect(asset);
|
|
102
|
+
}}
|
|
103
|
+
>
|
|
104
|
+
<AssetPreview
|
|
105
|
+
slot="image"
|
|
106
|
+
asset={asset}
|
|
107
|
+
imageLoaded={previewLoaded}
|
|
108
|
+
thumbnailOnly={view === GridView.Small || !isInViewport}
|
|
109
|
+
onLoaded={onPreviewLoaded}
|
|
110
|
+
/>
|
|
111
|
+
{isSelected && (
|
|
112
|
+
<div slot="image" className="asset-card__checkbox">
|
|
113
|
+
<cx-checkbox checked></cx-checkbox>
|
|
114
|
+
</div>
|
|
115
|
+
)}
|
|
116
|
+
<cx-space>
|
|
117
|
+
{displayInfo.title && (
|
|
118
|
+
<cx-line-clamp lines={1} className="asset-card__name">
|
|
119
|
+
{asset.name}
|
|
120
|
+
</cx-line-clamp>
|
|
121
|
+
)}
|
|
122
|
+
{displayInfo.searchInDrive && (
|
|
123
|
+
<cx-tooltip content="Open in drive">
|
|
124
|
+
<cx-icon-button name="folder" size="small" className="asset-card__button"></cx-icon-button>
|
|
125
|
+
</cx-tooltip>
|
|
126
|
+
)}
|
|
127
|
+
</cx-space>
|
|
128
|
+
{displayInfo.tags && tags.length > 0 && (
|
|
129
|
+
<ArrayClamp
|
|
130
|
+
className="asset-card__tags"
|
|
131
|
+
separator=" "
|
|
132
|
+
tooltipSeparator=", "
|
|
133
|
+
getChildString={getTagTitle}
|
|
134
|
+
>
|
|
135
|
+
{tags
|
|
136
|
+
?.filter((tag) => !isNullOrWhiteSpace(tag))
|
|
137
|
+
.slice(0, 5)
|
|
138
|
+
.map((tag) => (
|
|
139
|
+
<cx-tag
|
|
140
|
+
key={tag.toLowerCase()}
|
|
141
|
+
size="small"
|
|
142
|
+
variant="neutral"
|
|
143
|
+
pill
|
|
144
|
+
>
|
|
145
|
+
<cx-line-clamp lines={1}>{tag}</cx-line-clamp>
|
|
146
|
+
</cx-tag>
|
|
147
|
+
))}
|
|
148
|
+
</ArrayClamp>
|
|
149
|
+
)}
|
|
150
|
+
{(displayInfo.dimension || displayInfo.fileSize) && (
|
|
151
|
+
<cx-space spacing="small" align-items="center" wrap="nowrap" className="asset-card__secondary-info">
|
|
152
|
+
{displayInfo.dimension && Boolean(Number(asset.width)) && Boolean(Number(asset.height)) && (
|
|
153
|
+
<cx-line-clamp lines={1} className="asset-card__name">
|
|
154
|
+
<cx-typography variant="small">
|
|
155
|
+
<span>{asset.width}</span>x<span>{asset.height}</span>
|
|
156
|
+
</cx-typography>
|
|
157
|
+
</cx-line-clamp>
|
|
158
|
+
)}
|
|
159
|
+
{displayInfo.fileSize && (
|
|
160
|
+
<cx-line-clamp lines={1} className="asset-card__name asset-card__name--right">
|
|
161
|
+
<cx-typography variant="small">
|
|
162
|
+
{asset.size}
|
|
163
|
+
</cx-typography>
|
|
164
|
+
</cx-line-clamp>
|
|
165
|
+
)}
|
|
166
|
+
{!(
|
|
167
|
+
displayInfo.dimension && Boolean(Number(asset.width)) && Boolean(Number(asset.height)) ||
|
|
168
|
+
displayInfo.fileSize
|
|
169
|
+
) &&
|
|
170
|
+
(
|
|
171
|
+
<cx-typography variant="small" className="asset-card__placeholder">
|
|
172
|
+
<span>empty</span>
|
|
173
|
+
</cx-typography>
|
|
174
|
+
)}
|
|
175
|
+
</cx-space>
|
|
176
|
+
)}
|
|
177
|
+
{/* Placeholder to keep the card size consistent */}
|
|
178
|
+
{displayInfo.tags && tags.length === 0 && (
|
|
179
|
+
<ArrayClamp
|
|
180
|
+
className="asset-card__tags"
|
|
181
|
+
separator=" "
|
|
182
|
+
tooltipSeparator=", "
|
|
183
|
+
getChildString={getTagTitle}
|
|
184
|
+
>
|
|
185
|
+
<span></span>
|
|
186
|
+
</ArrayClamp>
|
|
187
|
+
)}
|
|
188
|
+
</Card>
|
|
189
|
+
);
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
export default AssetCard;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
|
|
3
|
+
export const Container = styled.div`
|
|
4
|
+
position: relative;
|
|
5
|
+
|
|
6
|
+
.wrapper__progress-bar {
|
|
7
|
+
--height: 4px;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.wrapper__content {
|
|
11
|
+
box-sizing: border-box;
|
|
12
|
+
overflow: auto;
|
|
13
|
+
padding: var(--cx-spacing-2x-small) 0;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.wrapper__content__empty {
|
|
17
|
+
position: absolute;
|
|
18
|
+
width: 100%;
|
|
19
|
+
height: 100%;
|
|
20
|
+
display: flex;
|
|
21
|
+
justify-content: center;
|
|
22
|
+
align-items: center;
|
|
23
|
+
top: 0;
|
|
24
|
+
left: 0;
|
|
25
|
+
|
|
26
|
+
cx-spinner {
|
|
27
|
+
--track-width: 6px,
|
|
28
|
+
font-size: var(--cx-font-size-3x-large),
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.asset-card__masonry > div {
|
|
33
|
+
align-items: center;
|
|
34
|
+
}
|
|
35
|
+
`;
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { forwardRef, useCallback, useContext, useMemo, useRef } from 'react';
|
|
2
|
+
import InfiniteScroll from 'react-infinite-scroll-component';
|
|
3
|
+
import Masonry from 'react-responsive-masonry';
|
|
4
|
+
|
|
5
|
+
import NoResult from '@/components/NoResult';
|
|
6
|
+
import { GlobalConfigContext } from '@/GlobalConfigContext';
|
|
7
|
+
import { Asset, GridView } from '@/types/search';
|
|
8
|
+
|
|
9
|
+
import AssetCard from './AssetCard';
|
|
10
|
+
import { Container } from './AssetCardWrapper.styled';
|
|
11
|
+
import { ASSET_SIZE } from '@/consts/asset';
|
|
12
|
+
|
|
13
|
+
type Props = {
|
|
14
|
+
// Are there more items to load?
|
|
15
|
+
// (This information comes from the most recent API request.)
|
|
16
|
+
hasNextPage: boolean;
|
|
17
|
+
height: number;
|
|
18
|
+
// Array of items loaded so far.
|
|
19
|
+
items: Asset[];
|
|
20
|
+
isConfigError?: boolean;
|
|
21
|
+
isError?: boolean;
|
|
22
|
+
isFetched?: boolean;
|
|
23
|
+
// Are we currently loading a page of items?
|
|
24
|
+
// (This may be an in-flight flag in your Redux store for example.)
|
|
25
|
+
isLoadingData: boolean;
|
|
26
|
+
selectedAsset: Asset | null;
|
|
27
|
+
view: GridView;
|
|
28
|
+
width: number;
|
|
29
|
+
onItemSelect: (selectedAsset: Asset) => void;
|
|
30
|
+
// Callback function responsible for loading the next page of items.
|
|
31
|
+
onLoadMore: () => void;
|
|
32
|
+
onScroll: (e: MouseEvent) => void;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export const AssetCardWrapper = forwardRef<HTMLDivElement, Props>(({
|
|
36
|
+
hasNextPage,
|
|
37
|
+
height,
|
|
38
|
+
isConfigError,
|
|
39
|
+
isError,
|
|
40
|
+
isFetched,
|
|
41
|
+
isLoadingData,
|
|
42
|
+
items,
|
|
43
|
+
selectedAsset,
|
|
44
|
+
view,
|
|
45
|
+
width,
|
|
46
|
+
onItemSelect,
|
|
47
|
+
onLoadMore,
|
|
48
|
+
onScroll,
|
|
49
|
+
}, ref) => {
|
|
50
|
+
const { displayInfo, searchInDrive } = useContext(GlobalConfigContext);
|
|
51
|
+
const infiniteScrollRef = useRef<InfiniteScroll>(null);
|
|
52
|
+
const gutter = useMemo(() => {
|
|
53
|
+
return parseInt(getComputedStyle(document.documentElement).getPropertyValue('--cx-spacing-medium') || '16', 10);
|
|
54
|
+
}, []);
|
|
55
|
+
|
|
56
|
+
const calculateColumnCount = useCallback(() => {
|
|
57
|
+
const actualWidth = infiniteScrollRef.current?.getScrollableTarget()?.children[0].clientWidth ?? width;
|
|
58
|
+
const breakPoint = ASSET_SIZE[view]?.minWidth || ASSET_SIZE[GridView.Large].minWidth;
|
|
59
|
+
return Math.max(1, Math.floor((actualWidth + gutter) / (breakPoint + gutter)));
|
|
60
|
+
}, [gutter, view, width]);
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
const renderContent = useCallback(() => {
|
|
64
|
+
if (items.length > 0) {
|
|
65
|
+
return (
|
|
66
|
+
<InfiniteScroll
|
|
67
|
+
dataLength={items.length}
|
|
68
|
+
hasMore={hasNextPage}
|
|
69
|
+
loader={null}
|
|
70
|
+
ref={infiniteScrollRef}
|
|
71
|
+
scrollableTarget="scrollableDiv"
|
|
72
|
+
style={{ overflow: 'visible' }}
|
|
73
|
+
next={onLoadMore}
|
|
74
|
+
onScroll={onScroll}
|
|
75
|
+
>
|
|
76
|
+
<Masonry columnsCount={calculateColumnCount()} gutter={`${gutter}px`} className='asset-card__masonry'>
|
|
77
|
+
{items.map((item) => (
|
|
78
|
+
<AssetCard
|
|
79
|
+
id={item.id}
|
|
80
|
+
key={item.id}
|
|
81
|
+
asset={item}
|
|
82
|
+
displayInfo={{
|
|
83
|
+
...displayInfo,
|
|
84
|
+
searchInDrive,
|
|
85
|
+
}}
|
|
86
|
+
view={view}
|
|
87
|
+
isSelected={selectedAsset?.id === item.id}
|
|
88
|
+
onItemSelect={onItemSelect}
|
|
89
|
+
/>
|
|
90
|
+
))}
|
|
91
|
+
</Masonry>
|
|
92
|
+
</InfiniteScroll>
|
|
93
|
+
);
|
|
94
|
+
} else if (!isLoadingData) {
|
|
95
|
+
return (
|
|
96
|
+
<div className="wrapper__content__empty">
|
|
97
|
+
<NoResult icon="search_off" message="No matching results" />
|
|
98
|
+
</div>
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return null;
|
|
103
|
+
}, [
|
|
104
|
+
hasNextPage,
|
|
105
|
+
isLoadingData,
|
|
106
|
+
items,
|
|
107
|
+
selectedAsset?.id,
|
|
108
|
+
view,
|
|
109
|
+
displayInfo,
|
|
110
|
+
gutter,
|
|
111
|
+
searchInDrive,
|
|
112
|
+
calculateColumnCount,
|
|
113
|
+
onItemSelect,
|
|
114
|
+
onLoadMore,
|
|
115
|
+
onScroll,
|
|
116
|
+
]);
|
|
117
|
+
|
|
118
|
+
if (isConfigError && isFetched) {
|
|
119
|
+
return (
|
|
120
|
+
<NoResult
|
|
121
|
+
icon="error_outline"
|
|
122
|
+
message="The Content Browser was loaded with incorrect configuration(s). Please update the configuration and try again."
|
|
123
|
+
/>
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (isError && isFetched) {
|
|
128
|
+
return (
|
|
129
|
+
<NoResult
|
|
130
|
+
icon="error_outline"
|
|
131
|
+
message="Something went wrong. Please try again later."
|
|
132
|
+
/>
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return (
|
|
137
|
+
<Container className="wrapper" ref={ref}>
|
|
138
|
+
<div
|
|
139
|
+
style={{
|
|
140
|
+
position: 'absolute',
|
|
141
|
+
width: '100%',
|
|
142
|
+
opacity: isLoadingData ? 1 : 0,
|
|
143
|
+
zIndex: 'var(--cx-z-index-drawer)',
|
|
144
|
+
}}
|
|
145
|
+
>
|
|
146
|
+
<cx-progress-bar
|
|
147
|
+
className="wrapper__progress-bar"
|
|
148
|
+
indeterminate
|
|
149
|
+
></cx-progress-bar>
|
|
150
|
+
</div>
|
|
151
|
+
<div
|
|
152
|
+
className="wrapper__content"
|
|
153
|
+
style={{
|
|
154
|
+
width: width,
|
|
155
|
+
height: height,
|
|
156
|
+
}}
|
|
157
|
+
id="scrollableDiv"
|
|
158
|
+
>
|
|
159
|
+
{renderContent()}
|
|
160
|
+
</div>
|
|
161
|
+
</Container>
|
|
162
|
+
);
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
export default AssetCardWrapper;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './AssetCardWrapper';
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
|
|
3
|
+
export const Container = styled.div`
|
|
4
|
+
&.asset-preview {
|
|
5
|
+
position: relative;
|
|
6
|
+
width: 100%;
|
|
7
|
+
height: 100%;
|
|
8
|
+
overflow: hidden;
|
|
9
|
+
display: flex;
|
|
10
|
+
align-items: center;
|
|
11
|
+
justify-content: center;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
&.asset-preview > div {
|
|
15
|
+
height: 100%;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.asset-preview__representative {
|
|
19
|
+
width: 100%;
|
|
20
|
+
height: 100%;
|
|
21
|
+
display: flex;
|
|
22
|
+
align-items: center;
|
|
23
|
+
justify-content: center;
|
|
24
|
+
object-fit: contain;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.asset-preview__representative--animated {
|
|
28
|
+
display: none;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.asset-preview__representative-container:hover {
|
|
32
|
+
.asset-preview__representative {
|
|
33
|
+
display: none;
|
|
34
|
+
}
|
|
35
|
+
.asset-preview__representative--animated {
|
|
36
|
+
display: block;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.asset-preview__representative--horizontal > * {
|
|
41
|
+
width: 100%;
|
|
42
|
+
height: auto;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.asset-preview__representative--vertical > * {
|
|
46
|
+
width: auto;
|
|
47
|
+
height: 100%;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.asset-preview__representative-overlay {
|
|
51
|
+
position: absolute;
|
|
52
|
+
width: 100%;
|
|
53
|
+
height: 100%;
|
|
54
|
+
top: 0;
|
|
55
|
+
left: 0;
|
|
56
|
+
background-color: transparent;
|
|
57
|
+
z-index: 1;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.asset-preview__image-skeleton {
|
|
61
|
+
--border-radius: var(--cx-border-radius-medium);
|
|
62
|
+
|
|
63
|
+
aspect-ratio: 246/180;
|
|
64
|
+
position: absolute;
|
|
65
|
+
width: 100%;
|
|
66
|
+
height: 100%;
|
|
67
|
+
top: 0;
|
|
68
|
+
left: 0;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.asset-preview__video-icon {
|
|
72
|
+
position: absolute;
|
|
73
|
+
top: 50%;
|
|
74
|
+
left: 50%;
|
|
75
|
+
transform: translate(-50%, -50%);
|
|
76
|
+
color: var(--cx-color-neutral-0);
|
|
77
|
+
font-size: var(--cx-font-size-x-large);
|
|
78
|
+
background-color: color-mix(
|
|
79
|
+
in srgb,
|
|
80
|
+
var(--cx-color-neutral-1000),
|
|
81
|
+
transparent 60%
|
|
82
|
+
);
|
|
83
|
+
border-radius: var(--cx-border-radius-medium);
|
|
84
|
+
display: flex;
|
|
85
|
+
align-items: center;
|
|
86
|
+
justify-content: center;
|
|
87
|
+
width: 40px;
|
|
88
|
+
height: 40px;
|
|
89
|
+
pointer-events: none;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.asset-preview__video-icon[hidden] {
|
|
93
|
+
display: none !important;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.asset-preview__progress-bar {
|
|
97
|
+
--height: 6px;
|
|
98
|
+
|
|
99
|
+
position: absolute;
|
|
100
|
+
bottom: 0;
|
|
101
|
+
left: 0;
|
|
102
|
+
width: 100%;
|
|
103
|
+
|
|
104
|
+
&::part(indicator) {
|
|
105
|
+
transition: none;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
`;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { FC, useCallback, useState } from 'react';
|
|
2
|
+
|
|
3
|
+
import { Asset, MediaType } from '@/types/search';
|
|
4
|
+
|
|
5
|
+
import { Container } from './AssetPreview.styled';
|
|
6
|
+
import ImagePreview from './ImagePreview';
|
|
7
|
+
import VideoPreview from './VideoPreview';
|
|
8
|
+
import OtherPreview from './OtherPreview';
|
|
9
|
+
|
|
10
|
+
type Props = {
|
|
11
|
+
asset: Asset;
|
|
12
|
+
imageLoaded: boolean;
|
|
13
|
+
slot: string;
|
|
14
|
+
thumbnailOnly: boolean;
|
|
15
|
+
onLoaded: () => void;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const AssetPreview: FC<Props> = ({
|
|
19
|
+
asset,
|
|
20
|
+
imageLoaded,
|
|
21
|
+
slot,
|
|
22
|
+
thumbnailOnly,
|
|
23
|
+
onLoaded,
|
|
24
|
+
}) => {
|
|
25
|
+
const [isError, setIsError] = useState(false);
|
|
26
|
+
|
|
27
|
+
const renderPreview = useCallback(() => {
|
|
28
|
+
const isUrlFilled = typeof asset.imageUrl === 'string' && asset.imageUrl.length > 0;
|
|
29
|
+
|
|
30
|
+
if (isError || !isUrlFilled) {
|
|
31
|
+
return (
|
|
32
|
+
<OtherPreview type={asset.docType}>
|
|
33
|
+
{asset.extension?.toUpperCase() || asset.docType}
|
|
34
|
+
</OtherPreview>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (asset.docType === MediaType.Video) {
|
|
39
|
+
return (
|
|
40
|
+
<VideoPreview
|
|
41
|
+
url={asset.scrubUrl}
|
|
42
|
+
thumbnailOnly={thumbnailOnly}
|
|
43
|
+
thumbnailUrl={asset.imageUrl}
|
|
44
|
+
loaded={imageLoaded}
|
|
45
|
+
onLoaded={onLoaded}
|
|
46
|
+
onError={() => setIsError(true)}
|
|
47
|
+
/>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<ImagePreview
|
|
53
|
+
alt={asset.name}
|
|
54
|
+
url={asset.imageUrl}
|
|
55
|
+
originalUrl={asset.extension === 'gif' && asset.originalUrl ? asset.originalUrl : undefined}
|
|
56
|
+
loaded={imageLoaded}
|
|
57
|
+
onLoaded={onLoaded}
|
|
58
|
+
onError={() => setIsError(true)}
|
|
59
|
+
/>
|
|
60
|
+
);
|
|
61
|
+
}, [asset, isError, onLoaded, thumbnailOnly, imageLoaded]);
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<Container slot={slot} className="asset-preview">
|
|
65
|
+
{
|
|
66
|
+
!imageLoaded && (
|
|
67
|
+
<cx-skeleton
|
|
68
|
+
slot="image"
|
|
69
|
+
className="asset-preview__image-skeleton"
|
|
70
|
+
></cx-skeleton>
|
|
71
|
+
)
|
|
72
|
+
}
|
|
73
|
+
{renderPreview()}
|
|
74
|
+
</Container>
|
|
75
|
+
);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export default AssetPreview;
|