@contentful/f36-asset 4.0.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/LICENSE.md +7 -0
- package/README.md +5 -0
- package/dist/main.js +182 -0
- package/dist/main.js.map +1 -0
- package/dist/module.js +173 -0
- package/dist/module.js.map +1 -0
- package/dist/types.d.ts +46 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +38 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright (c) 2018-present Contentful GmbH
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# @contentful/f36-asset
|
|
2
|
+
|
|
3
|
+
This package is part of the pre-release. This means it is unsupported and subject to breaking changes without warning.
|
|
4
|
+
|
|
5
|
+
Please use official, supported version of the library [forma-36](https://github.com/contentful/forma-36/tree/master/packages/forma-36-react-components), [NPM](https://www.npmjs.com/package/@contentful/forma-36-react-components).
|
package/dist/main.js
ADDED
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
var $goRX5$emotion = require("emotion");
|
|
2
|
+
var $goRX5$react = require("react");
|
|
3
|
+
var $goRX5$contentfulf36core = require("@contentful/f36-core");
|
|
4
|
+
var $goRX5$contentfulf36typography = require("@contentful/f36-typography");
|
|
5
|
+
var $goRX5$contentfulf36icons = require("@contentful/f36-icons");
|
|
6
|
+
var $goRX5$contentfulf36tokens = require("@contentful/f36-tokens");
|
|
7
|
+
|
|
8
|
+
function $parcel$export(e, n, v, s) {
|
|
9
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
10
|
+
}
|
|
11
|
+
function $parcel$interopDefault(a) {
|
|
12
|
+
return a && a.__esModule ? a.default : a;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
$parcel$export(module.exports, "Asset", () => $ee511d6a9591eb62$export$c413dd039085b182);
|
|
16
|
+
$parcel$export(module.exports, "AssetIcon", () => $bdfac71418b2e6eb$export$de8d5274b07acfbd);
|
|
17
|
+
$parcel$export(module.exports, "isAssetType", () => $ecfcb790f927d565$export$3ccaa71e0816392d);
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
function $a7f01243e6d07e2f$export$d4130e73e2e8f9dd() {
|
|
28
|
+
return {
|
|
29
|
+
root: /*#__PURE__*/ $goRX5$emotion.css({
|
|
30
|
+
display: 'inline-block',
|
|
31
|
+
width: '39px',
|
|
32
|
+
height: '39px',
|
|
33
|
+
'g, path': {
|
|
34
|
+
fill: ($parcel$interopDefault($goRX5$contentfulf36tokens)).gray600
|
|
35
|
+
}
|
|
36
|
+
})
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
function $bdfac71418b2e6eb$export$de8d5274b07acfbd({ type: type = 'archive' , className: className , testId: testId = 'cf-ui-asset-icon' , ...otherProps }) {
|
|
42
|
+
const styles = $a7f01243e6d07e2f$export$d4130e73e2e8f9dd();
|
|
43
|
+
const props = {
|
|
44
|
+
...otherProps,
|
|
45
|
+
testId: testId,
|
|
46
|
+
className: $goRX5$emotion.cx(styles.root, className)
|
|
47
|
+
};
|
|
48
|
+
switch(type){
|
|
49
|
+
case 'audio':
|
|
50
|
+
return(/*#__PURE__*/ ($parcel$interopDefault($goRX5$react)).createElement($goRX5$contentfulf36icons.AudioIcon, props));
|
|
51
|
+
case 'code':
|
|
52
|
+
return(/*#__PURE__*/ ($parcel$interopDefault($goRX5$react)).createElement($goRX5$contentfulf36icons.CodeIllustrationIcon, props));
|
|
53
|
+
case 'image':
|
|
54
|
+
return(/*#__PURE__*/ ($parcel$interopDefault($goRX5$react)).createElement($goRX5$contentfulf36icons.ImageIcon, props));
|
|
55
|
+
case 'markup':
|
|
56
|
+
return(/*#__PURE__*/ ($parcel$interopDefault($goRX5$react)).createElement($goRX5$contentfulf36icons.MarkupIcon, props));
|
|
57
|
+
case 'pdf':
|
|
58
|
+
return(/*#__PURE__*/ ($parcel$interopDefault($goRX5$react)).createElement($goRX5$contentfulf36icons.PdfIcon, props));
|
|
59
|
+
case 'plaintext':
|
|
60
|
+
return(/*#__PURE__*/ ($parcel$interopDefault($goRX5$react)).createElement($goRX5$contentfulf36icons.PlaintextIcon, props));
|
|
61
|
+
case 'presentation':
|
|
62
|
+
return(/*#__PURE__*/ ($parcel$interopDefault($goRX5$react)).createElement($goRX5$contentfulf36icons.PresentationIcon, props));
|
|
63
|
+
case 'richtext':
|
|
64
|
+
return(/*#__PURE__*/ ($parcel$interopDefault($goRX5$react)).createElement($goRX5$contentfulf36icons.RichtextIcon, props));
|
|
65
|
+
case 'spreadsheet':
|
|
66
|
+
return(/*#__PURE__*/ ($parcel$interopDefault($goRX5$react)).createElement($goRX5$contentfulf36icons.SpreadsheetIcon, props));
|
|
67
|
+
case 'video':
|
|
68
|
+
return(/*#__PURE__*/ ($parcel$interopDefault($goRX5$react)).createElement($goRX5$contentfulf36icons.VideoIcon, props));
|
|
69
|
+
case 'archive':
|
|
70
|
+
default:
|
|
71
|
+
return(/*#__PURE__*/ ($parcel$interopDefault($goRX5$react)).createElement($goRX5$contentfulf36icons.ArchiveIcon, props));
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
function $757deda98165af5b$export$fa02bd03531e2fe() {
|
|
79
|
+
return {
|
|
80
|
+
relative: /*#__PURE__*/ $goRX5$emotion.css({
|
|
81
|
+
name: "1jke4yk",
|
|
82
|
+
styles: "position:relative;width:100%;"
|
|
83
|
+
}),
|
|
84
|
+
height100: /*#__PURE__*/ $goRX5$emotion.css({
|
|
85
|
+
name: "10klw3m",
|
|
86
|
+
styles: "height:100%;"
|
|
87
|
+
}),
|
|
88
|
+
image: /*#__PURE__*/ $goRX5$emotion.css({
|
|
89
|
+
name: "1o9ustp",
|
|
90
|
+
styles: "width:auto;height:100%;max-width:100%;max-height:100%;object-fit:contain;"
|
|
91
|
+
}),
|
|
92
|
+
titleContainer: /*#__PURE__*/ $goRX5$emotion.css({
|
|
93
|
+
opacity: 0,
|
|
94
|
+
transition: `opacity ${($parcel$interopDefault($goRX5$contentfulf36tokens)).transitionDurationDefault} ${($parcel$interopDefault($goRX5$contentfulf36tokens)).transitionEasingDefault}`,
|
|
95
|
+
position: 'absolute',
|
|
96
|
+
bottom: 0,
|
|
97
|
+
right: 0,
|
|
98
|
+
left: 0,
|
|
99
|
+
height: '100%',
|
|
100
|
+
display: 'flex',
|
|
101
|
+
overflow: 'hidden',
|
|
102
|
+
alignItems: 'flex-end',
|
|
103
|
+
boxSizing: 'border-box',
|
|
104
|
+
background: `linear-gradient(0deg, ${($parcel$interopDefault($goRX5$contentfulf36tokens)).gray900} 0%, transparent calc(1rem * (100 / ${($parcel$interopDefault($goRX5$contentfulf36tokens)).fontBaseDefault})), transparent 100% )`,
|
|
105
|
+
':hover': {
|
|
106
|
+
opacity: 1
|
|
107
|
+
}
|
|
108
|
+
}),
|
|
109
|
+
title: /*#__PURE__*/ $goRX5$emotion.css({
|
|
110
|
+
name: "4gk4ib",
|
|
111
|
+
styles: "bottom:0;left:0;right:0;position:absolute;"
|
|
112
|
+
})
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
function $ee511d6a9591eb62$export$c413dd039085b182({ className: className , src: src , status: status , testId: testId = 'cf-ui-asset' , title: title , type: type = 'image' , ...otherProps }) {
|
|
118
|
+
const styles = $757deda98165af5b$export$fa02bd03531e2fe();
|
|
119
|
+
const isImage = src && src !== '' && type === 'image'; // Do not show image previews when publish status is archived
|
|
120
|
+
const showPreview = isImage && status !== 'archived';
|
|
121
|
+
return(/*#__PURE__*/ ($parcel$interopDefault($goRX5$react)).createElement($goRX5$contentfulf36core.Box, {
|
|
122
|
+
className: $goRX5$emotion.cx(styles.relative, className),
|
|
123
|
+
testId: testId,
|
|
124
|
+
...otherProps
|
|
125
|
+
}, showPreview ? /*#__PURE__*/ ($parcel$interopDefault($goRX5$react)).createElement(($parcel$interopDefault($goRX5$react)).Fragment, null, /*#__PURE__*/ ($parcel$interopDefault($goRX5$react)).createElement($goRX5$contentfulf36core.Flex, {
|
|
126
|
+
alignItems: "center",
|
|
127
|
+
justifyContent: "center",
|
|
128
|
+
className: styles.height100
|
|
129
|
+
}, /*#__PURE__*/ ($parcel$interopDefault($goRX5$react)).createElement("img", {
|
|
130
|
+
className: styles.image,
|
|
131
|
+
src: src,
|
|
132
|
+
alt: title
|
|
133
|
+
})), title && /*#__PURE__*/ ($parcel$interopDefault($goRX5$react)).createElement("div", {
|
|
134
|
+
className: styles.titleContainer
|
|
135
|
+
}, /*#__PURE__*/ ($parcel$interopDefault($goRX5$react)).createElement($goRX5$contentfulf36typography.Text, {
|
|
136
|
+
className: styles.title,
|
|
137
|
+
fontColor: "colorWhite",
|
|
138
|
+
margin: "spacingS",
|
|
139
|
+
isTruncated: true
|
|
140
|
+
}, title))) : /*#__PURE__*/ ($parcel$interopDefault($goRX5$react)).createElement($goRX5$contentfulf36core.Flex, {
|
|
141
|
+
flexDirection: "column",
|
|
142
|
+
alignItems: "center",
|
|
143
|
+
justifyContent: "center",
|
|
144
|
+
paddingLeft: "spacingS",
|
|
145
|
+
paddingRight: "spacingS",
|
|
146
|
+
className: styles.height100
|
|
147
|
+
}, /*#__PURE__*/ ($parcel$interopDefault($goRX5$react)).createElement($goRX5$contentfulf36core.Flex, {
|
|
148
|
+
marginBottom: "spacingM",
|
|
149
|
+
marginTop: "spacingM",
|
|
150
|
+
justifyContent: "center"
|
|
151
|
+
}, /*#__PURE__*/ ($parcel$interopDefault($goRX5$react)).createElement($bdfac71418b2e6eb$export$de8d5274b07acfbd, {
|
|
152
|
+
type: type
|
|
153
|
+
})), /*#__PURE__*/ ($parcel$interopDefault($goRX5$react)).createElement($goRX5$contentfulf36typography.Text, {
|
|
154
|
+
isTruncated: true,
|
|
155
|
+
marginBottom: "spacingM",
|
|
156
|
+
fontColor: "gray600"
|
|
157
|
+
}, title))));
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
const $ecfcb790f927d565$export$b14ad400b1d09e0f = {
|
|
163
|
+
archive: 'archive',
|
|
164
|
+
audio: 'audio',
|
|
165
|
+
code: 'code',
|
|
166
|
+
image: 'image',
|
|
167
|
+
markup: 'markup',
|
|
168
|
+
pdf: 'pdf',
|
|
169
|
+
plaintext: 'plaintext',
|
|
170
|
+
presentation: 'presentation',
|
|
171
|
+
richtext: 'richtext',
|
|
172
|
+
spreadsheet: 'spreadsheet',
|
|
173
|
+
video: 'video'
|
|
174
|
+
};
|
|
175
|
+
function $ecfcb790f927d565$export$3ccaa71e0816392d(type) {
|
|
176
|
+
return Object.keys($ecfcb790f927d565$export$b14ad400b1d09e0f).includes(type);
|
|
177
|
+
}
|
|
178
|
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ACL,KAAR;QACV,SAAA,EAAU,CAFZ;QAGE,MAAA,EAAO,CAHT;QAIE,WAJF,EAIE,IAJF;OAMGA,KAAD,yEAMP,6BAAD;QACE,aAAA,EAAc,CADhB;QAEE,UAAA,EAAW,CAFb;QAGE,cAAA,EAAe,CAHjB;QAIE,WAAA,EAAY,CAJd;QAKE,YAAA,EAAa,CALf;QAME,SAAA,EAAWK,MAAM,CAACI,SAAR;0EAET,6BAAD;QACE,YAAA,EAAa,CADf;QAEE,SAAA,EAAU,CAFZ;QAGE,cAAA,EAAe,CAHjB;0EAKG,yCAAD;QAAW,IAAA,EAAMR,IAAD;4EAEjB,mCAAD;QAAM,WAAN,EAAM,IAAN;QAAkB,YAAA,EAAa,CAA/B;QAA0C,SAAA,EAAU,CAApD;OACGD,KAAD;AAMX,CAAA;;;;AIxGM,KAAA,CAAMgD,yCAAK,GAAG,CAArB;IACEC,OAAO,EAAE,CADU;IAEnBC,KAAK,EAAE,CAFY;IAGnBC,IAAI,EAAE,CAHa;IAInBzC,KAAK,EAAE,CAJY;IAKnB0C,MAAM,EAAE,CALW;IAMnBC,GAAG,EAAE,CANc;IAOnBC,SAAS,EAAE,CAPQ;IAQnBC,YAAY,EAAE,CARK;IASnBC,QAAQ,EAAE,CATS;IAUnBC,WAAW,EAAE,CAVM;IAWnBC,KAAK,EAAE,CAAPA;AAXmB,CAAd;SAcSrE,yCAAT,CAAqBY,IAArB,EAAsD,CAA7D;IACE,MAAA,CAAO0D,MAAM,CAACC,IAAP,CAAYZ,yCAAZ,EAAmBa,QAAnB,CAA4B5D,IAA5B;AACR,CAAA;;","sources":["packages/components/asset/src/index.ts","packages/components/asset/src/Asset.tsx","packages/components/asset/src/AssetIcon/AssetIcon.tsx","packages/components/asset/src/AssetIcon/AssetIcon.styles.ts","packages/components/asset/src/Asset.styles.ts","packages/components/asset/src/types.ts"],"sourcesContent":["export { Asset } from './Asset';\nexport type { AssetProps, AssetStatus } from './Asset';\nexport { AssetIcon } from './AssetIcon/AssetIcon';\nexport type { AssetIconProps } from './AssetIcon/AssetIcon';\nexport type { AssetType } from './types';\nexport { isAssetType } from './types';\n","import React from 'react';\nimport { cx } from 'emotion';\nimport type {\n EntityStatus,\n PickUnion,\n CommonProps,\n} from '@contentful/f36-core';\nimport { Box, Flex } from '@contentful/f36-core';\nimport { Text } from '@contentful/f36-typography';\n\nimport { AssetIcon } from './AssetIcon/AssetIcon';\nimport { getAssetStyles } from './Asset.styles';\nimport type { AssetType } from './types';\n\nexport type AssetStatus = PickUnion<\n EntityStatus,\n 'archived' | 'changed' | 'deleted' | 'draft' | 'published'\n>;\n\nexport interface AssetProps extends CommonProps {\n /**\n * A `src` attribute to use for image assets\n */\n src?: string;\n /**\n * The publish status of the asset\n */\n status?: AssetStatus;\n /**\n * The title of the asset\n */\n title?: string;\n /**\n * The type of asset being represented\n */\n type?: AssetType;\n}\n\nexport function Asset({\n className,\n src,\n status,\n testId = 'cf-ui-asset',\n title,\n type = 'image',\n ...otherProps\n}: AssetProps) {\n const styles = getAssetStyles();\n const isImage = src && src !== '' && type === 'image';\n\n // Do not show image previews when publish status is archived\n const showPreview = isImage && status !== 'archived';\n\n return (\n <Box\n className={cx(styles.relative, className)}\n testId={testId}\n {...otherProps}\n >\n {showPreview ? (\n <>\n <Flex\n alignItems=\"center\"\n justifyContent=\"center\"\n className={styles.height100}\n >\n <img className={styles.image} src={src} alt={title} />\n </Flex>\n {title && (\n <div className={styles.titleContainer}>\n <Text\n className={styles.title}\n fontColor=\"colorWhite\"\n margin=\"spacingS\"\n isTruncated\n >\n {title}\n </Text>\n </div>\n )}\n </>\n ) : (\n <Flex\n flexDirection=\"column\"\n alignItems=\"center\"\n justifyContent=\"center\"\n paddingLeft=\"spacingS\"\n paddingRight=\"spacingS\"\n className={styles.height100}\n >\n <Flex\n marginBottom=\"spacingM\"\n marginTop=\"spacingM\"\n justifyContent=\"center\"\n >\n <AssetIcon type={type} />\n </Flex>\n <Text isTruncated marginBottom=\"spacingM\" fontColor=\"gray600\">\n {title}\n </Text>\n </Flex>\n )}\n </Box>\n );\n}\n","import React from 'react';\nimport {\n ArchiveIcon,\n AudioIcon,\n CodeIllustrationIcon,\n ImageIcon,\n MarkupIcon,\n PdfIcon,\n PlaintextIcon,\n RichtextIcon,\n PresentationIcon,\n SpreadsheetIcon,\n VideoIcon,\n} from '@contentful/f36-icons';\nimport type { GeneratedIconProps } from '@contentful/f36-icon';\nimport type { AssetType } from '../types';\n\nimport { cx } from 'emotion';\nimport { getAssetIconStyles } from './AssetIcon.styles';\n\nexport interface AssetIconProps\n extends Omit<GeneratedIconProps, 'illustration' | 'ref'> {\n type?: AssetType;\n}\n\n/**\n * Renders only the Illustration that would represent this asset's type\n */\nexport function AssetIcon({\n type = 'archive',\n className,\n testId = 'cf-ui-asset-icon',\n ...otherProps\n}: AssetIconProps) {\n const styles = getAssetIconStyles();\n const props = {\n ...otherProps,\n testId,\n className: cx(styles.root, className),\n };\n\n switch (type) {\n case 'audio':\n return <AudioIcon {...props} />;\n case 'code':\n return <CodeIllustrationIcon {...props} />;\n case 'image':\n return <ImageIcon {...props} />;\n case 'markup':\n return <MarkupIcon {...props} />;\n case 'pdf':\n return <PdfIcon {...props} />;\n case 'plaintext':\n return <PlaintextIcon {...props} />;\n case 'presentation':\n return <PresentationIcon {...props} />;\n case 'richtext':\n return <RichtextIcon {...props} />;\n case 'spreadsheet':\n return <SpreadsheetIcon {...props} />;\n case 'video':\n return <VideoIcon {...props} />;\n case 'archive':\n default:\n return <ArchiveIcon {...props} />;\n }\n}\n","import tokens from '@contentful/f36-tokens';\nimport { css } from 'emotion';\n\nexport function getAssetIconStyles() {\n return {\n root: css({\n display: 'inline-block',\n width: '39px',\n height: '39px',\n 'g, path': {\n fill: tokens.gray600,\n },\n }),\n };\n}\n","import tokens from '@contentful/f36-tokens';\nimport { css } from 'emotion';\n\nexport function getAssetStyles() {\n return {\n relative: css({\n position: 'relative',\n width: '100%',\n }),\n height100: css({\n height: '100%',\n }),\n image: css({\n width: 'auto',\n height: '100%',\n maxWidth: '100%',\n maxHeight: '100%',\n objectFit: 'contain',\n }),\n titleContainer: css({\n opacity: 0,\n transition: `opacity ${tokens.transitionDurationDefault} ${tokens.transitionEasingDefault}`,\n position: 'absolute',\n bottom: 0,\n right: 0,\n left: 0,\n height: '100%',\n display: 'flex',\n overflow: 'hidden',\n alignItems: 'flex-end',\n boxSizing: 'border-box',\n background: `linear-gradient(0deg, ${tokens.gray900} 0%, transparent calc(1rem * (100 / ${tokens.fontBaseDefault})), transparent 100% )`,\n ':hover': { opacity: 1 },\n }),\n title: css({\n bottom: 0,\n left: 0,\n right: 0,\n position: 'absolute',\n }),\n };\n}\n","export const types = {\n archive: 'archive',\n audio: 'audio',\n code: 'code',\n image: 'image',\n markup: 'markup',\n pdf: 'pdf',\n plaintext: 'plaintext',\n presentation: 'presentation',\n richtext: 'richtext',\n spreadsheet: 'spreadsheet',\n video: 'video',\n};\n\nexport function isAssetType(type: string): type is AssetType {\n return Object.keys(types).includes(type);\n}\n\nexport type AssetType = keyof typeof types;\n"],"names":["Asset","AssetProps","AssetStatus","AssetIcon","AssetIconProps","AssetType","isAssetType","React","EntityStatus","PickUnion","CommonProps","Box","Flex","Text","getAssetStyles","src","status","title","type","className","testId","otherProps","styles","isImage","showPreview","relative","height100","image","titleContainer","ArchiveIcon","AudioIcon","CodeIllustrationIcon","ImageIcon","MarkupIcon","PdfIcon","PlaintextIcon","RichtextIcon","PresentationIcon","SpreadsheetIcon","VideoIcon","GeneratedIconProps","getAssetIconStyles","Omit","props","root","tokens","display","width","height","fill","gray600","opacity","transition","transitionDurationDefault","transitionEasingDefault","position","bottom","right","left","overflow","alignItems","boxSizing","background","gray900","fontBaseDefault","types","archive","audio","code","markup","pdf","plaintext","presentation","richtext","spreadsheet","video","Object","keys","includes"],"version":3,"file":"main.js.map"}
|
package/dist/module.js
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import {cx as $dtSHR$cx, css as $dtSHR$css} from "emotion";
|
|
2
|
+
import $dtSHR$react from "react";
|
|
3
|
+
import {Box as $dtSHR$Box, Flex as $dtSHR$Flex} from "@contentful/f36-core";
|
|
4
|
+
import {Text as $dtSHR$Text} from "@contentful/f36-typography";
|
|
5
|
+
import {AudioIcon as $dtSHR$AudioIcon, CodeIllustrationIcon as $dtSHR$CodeIllustrationIcon, ImageIcon as $dtSHR$ImageIcon, MarkupIcon as $dtSHR$MarkupIcon, PdfIcon as $dtSHR$PdfIcon, PlaintextIcon as $dtSHR$PlaintextIcon, PresentationIcon as $dtSHR$PresentationIcon, RichtextIcon as $dtSHR$RichtextIcon, SpreadsheetIcon as $dtSHR$SpreadsheetIcon, VideoIcon as $dtSHR$VideoIcon, ArchiveIcon as $dtSHR$ArchiveIcon} from "@contentful/f36-icons";
|
|
6
|
+
import $dtSHR$contentfulf36tokens from "@contentful/f36-tokens";
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
function $6f9c5a7cc9575f3b$export$d4130e73e2e8f9dd() {
|
|
18
|
+
return {
|
|
19
|
+
root: /*#__PURE__*/ $dtSHR$css({
|
|
20
|
+
display: 'inline-block',
|
|
21
|
+
width: '39px',
|
|
22
|
+
height: '39px',
|
|
23
|
+
'g, path': {
|
|
24
|
+
fill: $dtSHR$contentfulf36tokens.gray600
|
|
25
|
+
}
|
|
26
|
+
})
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
function $294bba6cf7661148$export$de8d5274b07acfbd({ type: type = 'archive' , className: className , testId: testId = 'cf-ui-asset-icon' , ...otherProps }) {
|
|
32
|
+
const styles = $6f9c5a7cc9575f3b$export$d4130e73e2e8f9dd();
|
|
33
|
+
const props = {
|
|
34
|
+
...otherProps,
|
|
35
|
+
testId: testId,
|
|
36
|
+
className: $dtSHR$cx(styles.root, className)
|
|
37
|
+
};
|
|
38
|
+
switch(type){
|
|
39
|
+
case 'audio':
|
|
40
|
+
return(/*#__PURE__*/ $dtSHR$react.createElement($dtSHR$AudioIcon, props));
|
|
41
|
+
case 'code':
|
|
42
|
+
return(/*#__PURE__*/ $dtSHR$react.createElement($dtSHR$CodeIllustrationIcon, props));
|
|
43
|
+
case 'image':
|
|
44
|
+
return(/*#__PURE__*/ $dtSHR$react.createElement($dtSHR$ImageIcon, props));
|
|
45
|
+
case 'markup':
|
|
46
|
+
return(/*#__PURE__*/ $dtSHR$react.createElement($dtSHR$MarkupIcon, props));
|
|
47
|
+
case 'pdf':
|
|
48
|
+
return(/*#__PURE__*/ $dtSHR$react.createElement($dtSHR$PdfIcon, props));
|
|
49
|
+
case 'plaintext':
|
|
50
|
+
return(/*#__PURE__*/ $dtSHR$react.createElement($dtSHR$PlaintextIcon, props));
|
|
51
|
+
case 'presentation':
|
|
52
|
+
return(/*#__PURE__*/ $dtSHR$react.createElement($dtSHR$PresentationIcon, props));
|
|
53
|
+
case 'richtext':
|
|
54
|
+
return(/*#__PURE__*/ $dtSHR$react.createElement($dtSHR$RichtextIcon, props));
|
|
55
|
+
case 'spreadsheet':
|
|
56
|
+
return(/*#__PURE__*/ $dtSHR$react.createElement($dtSHR$SpreadsheetIcon, props));
|
|
57
|
+
case 'video':
|
|
58
|
+
return(/*#__PURE__*/ $dtSHR$react.createElement($dtSHR$VideoIcon, props));
|
|
59
|
+
case 'archive':
|
|
60
|
+
default:
|
|
61
|
+
return(/*#__PURE__*/ $dtSHR$react.createElement($dtSHR$ArchiveIcon, props));
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
function $dc8375c31ef26a6b$export$fa02bd03531e2fe() {
|
|
69
|
+
return {
|
|
70
|
+
relative: /*#__PURE__*/ $dtSHR$css({
|
|
71
|
+
name: "1jke4yk",
|
|
72
|
+
styles: "position:relative;width:100%;"
|
|
73
|
+
}),
|
|
74
|
+
height100: /*#__PURE__*/ $dtSHR$css({
|
|
75
|
+
name: "10klw3m",
|
|
76
|
+
styles: "height:100%;"
|
|
77
|
+
}),
|
|
78
|
+
image: /*#__PURE__*/ $dtSHR$css({
|
|
79
|
+
name: "1o9ustp",
|
|
80
|
+
styles: "width:auto;height:100%;max-width:100%;max-height:100%;object-fit:contain;"
|
|
81
|
+
}),
|
|
82
|
+
titleContainer: /*#__PURE__*/ $dtSHR$css({
|
|
83
|
+
opacity: 0,
|
|
84
|
+
transition: `opacity ${$dtSHR$contentfulf36tokens.transitionDurationDefault} ${$dtSHR$contentfulf36tokens.transitionEasingDefault}`,
|
|
85
|
+
position: 'absolute',
|
|
86
|
+
bottom: 0,
|
|
87
|
+
right: 0,
|
|
88
|
+
left: 0,
|
|
89
|
+
height: '100%',
|
|
90
|
+
display: 'flex',
|
|
91
|
+
overflow: 'hidden',
|
|
92
|
+
alignItems: 'flex-end',
|
|
93
|
+
boxSizing: 'border-box',
|
|
94
|
+
background: `linear-gradient(0deg, ${$dtSHR$contentfulf36tokens.gray900} 0%, transparent calc(1rem * (100 / ${$dtSHR$contentfulf36tokens.fontBaseDefault})), transparent 100% )`,
|
|
95
|
+
':hover': {
|
|
96
|
+
opacity: 1
|
|
97
|
+
}
|
|
98
|
+
}),
|
|
99
|
+
title: /*#__PURE__*/ $dtSHR$css({
|
|
100
|
+
name: "4gk4ib",
|
|
101
|
+
styles: "bottom:0;left:0;right:0;position:absolute;"
|
|
102
|
+
})
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
function $4a170a6eb7674988$export$c413dd039085b182({ className: className , src: src , status: status , testId: testId = 'cf-ui-asset' , title: title , type: type = 'image' , ...otherProps }) {
|
|
108
|
+
const styles = $dc8375c31ef26a6b$export$fa02bd03531e2fe();
|
|
109
|
+
const isImage = src && src !== '' && type === 'image'; // Do not show image previews when publish status is archived
|
|
110
|
+
const showPreview = isImage && status !== 'archived';
|
|
111
|
+
return(/*#__PURE__*/ $dtSHR$react.createElement($dtSHR$Box, {
|
|
112
|
+
className: $dtSHR$cx(styles.relative, className),
|
|
113
|
+
testId: testId,
|
|
114
|
+
...otherProps
|
|
115
|
+
}, showPreview ? /*#__PURE__*/ $dtSHR$react.createElement($dtSHR$react.Fragment, null, /*#__PURE__*/ $dtSHR$react.createElement($dtSHR$Flex, {
|
|
116
|
+
alignItems: "center",
|
|
117
|
+
justifyContent: "center",
|
|
118
|
+
className: styles.height100
|
|
119
|
+
}, /*#__PURE__*/ $dtSHR$react.createElement("img", {
|
|
120
|
+
className: styles.image,
|
|
121
|
+
src: src,
|
|
122
|
+
alt: title
|
|
123
|
+
})), title && /*#__PURE__*/ $dtSHR$react.createElement("div", {
|
|
124
|
+
className: styles.titleContainer
|
|
125
|
+
}, /*#__PURE__*/ $dtSHR$react.createElement($dtSHR$Text, {
|
|
126
|
+
className: styles.title,
|
|
127
|
+
fontColor: "colorWhite",
|
|
128
|
+
margin: "spacingS",
|
|
129
|
+
isTruncated: true
|
|
130
|
+
}, title))) : /*#__PURE__*/ $dtSHR$react.createElement($dtSHR$Flex, {
|
|
131
|
+
flexDirection: "column",
|
|
132
|
+
alignItems: "center",
|
|
133
|
+
justifyContent: "center",
|
|
134
|
+
paddingLeft: "spacingS",
|
|
135
|
+
paddingRight: "spacingS",
|
|
136
|
+
className: styles.height100
|
|
137
|
+
}, /*#__PURE__*/ $dtSHR$react.createElement($dtSHR$Flex, {
|
|
138
|
+
marginBottom: "spacingM",
|
|
139
|
+
marginTop: "spacingM",
|
|
140
|
+
justifyContent: "center"
|
|
141
|
+
}, /*#__PURE__*/ $dtSHR$react.createElement($294bba6cf7661148$export$de8d5274b07acfbd, {
|
|
142
|
+
type: type
|
|
143
|
+
})), /*#__PURE__*/ $dtSHR$react.createElement($dtSHR$Text, {
|
|
144
|
+
isTruncated: true,
|
|
145
|
+
marginBottom: "spacingM",
|
|
146
|
+
fontColor: "gray600"
|
|
147
|
+
}, title))));
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
const $c14cae86e9d474fd$export$b14ad400b1d09e0f = {
|
|
153
|
+
archive: 'archive',
|
|
154
|
+
audio: 'audio',
|
|
155
|
+
code: 'code',
|
|
156
|
+
image: 'image',
|
|
157
|
+
markup: 'markup',
|
|
158
|
+
pdf: 'pdf',
|
|
159
|
+
plaintext: 'plaintext',
|
|
160
|
+
presentation: 'presentation',
|
|
161
|
+
richtext: 'richtext',
|
|
162
|
+
spreadsheet: 'spreadsheet',
|
|
163
|
+
video: 'video'
|
|
164
|
+
};
|
|
165
|
+
function $c14cae86e9d474fd$export$3ccaa71e0816392d(type) {
|
|
166
|
+
return Object.keys($c14cae86e9d474fd$export$b14ad400b1d09e0f).includes(type);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
export {$4a170a6eb7674988$export$c413dd039085b182 as Asset, $294bba6cf7661148$export$de8d5274b07acfbd as AssetIcon, $c14cae86e9d474fd$export$3ccaa71e0816392d as isAssetType};
|
|
173
|
+
//# sourceMappingURL=module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;SGGgByC,yCAAT,GAA8B,CAArC;IACE,MAAA,CAAO,CAAP;QACEG,IAAI,EAAA,EAAE,AAAF,SAAE,AAAF,EAAE,CAAA,UAAA,CAAI,CAAVA;YACEE,OAAO,EAAE,CADD;YAERC,KAAK,EAAE,CAFC;YAGRC,MAAM,EAAE,CAHA;YAIR,CAAA,UAAW,CAAX;gBACEC,IAAI,EAAEJ,0BAAM,CAACK,OAAbD;YADS,CAAA;QAJH,CAAJ;IADD,CAAP;AAUD,CAAA;;;SDce9C,yCAAT,CAAmB,CAA1B,OACEe,IAAI,GAAG,CADiB,sBAExBC,SAFwB,WAGxBC,MAAM,GAAG,CAHe,uBAIrBC,UAAH,CACCjB,CALI,EAKY,CALO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InBzC,KAAK,EAAE,CAJY;IAKnB0C,MAAM,EAAE,CALW;IAMnBC,GAAG,EAAE,CANc;IAOnBC,SAAS,EAAE,CAPQ;IAQnBC,YAAY,EAAE,CARK;IASnBC,QAAQ,EAAE,CATS;IAUnBC,WAAW,EAAE,CAVM;IAWnBC,KAAK,EAAE,CAAPA;AAXmB,CAAd;SAcSrE,yCAAT,CAAqBY,IAArB,EAAsD,CAA7D;IACE,MAAA,CAAO0D,MAAM,CAACC,IAAP,CAAYZ,yCAAZ,EAAmBa,QAAnB,CAA4B5D,IAA5B;AACR,CAAA;;","sources":["packages/components/asset/src/index.ts","packages/components/asset/src/Asset.tsx","packages/components/asset/src/AssetIcon/AssetIcon.tsx","packages/components/asset/src/AssetIcon/AssetIcon.styles.ts","packages/components/asset/src/Asset.styles.ts","packages/components/asset/src/types.ts"],"sourcesContent":["export { Asset } from './Asset';\nexport type { AssetProps, AssetStatus } from './Asset';\nexport { AssetIcon } from './AssetIcon/AssetIcon';\nexport type { AssetIconProps } from './AssetIcon/AssetIcon';\nexport type { AssetType } from './types';\nexport { isAssetType } from './types';\n","import React from 'react';\nimport { cx } from 'emotion';\nimport type {\n EntityStatus,\n PickUnion,\n CommonProps,\n} from '@contentful/f36-core';\nimport { Box, Flex } from '@contentful/f36-core';\nimport { Text } from '@contentful/f36-typography';\n\nimport { AssetIcon } from './AssetIcon/AssetIcon';\nimport { getAssetStyles } from './Asset.styles';\nimport type { AssetType } from './types';\n\nexport type AssetStatus = PickUnion<\n EntityStatus,\n 'archived' | 'changed' | 'deleted' | 'draft' | 'published'\n>;\n\nexport interface AssetProps extends CommonProps {\n /**\n * A `src` attribute to use for image assets\n */\n src?: string;\n /**\n * The publish status of the asset\n */\n status?: AssetStatus;\n /**\n * The title of the asset\n */\n title?: string;\n /**\n * The type of asset being represented\n */\n type?: AssetType;\n}\n\nexport function Asset({\n className,\n src,\n status,\n testId = 'cf-ui-asset',\n title,\n type = 'image',\n ...otherProps\n}: AssetProps) {\n const styles = getAssetStyles();\n const isImage = src && src !== '' && type === 'image';\n\n // Do not show image previews when publish status is archived\n const showPreview = isImage && status !== 'archived';\n\n return (\n <Box\n className={cx(styles.relative, className)}\n testId={testId}\n {...otherProps}\n >\n {showPreview ? (\n <>\n <Flex\n alignItems=\"center\"\n justifyContent=\"center\"\n className={styles.height100}\n >\n <img className={styles.image} src={src} alt={title} />\n </Flex>\n {title && (\n <div className={styles.titleContainer}>\n <Text\n className={styles.title}\n fontColor=\"colorWhite\"\n margin=\"spacingS\"\n isTruncated\n >\n {title}\n </Text>\n </div>\n )}\n </>\n ) : (\n <Flex\n flexDirection=\"column\"\n alignItems=\"center\"\n justifyContent=\"center\"\n paddingLeft=\"spacingS\"\n paddingRight=\"spacingS\"\n className={styles.height100}\n >\n <Flex\n marginBottom=\"spacingM\"\n marginTop=\"spacingM\"\n justifyContent=\"center\"\n >\n <AssetIcon type={type} />\n </Flex>\n <Text isTruncated marginBottom=\"spacingM\" fontColor=\"gray600\">\n {title}\n </Text>\n </Flex>\n )}\n </Box>\n );\n}\n","import React from 'react';\nimport {\n ArchiveIcon,\n AudioIcon,\n CodeIllustrationIcon,\n ImageIcon,\n MarkupIcon,\n PdfIcon,\n PlaintextIcon,\n RichtextIcon,\n PresentationIcon,\n SpreadsheetIcon,\n VideoIcon,\n} from '@contentful/f36-icons';\nimport type { GeneratedIconProps } from '@contentful/f36-icon';\nimport type { AssetType } from '../types';\n\nimport { cx } from 'emotion';\nimport { getAssetIconStyles } from './AssetIcon.styles';\n\nexport interface AssetIconProps\n extends Omit<GeneratedIconProps, 'illustration' | 'ref'> {\n type?: AssetType;\n}\n\n/**\n * Renders only the Illustration that would represent this asset's type\n */\nexport function AssetIcon({\n type = 'archive',\n className,\n testId = 'cf-ui-asset-icon',\n ...otherProps\n}: AssetIconProps) {\n const styles = getAssetIconStyles();\n const props = {\n ...otherProps,\n testId,\n className: cx(styles.root, className),\n };\n\n switch (type) {\n case 'audio':\n return <AudioIcon {...props} />;\n case 'code':\n return <CodeIllustrationIcon {...props} />;\n case 'image':\n return <ImageIcon {...props} />;\n case 'markup':\n return <MarkupIcon {...props} />;\n case 'pdf':\n return <PdfIcon {...props} />;\n case 'plaintext':\n return <PlaintextIcon {...props} />;\n case 'presentation':\n return <PresentationIcon {...props} />;\n case 'richtext':\n return <RichtextIcon {...props} />;\n case 'spreadsheet':\n return <SpreadsheetIcon {...props} />;\n case 'video':\n return <VideoIcon {...props} />;\n case 'archive':\n default:\n return <ArchiveIcon {...props} />;\n }\n}\n","import tokens from '@contentful/f36-tokens';\nimport { css } from 'emotion';\n\nexport function getAssetIconStyles() {\n return {\n root: css({\n display: 'inline-block',\n width: '39px',\n height: '39px',\n 'g, path': {\n fill: tokens.gray600,\n },\n }),\n };\n}\n","import tokens from '@contentful/f36-tokens';\nimport { css } from 'emotion';\n\nexport function getAssetStyles() {\n return {\n relative: css({\n position: 'relative',\n width: '100%',\n }),\n height100: css({\n height: '100%',\n }),\n image: css({\n width: 'auto',\n height: '100%',\n maxWidth: '100%',\n maxHeight: '100%',\n objectFit: 'contain',\n }),\n titleContainer: css({\n opacity: 0,\n transition: `opacity ${tokens.transitionDurationDefault} ${tokens.transitionEasingDefault}`,\n position: 'absolute',\n bottom: 0,\n right: 0,\n left: 0,\n height: '100%',\n display: 'flex',\n overflow: 'hidden',\n alignItems: 'flex-end',\n boxSizing: 'border-box',\n background: `linear-gradient(0deg, ${tokens.gray900} 0%, transparent calc(1rem * (100 / ${tokens.fontBaseDefault})), transparent 100% )`,\n ':hover': { opacity: 1 },\n }),\n title: css({\n bottom: 0,\n left: 0,\n right: 0,\n position: 'absolute',\n }),\n };\n}\n","export const types = {\n archive: 'archive',\n audio: 'audio',\n code: 'code',\n image: 'image',\n markup: 'markup',\n pdf: 'pdf',\n plaintext: 'plaintext',\n presentation: 'presentation',\n richtext: 'richtext',\n spreadsheet: 'spreadsheet',\n video: 'video',\n};\n\nexport function isAssetType(type: string): type is AssetType {\n return Object.keys(types).includes(type);\n}\n\nexport type AssetType = keyof typeof types;\n"],"names":["Asset","AssetProps","AssetStatus","AssetIcon","AssetIconProps","AssetType","isAssetType","React","EntityStatus","PickUnion","CommonProps","Box","Flex","Text","getAssetStyles","src","status","title","type","className","testId","otherProps","styles","isImage","showPreview","relative","height100","image","titleContainer","ArchiveIcon","AudioIcon","CodeIllustrationIcon","ImageIcon","MarkupIcon","PdfIcon","PlaintextIcon","RichtextIcon","PresentationIcon","SpreadsheetIcon","VideoIcon","GeneratedIconProps","getAssetIconStyles","Omit","props","root","tokens","display","width","height","fill","gray600","opacity","transition","transitionDurationDefault","transitionEasingDefault","position","bottom","right","left","overflow","alignItems","boxSizing","background","gray900","fontBaseDefault","types","archive","audio","code","markup","pdf","plaintext","presentation","richtext","spreadsheet","video","Object","keys","includes"],"version":3,"file":"module.js.map"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { GeneratedIconProps } from "@contentful/f36-icon";
|
|
2
|
+
import { EntityStatus, PickUnion, CommonProps } from "@contentful/f36-core";
|
|
3
|
+
declare const types: {
|
|
4
|
+
archive: string;
|
|
5
|
+
audio: string;
|
|
6
|
+
code: string;
|
|
7
|
+
image: string;
|
|
8
|
+
markup: string;
|
|
9
|
+
pdf: string;
|
|
10
|
+
plaintext: string;
|
|
11
|
+
presentation: string;
|
|
12
|
+
richtext: string;
|
|
13
|
+
spreadsheet: string;
|
|
14
|
+
video: string;
|
|
15
|
+
};
|
|
16
|
+
export function isAssetType(type: string): type is AssetType;
|
|
17
|
+
export type AssetType = keyof typeof types;
|
|
18
|
+
export interface AssetIconProps extends Omit<GeneratedIconProps, 'illustration' | 'ref'> {
|
|
19
|
+
type?: AssetType;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Renders only the Illustration that would represent this asset's type
|
|
23
|
+
*/
|
|
24
|
+
export function AssetIcon({ type, className, testId, ...otherProps }: AssetIconProps): JSX.Element;
|
|
25
|
+
export type AssetStatus = PickUnion<EntityStatus, 'archived' | 'changed' | 'deleted' | 'draft' | 'published'>;
|
|
26
|
+
export interface AssetProps extends CommonProps {
|
|
27
|
+
/**
|
|
28
|
+
* A `src` attribute to use for image assets
|
|
29
|
+
*/
|
|
30
|
+
src?: string;
|
|
31
|
+
/**
|
|
32
|
+
* The publish status of the asset
|
|
33
|
+
*/
|
|
34
|
+
status?: AssetStatus;
|
|
35
|
+
/**
|
|
36
|
+
* The title of the asset
|
|
37
|
+
*/
|
|
38
|
+
title?: string;
|
|
39
|
+
/**
|
|
40
|
+
* The type of asset being represented
|
|
41
|
+
*/
|
|
42
|
+
type?: AssetType;
|
|
43
|
+
}
|
|
44
|
+
export function Asset({ className, src, status, testId, title, type, ...otherProps }: AssetProps): JSX.Element;
|
|
45
|
+
|
|
46
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;AAAA,QAAO,MAAM;;;;;;;;;;;;CAYZ,CAAC;AAEF,4BAA4B,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,SAAS,CAE3D;AAED,wBAAwB,MAAM,YAAY,CAAC;AEE3C,+BACE,SAAQ,IAAI,CAAC,kBAAkB,EAAE,cAAc,GAAG,KAAK,CAAC;IACxD,IAAI,CAAC,EAAE,SAAS,CAAC;CAClB;AAED;;GAEG;AACH,0BAA0B,EACxB,IAAgB,EAChB,SAAS,EACT,MAA2B,EAC3B,GAAG,UAAU,EACd,EAAE,cAAc,eAiChB;AEpDD,0BAA0B,UACxB,YAAY,EACZ,UAAU,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,WAAW,CAC3D,CAAC;AAEF,2BAA4B,SAAQ,WAAW;IAC7C;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,IAAI,CAAC,EAAE,SAAS,CAAC;CAClB;AAED,sBAAsB,EACpB,SAAS,EACT,GAAG,EACH,MAAM,EACN,MAAsB,EACtB,KAAK,EACL,IAAc,EACd,GAAG,UAAU,EACd,EAAE,UAAU,eA0DZ","sources":["packages/components/asset/src/src/types.ts","packages/components/asset/src/src/AssetIcon/AssetIcon.styles.ts","packages/components/asset/src/src/AssetIcon/AssetIcon.tsx","packages/components/asset/src/src/Asset.styles.ts","packages/components/asset/src/src/Asset.tsx","packages/components/asset/src/src/index.ts","packages/components/asset/src/index.ts"],"sourcesContent":[null,null,null,null,null,null,"export { Asset } from './Asset';\nexport type { AssetProps, AssetStatus } from './Asset';\nexport { AssetIcon } from './AssetIcon/AssetIcon';\nexport type { AssetIconProps } from './AssetIcon/AssetIcon';\nexport type { AssetType } from './types';\nexport { isAssetType } from './types';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@contentful/f36-asset",
|
|
3
|
+
"version": "4.0.0",
|
|
4
|
+
"description": "Forma 36: Asset component",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"build": "parcel build"
|
|
7
|
+
},
|
|
8
|
+
"dependencies": {
|
|
9
|
+
"@babel/runtime": "^7.6.2",
|
|
10
|
+
"@contentful/f36-core": "^4.0.0",
|
|
11
|
+
"@contentful/f36-icon": "^4.0.0",
|
|
12
|
+
"@contentful/f36-icons": "^4.0.0",
|
|
13
|
+
"@contentful/f36-tokens": "^4.0.0",
|
|
14
|
+
"@contentful/f36-typography": "^4.0.0",
|
|
15
|
+
"emotion": "^10.0.17"
|
|
16
|
+
},
|
|
17
|
+
"peerDependencies": {
|
|
18
|
+
"react": ">=16.8"
|
|
19
|
+
},
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"files": [
|
|
22
|
+
"dist"
|
|
23
|
+
],
|
|
24
|
+
"main": "dist/main.js",
|
|
25
|
+
"module": "dist/module.js",
|
|
26
|
+
"types": "dist/types.d.ts",
|
|
27
|
+
"source": "src/index.ts",
|
|
28
|
+
"sideEffects": false,
|
|
29
|
+
"browserslist": "extends @contentful/browserslist-config",
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "https://github.com/contentful/forma-36"
|
|
33
|
+
},
|
|
34
|
+
"publishConfig": {
|
|
35
|
+
"access": "public"
|
|
36
|
+
},
|
|
37
|
+
"gitHead": "01d931c77410619d05cd00dbb3b5acc5d8ae2cdf"
|
|
38
|
+
}
|