@arcblock/ux 2.1.66 → 2.1.69

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/lib/Datatable/TableSearch.js +5 -16
  2. package/lib/Locale/selector.js +13 -13
  3. package/package.json +4 -8
  4. package/src/Datatable/TableSearch.js +5 -14
  5. package/src/Locale/selector.js +5 -8
  6. package/lib/Locale/images/globe-dark.png +0 -0
  7. package/lib/Locale/images/globe-light.png +0 -0
  8. package/src/ActionButton/ActionButton.stories.js +0 -63
  9. package/src/ActivityIndicator/ActivityIndicator.stories.js +0 -9
  10. package/src/ActivityIndicator/demo/basic.js +0 -5
  11. package/src/ActivityIndicator/demo/with-custom-messages.js +0 -5
  12. package/src/Alert/Alert.stories.js +0 -100
  13. package/src/AnimationWaiter/AnimationWaiter.stories.js +0 -22
  14. package/src/AnimationWaiter/demo/basic.js +0 -5
  15. package/src/AnimationWaiter/demo/sizes.js +0 -11
  16. package/src/AnimationWaiter/demo/with-custom-messages.js +0 -5
  17. package/src/AnimationWaiter/demo/with-maybe-duration.js +0 -11
  18. package/src/AnimationWaiter/demo/with-more-messages.js +0 -22
  19. package/src/AnimationWaiter/demo/with-speed.js +0 -18
  20. package/src/AnimationWaiter/demo/with-tips.js +0 -22
  21. package/src/Badge/Badge.stories.js +0 -41
  22. package/src/Blocklet/Blocklet.stories.js +0 -17
  23. package/src/Blocklet/demo/basic.js +0 -102
  24. package/src/BlockletNFT/BlockletNFT.stories.js +0 -17
  25. package/src/BlockletNFT/demo/basic.js +0 -131
  26. package/src/ClickToCopy/ClickToCopy.stories.js +0 -23
  27. package/src/ClickToCopy/demo/basic.js +0 -9
  28. package/src/ClickToCopy/demo/copy-button.js +0 -28
  29. package/src/ClickToCopy/demo/with-complex-child.js +0 -9
  30. package/src/ClickToCopy/demo/with-custom-parent-font-color.js +0 -9
  31. package/src/ContactForm/ContactForm.stories.js +0 -32
  32. package/src/Earth/Earth.stories.js +0 -39
  33. package/src/Empty/Empty.stories.js +0 -23
  34. package/src/Empty/demo/basic.js +0 -5
  35. package/src/Empty/demo/complex-message.js +0 -13
  36. package/src/Empty/demo/custom-message.js +0 -5
  37. package/src/Icon/Icon.stories.js +0 -45
  38. package/src/Locale/images/globe-dark.png +0 -0
  39. package/src/Locale/images/globe-light.png +0 -0
  40. package/src/NFTDisplay/NFTDisplay.stories.js +0 -16
  41. package/src/NFTDisplay/demo/aspect-ratio.js +0 -33
  42. package/src/NFTDisplay/demo/basic.js +0 -15
  43. package/src/NFTDisplay/demo/broken-image.js +0 -84
  44. package/src/NFTDisplay/demo/custom-loading.js +0 -45
  45. package/src/NFTDisplay/demo/data/asset-state-display-url.json +0 -7
  46. package/src/NFTDisplay/demo/data/asset-state-gzipped-svg-1-1.json +0 -10
  47. package/src/NFTDisplay/demo/data/asset-state-gzipped-svg-374-130.json +0 -10
  48. package/src/NFTDisplay/demo/data/asset-state-gzipped-svg-with-foreign-object.json +0 -20
  49. package/src/NFTDisplay/demo/data/asset-state-svg.json +0 -29
  50. package/src/NFTDisplay/demo/data/asset-state-url.json +0 -10
  51. package/src/NFTDisplay/demo/fixed-size.js +0 -24
  52. package/src/NFTDisplay/demo/inset.js +0 -23
  53. package/src/NFTDisplay/demo/minimum-loading-time.js +0 -68
  54. package/src/NFTDisplay/demo/nft-type-svg.js +0 -13
  55. package/src/NFTDisplay/demo/nft-type-url.js +0 -26
  56. package/src/NFTDisplay/demo/preferred-svg-embedder-prop.js +0 -22
  57. package/src/NFTDisplay/demo/svg-validation.js +0 -23
  58. package/src/NFTDisplay/demo/with-foreign-object.js +0 -27
  59. package/src/PageScroller/story/PageScroller.stories.js +0 -18
  60. package/src/PricingTable/PricingTable.stories.js +0 -38
  61. package/src/Spinner/Spinner.stories.js +0 -67
  62. package/src/SplitButton/SplitButton.stories.js +0 -24
  63. package/src/SplitButton/demo/basic.js +0 -9
  64. package/src/TextCollapse/TextCollapse.stories.js +0 -73
