/
ComponentIcon.js
39 lines (35 loc) 路 960 Bytes
/
ComponentIcon.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import PropTypes from 'prop-types';
import React from 'react';
import { Flex, Icon } from '@strapi/design-system';
import { COMPONENT_ICONS } from './constants';
export function ComponentIcon({ showBackground = true, size = 'M', icon }) {
return (
<Flex
alignItems="center"
background={showBackground ? 'neutral200' : null}
justifyContent="center"
size={size}
showBackground={showBackground}
height={size === 'S' ? 5 : 8}
width={size === 'S' ? 5 : 8}
color="neutral600"
borderRadius={showBackground ? '50%' : 0}
>
<Icon
as={COMPONENT_ICONS[icon] || COMPONENT_ICONS.cube}
height={size === 'S' ? 3 : 5}
width={size === 'S' ? 3 : 5}
/>
</Flex>
);
}
ComponentIcon.defaultProps = {
showBackground: true,
size: 'M',
icon: 'Cube',
};
ComponentIcon.propTypes = {
showBackground: PropTypes.bool,
size: PropTypes.string,
icon: PropTypes.string,
};