Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit dcb628d

Browse files
author
Danny
authored
feat: double outline for hide ui button (storybookjs#382)
authored-by: Pavlos Vinieratos <[email protected]> changes from storybookjs#370
1 parent e189001 commit dcb628d

File tree

1 file changed

+41
-6
lines changed

1 file changed

+41
-6
lines changed
Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import React from 'react';
22
import styled from '@emotion/native';
3-
import { ViewStyle } from 'react-native';
3+
import { StyleProp, View, ViewStyle } from 'react-native';
44

55
interface Props {
66
onPress: () => void;
7-
style?: ViewStyle;
7+
style?: StyleProp<ViewStyle>;
88
}
99

1010
const Touchable = styled.TouchableOpacity({
@@ -15,11 +15,46 @@ const Touchable = styled.TouchableOpacity({
1515
zIndex: 100,
1616
});
1717

18-
const HideIcon = styled.Text(({ theme }) => ({
19-
fontSize: 14,
20-
color: theme.buttonTextColor || '#999999',
18+
const HIDE_ICON_SIZE = 14;
19+
const HIDE_ICON_BORDER_WIDTH = 1;
20+
21+
const Inner = styled.View(({ theme }) => ({
22+
position: 'absolute',
23+
top: 0,
24+
left: 0,
25+
width: HIDE_ICON_SIZE,
26+
height: HIDE_ICON_SIZE,
27+
borderRadius: HIDE_ICON_BORDER_WIDTH,
28+
overflow: 'hidden',
29+
borderColor: theme.buttonTextColor || '#999999',
30+
borderWidth: HIDE_ICON_BORDER_WIDTH * 2,
2131
}));
2232

33+
const Outer = styled.View({
34+
position: 'absolute',
35+
top: 0,
36+
left: 0,
37+
width: HIDE_ICON_SIZE,
38+
height: HIDE_ICON_SIZE,
39+
borderRadius: HIDE_ICON_BORDER_WIDTH,
40+
overflow: 'hidden',
41+
borderColor: 'white',
42+
borderWidth: HIDE_ICON_BORDER_WIDTH,
43+
});
44+
45+
const hideIconStyles = {
46+
width: HIDE_ICON_SIZE,
47+
height: HIDE_ICON_SIZE,
48+
marginRight: 4,
49+
};
50+
51+
const HideIcon = () => (
52+
<View style={hideIconStyles}>
53+
<Inner />
54+
<Outer />
55+
</View>
56+
);
57+
2358
const VisibilityButton = ({ onPress, style }: Props) => (
2459
<Touchable
2560
onPress={onPress}
@@ -28,7 +63,7 @@ const VisibilityButton = ({ onPress, style }: Props) => (
2863
accessibilityLabel="Storybook.OnDeviceUI.toggleUI"
2964
hitSlop={{ top: 5, left: 5, bottom: 5, right: 5 }}
3065
>
31-
<HideIcon>â–¡</HideIcon>
66+
<HideIcon />
3267
</Touchable>
3368
);
3469
export default React.memo(VisibilityButton);

0 commit comments

Comments
 (0)