@@ -1,102 +0,0 @@
1
- /* eslint-disable react/jsx-no-bind */
2
- import styled from 'styled-components';
3
- import { Grid, Box } from '@mui/material';
4
- import withTheme from '../../withTheme';
5
- import Button from '../../Button';
6
- import Blocklet, { ActionButton } from '..';
7
-
8
- const TempBlocklet = withTheme(Blocklet);
9
- const ThemedBlocklet = styled(TempBlocklet)`
10
- .arcblock-blocklet__button {
11
- color: blue;
12
- }
13
- `;
14
- const StyledButton = styled(Button)`
15
- &.MuiButton-root {
16
- overflow: hidden;
17
- text-overflow: ellipsis;
18
- white-space: nowrap;
19
- max-width: 86px;
20
- display: inline-block;
21
- }
22
- `;
23
- function echoMsg(msg) {
24
- // eslint-disable-next-line no-alert
25
- alert(msg);
26
- }
27
-
28
- export default function Basic() {
29
- function onButtonClick(e) {
30
- if (e) {
31
- e.preventDefault();
32
- e.stopPropagation();
33
- }
34
- echoMsg('click button');
35
- }
36
- function onClick() {
37
- echoMsg('click main');
38
- }
39
- function onClickLink(e) {
40
- e.preventDefault();
41
- e.stopPropagation();
42
- echoMsg('click link');
43
- return false;
44
- }
45
- return (
46
- <Box>
47
- <Grid container>
48
- <Grid item lg={4} md={6} sm={6} xs={12}>
49
- <ThemedBlocklet
50
- title="default blocklet"
51
- description="中文自私不是一个人按照他自己的意愿生活,而是要求别人按照他的意愿生活。"
52
- buttonText="99999.99 ABT"
53
- onButtonClick={onButtonClick}
54
- onMainClick={onClick}
55
- version="1.0.0"
56
- did="z8iZasdfMgmMHWgbhZuVDZgRPAa9Ktido123"
57
- />
58
- </Grid>
59
- <Grid item lg={4} md={6} sm={6} xs={12}>
60
- <ThemedBlocklet
61
- title="default blocklet"
62
- description="中文自私]。"
63
- buttonText="99999.99 ABT"
64
- did="z8iZasdfMgmMHWgbhZuVDZgRPAa9Ktido124"
65
- onButtonClick={onButtonClick}
66
- onMainClick={onClick}
67
- version="1.0.0"
68
- />
69
- </Grid>
70
- <Grid item lg={4} md={6} sm={6} xs={12}>
71
- <ThemedBlocklet
72
- title="did logo for blocklet loogggggggggggggggggggggggashdahsjdkhasdhajkshk"
73
- description="This is a blocklet card demo, this is very long. So it have to be ellipsis, it should works well"
74
- did="z8iZasdfMgmMHWgbhZuVDZgRPAa9Ktido125"
75
- buttonText="Purchase"
76
- onButtonClick={onButtonClick}
77
- onMainClick={onClick}
78
- version="1.0.0"
79
- />
80
- </Grid>
81
- <Grid item lg={4} md={6} sm={6} xs={12}>
82
- <a href="/" onClick={onClickLink} style={{ color: 'initial' }}>
83
- <ThemedBlocklet
84
- title="custom button for blocklet"
85
- description="This is a blocklet card demo, this is very long. So it have to be ellipsis, it should works well"
86
- cover="https://temp.im/80x80"
87
- button={
88
- <ActionButton>
89
- <StyledButton title={8888.88} color="primary" variant="outlined" size="small" onClick={onButtonClick}>
90
- 8888.88 ABT + 1000 Play3
91
- </StyledButton>
92
- </ActionButton>
93
- }
94
- onMainClick={onClick}
95
- version="1.0.0"
96
- />
97
- </a>
98
- </Grid>
99
- </Grid>
100
- </Box>
101
- );
102
- }
@@ -1,17 +0,0 @@
1
- import Basic from './demo/basic';
2
-
3
- export default {
4
- title: 'UX/BlockletNFT',
5
-
6
- parameters: {
7
- docs: {
8
- description: {
9
- component: 'BlockletNFT component is used to display Blocklet NFT Information',
10
- },
11
- },
12
- },
13
- };
14
-
15
- Basic.storyName = 'BlockletNFT';
16
-
17
- export { Basic };
@@ -1,131 +0,0 @@
1
- /* eslint-disable react/jsx-no-bind */
2
- import styled from 'styled-components';
3
-
4
- import withTheme from '../../withTheme';
5
- import { ActionButton } from '../../Blocklet';
6
- import BlockletNFT from '..';
7
- import Button from '../../Button';
8
-
9
- const TempBlockletNFT = withTheme(BlockletNFT);
10
- const Container = styled.div`
11
- margin-bottom: 40px;
12
- `;
13
-
14
- const StyledButton = styled(Button)`
15
- &.MuiButton-root {
16
- overflow: hidden;
17
- text-overflow: ellipsis;
18
- white-space: nowrap;
19
- max-width: 86px;
20
- display: inline-block;
21
- }
22
- `;
23
-
24
- function echoMsg(msg) {
25
- // eslint-disable-next-line no-alert
26
- alert(msg);
27
- }
28
-
29
- export default function Basic() {
30
- function onButtonClick(e) {
31
- if (e) {
32
- e.preventDefault();
33
- e.stopPropagation();
34
- }
35
- echoMsg('click button');
36
- }
37
- function onClick() {
38
- echoMsg('click main');
39
- }
40
- function onClickLink(e) {
41
- e.preventDefault();
42
- e.stopPropagation();
43
- echoMsg('click link');
44
- return false;
45
- }
46
- return (
47
- <div style={{ padding: '30px', maxWidth: 480 }}>
48
- <Container>
49
- <h2>size-auto(NFT)</h2>
50
- <a href="/" onClick={onClickLink} style={{ color: 'initial' }}>
51
- <TempBlockletNFT
52
- title="Blocklet Card (I'm loooooooong)"
53
- description="This is a blocklet card demo, this is very long. So it have to be ellipsis, it should works well"
54
- cover="https://temp.im/100x100"
55
- buttonText="Open"
56
- addons={[
57
- { icon: 'clock', value: '2021-04-29' },
58
- { icon: 'store', value: 123456, pretty: true },
59
- { icon: 'shopping-bag', value: 123456, pretty: true },
60
- ]}
61
- button={
62
- <Button variant="contained" color="error" size="small" rounded disabled onClick={onButtonClick}>
63
- Custom
64
- </Button>
65
- }
66
- onMainClick={onClick}
67
- isStickyButton
68
- />
69
- </a>
70
- </Container>
71
- <Container>
72
- <h2>size-auto(NFT)outter link (现在应该没有这种情况了)</h2>
73
- <a href="/" onClick={onClickLink} style={{ color: 'initial' }}>
74
- <TempBlockletNFT
75
- title="Blocklet Card (I'm loooooooong)"
76
- description="This is a blocklet card demo, this is very long. So it have to be ellipsis, it should works well"
77
- type="nft"
78
- buttonText="Open"
79
- addons={[
80
- { icon: 'clock', value: '2021-04-29' },
81
- { icon: 'store', value: 123456, pretty: true },
82
- { icon: 'shopping-bag', value: 123456, pretty: true },
83
- ]}
84
- onButtonClick={onButtonClick}
85
- isStickyButton
86
- buttonLoading
87
- />
88
- </a>
89
- </Container>
90
- <Container>
91
- <h2>size-auto(NFT)disabled</h2>
92
- <TempBlockletNFT
93
- title="Blocklet Card (I'm loooooooong)"
94
- description="This is a blocklet card demo, this is very long. So it have to be ellipsis, it should works well"
95
- type="nft"
96
- buttonText="Open"
97
- did="z8iZasdfMgmMHWgbhZuVDZgRPAa9Ktido123"
98
- addons={[{ icon: 'clock', value: '2021-04-29' }, { empty: true }, { empty: true }]}
99
- onButtonClick={onButtonClick}
100
- onMainClick={onClick}
101
- buttonDisabled
102
- isStickyButton
103
- />
104
- </Container>
105
- <Container>
106
- <h2>custom button</h2>
107
- <a href="/" onClick={onClickLink} style={{ color: 'initial' }}>
108
- <TempBlockletNFT
109
- title="Blocklet Card (I'm loooooooong)"
110
- description="This is a blocklet card demo, this is very long. So it have to be ellipsis, it should works well"
111
- cover="https://temp.im/64x64"
112
- addons={[
113
- { icon: 'clock', value: '2021-04-29' },
114
- { icon: 'store', value: 123456, pretty: true },
115
- { icon: 'shopping-bag', value: 123456, pretty: true },
116
- ]}
117
- button={
118
- <ActionButton>
119
- <StyledButton title={8888.88} color="primary" variant="outlined" size="small" onClick={onButtonClick}>
120
- 8888.88 ABT + 1000 Play3
121
- </StyledButton>
122
- </ActionButton>
123
- }
124
- onMainClick={onClick}
125
- version="1.0.0"
126
- />
127
- </a>
128
- </Container>
129
- </div>
130
- );
131
- }
@@ -1,23 +0,0 @@
1
- import Basic from './demo/basic';
2
- import WithComplexChild from './demo/with-complex-child';
3
- import WithCustomParentFontColor from './demo/with-custom-parent-font-color';
4
- import CopyButton from './demo/copy-button';
5
-
6
- export default {
7
- title: 'UX/ClickToCopy',
8
-
9
- parameters: {
10
- docs: {
11
- description: {
12
- component: 'ClickToCopy allows the content that is wrapped in it to be copied with a single click.',
13
- },
14
- },
15
- },
16
- };
17
-
18
- Basic.argTypes = {
19
- locale: { control: 'select', options: ['en', 'zh'] },
20
- tip: { control: 'text' },
21
- };
22
-
23
- export { Basic, WithComplexChild, WithCustomParentFontColor, CopyButton };
@@ -1,9 +0,0 @@
1
- import ClickToCopy from '..';
2
-
3
- export default function Demo(props) {
4
- return (
5
- <ClickToCopy locale="en" tip="custom tooltip message" {...props}>
6
- copy this message
7
- </ClickToCopy>
8
- );
9
- }
@@ -1,28 +0,0 @@
1
- import Box from '@mui/material/Box';
2
- import Divider from '@mui/material/Divider';
3
- import { CopyButton } from '..';
4
-
5
- export default function Demo() {
6
- const text = 'copy this message';
7
- return (
8
- <div>
9
- <Box display="flex" alignItems="center" style={{ color: '#999' }}>
10
- <span>{text}</span>
11
- <CopyButton locale="en" content={text} style={{ marginLeft: 4 }} />
12
- </Box>
13
-
14
- <Divider sx={{ my: 2 }} />
15
-
16
- <CopyButton
17
- locale="zh"
18
- style={{ marginLeft: 4 }}
19
- render={({ copyButton, containerRef }) => (
20
- <Box ref={containerRef} display="flex" alignItems="center" style={{ color: '#999' }}>
21
- <span>{text} (CopyButton#render prop)</span>
22
- {copyButton}
23
- </Box>
24
- )}
25
- />
26
- </div>
27
- );
28
- }
@@ -1,9 +0,0 @@
1
- import ClickToCopy from '..';
2
-
3
- export default function Demo() {
4
- return (
5
- <ClickToCopy>
6
- <span>I am the content from inner span</span>
7
- </ClickToCopy>
8
- );
9
- }
@@ -1,9 +0,0 @@
1
- import ClickToCopy from '..';
2
-
3
- export default function Demo() {
4
- return (
5
- <div style={{ color: 'red' }}>
6
- <ClickToCopy>custom tooltip message</ClickToCopy>
7
- </div>
8
- );
9
- }
@@ -1,32 +0,0 @@
1
- import ContactForm from '.';
2
- import withTheme from '../withTheme';
3
-
4
- const ThemedContactForm = withTheme(ContactForm);
5
-
6
- export default {
7
- title: 'Deprecated/ContactForm',
8
- };
9
-
10
- export function VerticalLayout() {
11
- return <ThemedContactForm />;
12
- }
13
-
14
- VerticalLayout.storyName = 'vertical layout';
15
-
16
- export function HorizontalLayout() {
17
- return <ThemedContactForm layout="horizontal" />;
18
- }
19
-
20
- HorizontalLayout.storyName = 'horizontal layout';
21
-
22
- export function WithoutTitle() {
23
- return <ThemedContactForm layout="vertical" title="" />;
24
- }
25
-
26
- WithoutTitle.storyName = 'without title';
27
-
28
- export function CustomizeFields() {
29
- return <ThemedContactForm layout="horizontal" fields={['Email', 'Name']} />;
30
- }
31
-
32
- CustomizeFields.storyName = 'customize fields';
@@ -1,39 +0,0 @@
1
- import AsyncComponent from '../Async';
2
-
3
- const Earth = AsyncComponent(() => import('.'));
4
-
5
- export default {
6
- title: 'Deprecated/Earth',
7
-
8
- parameters: {
9
- readme: {
10
- sidebar: '<!-- PROPS -->',
11
- },
12
- },
13
- };
14
-
15
- export function DarkMode() {
16
- return (
17
- <div
18
- style={{
19
- background: '#222',
20
- }}>
21
- <Earth theme="dark" width={600} enableRotation />
22
- </div>
23
- );
24
- }
25
-
26
- DarkMode.storyName = 'dark mode';
27
-
28
- export function LightMode() {
29
- return (
30
- <div
31
- style={{
32
- background: 'transparent',
33
- }}>
34
- <Earth theme="light" width={600} enableRotation />
35
- </div>
36
- );
37
- }
38
-
39
- LightMode.storyName = 'light mode';
@@ -1,23 +0,0 @@
1
- import Empty from './index';
2
-
3
- import Basic from './demo/basic';
4
- import CustomMessage from './demo/custom-message';
5
- import ComplexMessage from './demo/complex-message';
6
-
7
- export default {
8
- title: 'UX/Empty',
9
- component: Empty,
10
- parameters: {
11
- docs: {
12
- description: {
13
- component: 'Empty provides a generic "Empty Content" placeholder.',
14
- },
15
- },
16
- },
17
- };
18
-
19
- Basic.parameters = {
20
- layout: 'fullscreen',
21
- };
22
-
23
- export { Basic, CustomMessage, ComplexMessage };
@@ -1,5 +0,0 @@
1
- import Empty from '..';
2
-
3
- export default function Basic() {
4
- return <Empty />;
5
- }
@@ -1,13 +0,0 @@
1
- import Button from '@mui/material/Button';
2
- import Empty from '..';
3
-
4
- export default function ComplexMessage() {
5
- return (
6
- <Empty>
7
- {/* eslint-disable-next-line no-alert */}
8
- <Button color="primary" variant="outlined" size="small" onClick={() => alert('click button')}>
9
- 点击刷新
10
- </Button>
11
- </Empty>
12
- );
13
- }
@@ -1,5 +0,0 @@
1
- import Empty from '..';
2
-
3
- export default function CustomMessage() {
4
- return <Empty>no more data</Empty>;
5
- }
@@ -1,45 +0,0 @@
1
- import Icon from '.';
2
-
3
- export default {
4
- title: 'Deprecated/Icon',
5
-
6
- parameters: {
7
- readme: {
8
- sidebar: '<!-- PROPS -->',
9
- },
10
- },
11
- };
12
-
13
- export function WithDifferentNames() {
14
- return (
15
- <div style={{ display: 'flex', width: '300px', justifyContent: 'space-between' }}>
16
- <Icon name="box" />
17
- <Icon name="cut" />
18
- <Icon name="copy" />
19
- <Icon name="file" />
20
- </div>
21
- );
22
- }
23
-
24
- WithDifferentNames.storyName = 'with different names';
25
-
26
- export function WithDifferentSizes() {
27
- return (
28
- <div style={{ display: 'flex', width: '300px', justifyContent: 'space-between' }}>
29
- <Icon name="box" />
30
- <Icon name="box" size={50} />
31
- </div>
32
- );
33
- }
34
-
35
- WithDifferentSizes.storyName = 'with different sizes';
36
-
37
- export function WithRounded() {
38
- return (
39
- <div style={{ display: 'flex', width: '300px', justifyContent: 'space-between' }}>
40
- <Icon name="box" rounded />
41
- </div>
42
- );
43
- }
44
-
45
- WithRounded.storyName = 'with rounded';
Binary file
Binary file
@@ -1,16 +0,0 @@
1
- export { default as Basic } from './demo/basic';
2
- export { default as FixedSize } from './demo/fixed-size';
3
- export { default as Inset } from './demo/inset';
4
- export { default as AspectRatio } from './demo/aspect-ratio';
5
- export { default as NftTypeUrl } from './demo/nft-type-url';
6
- export { default as MinimumLoadingTime } from './demo/minimum-loading-time';
7
- export { default as WithForeignObject } from './demo/with-foreign-object';
8
- export { default as NftTypeSvg } from './demo/nft-type-svg';
9
- export { default as CustomLoading } from './demo/custom-loading';
10
- export { default as SvgValidation } from './demo/svg-validation';
11
- export { default as BrokenImage } from './demo/broken-image';
12
- export { default as PreferredSvgEmbedderProp } from './demo/preferred-svg-embedder-prop';
13
-
14
- export default {
15
- title: 'UX/NFTDisplay',
16
- };
@@ -1,33 +0,0 @@
1
- import Box from '@mui/material/Box';
2
- import NFTDisplay, { getNFTData } from '..';
3
- // test data: svg 宽高比 374:130
4
- import ASSET_STATE_GZIPPED_SVG_374_130 from './data/asset-state-gzipped-svg-374-130.json';
5
- import ASSET_STATE_DISPLAY_URL from './data/asset-state-display-url.json';
6
-
7
- export default function AspectRatio() {
8
- const data = ASSET_STATE_GZIPPED_SVG_374_130.data.value;
9
- const { address } = ASSET_STATE_GZIPPED_SVG_374_130;
10
- return (
11
- <Box p={2}>
12
- <h5>1:1</h5>
13
- <Box width={300} border={1}>
14
- <NFTDisplay data={data} address={address} aspect={1} />
15
- </Box>
16
-
17
- <h5>4:3</h5>
18
- <Box width={300} border={1}>
19
- <NFTDisplay data={data} address={address} aspect={4 / 3} />
20
- </Box>
21
-
22
- <h5>16:9</h5>
23
- <Box width={300} border={1}>
24
- <NFTDisplay data={data} address={address} aspect={16 / 9} />
25
- </Box>
26
-
27
- <h5>keep image aspect ratio</h5>
28
- <Box width={300} height={300} minHeight={100} p={1} border={1} overflow="auto" style={{ resize: 'both' }}>
29
- <NFTDisplay data={getNFTData(ASSET_STATE_DISPLAY_URL)} address={ASSET_STATE_DISPLAY_URL.address} inset />
30
- </Box>
31
- </Box>
32
- );
33
- }
@@ -1,15 +0,0 @@
1
- import Box from '@mui/material/Box';
2
- import NFTDisplay from '..';
3
- // test data: svg 宽高比 1:1
4
- import ASSET_STATE_GZIPPED_SVG_1_1 from './data/asset-state-gzipped-svg-1-1.json';
5
- // test data: svg 宽高比 374:130
6
- import ASSET_STATE_GZIPPED_SVG_374_130 from './data/asset-state-gzipped-svg-374-130.json';
7
-
8
- export default function Basic() {
9
- return (
10
- <Box width={300} height={300} p={2}>
11
- <NFTDisplay data={ASSET_STATE_GZIPPED_SVG_1_1.data.value} address={ASSET_STATE_GZIPPED_SVG_1_1.address} />
12
- <NFTDisplay data={ASSET_STATE_GZIPPED_SVG_374_130.data.value} address={ASSET_STATE_GZIPPED_SVG_374_130.address} />
13
- </Box>
14
- );
15
- }
@@ -1,84 +0,0 @@
1
- import Box from '@mui/material/Box';
2
- import styled from 'styled-components';
3
- import NFTDisplay from '..';
4
- import ASSET_STATE_URL from './data/asset-state-url.json';
5
-
6
- const StyledBox = styled(Box)`
7
- && svg.nft-display-broken {
8
- max-width: 300px;
9
- fill: #f38b8b;
10
- }
11
- `;
12
-
13
- export default function BrokenImage() {
14
- const data = ASSET_STATE_URL.data.value;
15
- const { address } = ASSET_STATE_URL;
16
-
17
- // 将 url 改为无效地址
18
- const parsed = JSON.parse(data);
19
- parsed.credentialSubject.display.content = 'https://invalid-url';
20
-
21
- const boxProps = {
22
- border: 1,
23
- borderTop: 0,
24
- borderBottom: 0,
25
- borderLeft: 0,
26
- borderColor: 'grey.300',
27
- p: 4,
28
- };
29
-
30
- const renderError = () => (
31
- <Box
32
- component="span"
33
- display="flex"
34
- justifyContent="center"
35
- alignItems="center"
36
- height={1}
37
- width={1}
38
- bgcolor="grey.400"
39
- color="grey.600">
40
- <span>加载封面失败</span>
41
- </Box>
42
- );
43
-
44
- return (
45
- <Box p={2} display="flex">
46
- <Box {...boxProps}>
47
- <h5>invalid asset data</h5>
48
- <Box width={100} height={100} border={1} mt={1} ml={1} borderColor="#eee">
49
- <NFTDisplay inset />
50
- </Box>
51
- </Box>
52
-
53
- <Box {...boxProps}>
54
- <h5>invalid url</h5>
55
- <Box width={100} height={100} border={1} mt={1} ml={1} borderColor="#eee">
56
- <NFTDisplay data={parsed} address={address} inset />
57
- </Box>
58
- </Box>
59
-
60
- <Box {...boxProps}>
61
- <h5>broken image style customization</h5>
62
- <StyledBox
63
- width={300}
64
- height={300}
65
- p={1}
66
- border={1}
67
- mt={1}
68
- ml={1}
69
- borderColor="#eee"
70
- overflow="auto"
71
- style={{ resize: 'both' }}>
72
- <NFTDisplay data={parsed} address={address} inset />
73
- </StyledBox>
74
- </Box>
75
-
76
- <Box {...boxProps}>
77
- <h5>broken image customization (renderError)</h5>
78
- <Box width={200} height={200} border={1} mt={1} ml={1} borderColor="#eee">
79
- <NFTDisplay data={parsed} address={address} inset renderError={renderError} />
80
- </Box>
81
- </Box>
82
- </Box>
83
- );
84
- }