-
Notifications
You must be signed in to change notification settings - Fork 4k
/
index.native.js
48 lines (42 loc) · 934 Bytes
/
index.native.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
40
41
42
43
44
45
46
47
48
/**
* External dependencies
*/
import { View } from 'react-native';
/**
* WordPress dependencies
*/
import { Icon } from '@wordpress/components';
import { blockDefault } from '@wordpress/icons';
import { withPreferredColorScheme } from '@wordpress/compose';
/**
* Internal dependencies
*/
import styles from './style.scss';
export function BlockIcon( {
icon,
showColors = false,
getStylesFromColorScheme,
} ) {
if ( icon?.src === 'block-default' ) {
icon = {
src: blockDefault,
};
}
const renderedIcon = (
<Icon
icon={ icon && icon.src ? icon.src : icon }
{ ...getStylesFromColorScheme(
styles.iconPlaceholder,
styles.iconPlaceholderDark
) }
/>
);
const style = showColors
? {
backgroundColor: icon && icon.background,
color: icon && icon.foreground,
}
: {};
return <View style={ style }>{ renderedIcon }</View>;
}
export default withPreferredColorScheme( BlockIcon );