Skip to content

Commit

Permalink
Add hover style for [Selectbox] (#144)
Browse files Browse the repository at this point in the history
  • Loading branch information
Juyeong-Byeon committed Oct 8, 2021
1 parent 8d0de13 commit 67c9b51
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
9 changes: 8 additions & 1 deletion main/SelectBox/index.tsx
Expand Up @@ -16,6 +16,7 @@ import {Icon} from '../Icon';
import {TouchableOpacity} from 'react-native-gesture-handler';
import {Typography} from '../Typography';
import styled from '@emotion/native';
import {useHover} from 'react-native-web-hooks';
import {withTheme} from '@emotion/react';

const Title = styled.View`
Expand Down Expand Up @@ -45,6 +46,7 @@ type Styles = {
rightElementContainer?: StyleProp<ViewStyle>;
itemContainer?: StyleProp<ViewStyle>;
itemText?: StyleProp<TextStyle>;
hovered?: StyleProp<ViewStyle>;
};
interface ItemCompProps<T> {
value: T;
Expand All @@ -69,15 +71,20 @@ function ItemComp<T extends {value: string} | string>({
setIsOpened(false);
};

const ref = useRef(null);
const hover = useHover(ref);

return (
<TouchableOpacity {...itemTouchableProps} onPress={handlePress}>
<TouchableOpacity {...itemTouchableProps} onPress={handlePress} ref={ref}>
<Item
style={[
{
borderColor: theme.primary,
backgroundColor: theme.textContrast,
},
styles?.itemContainer,
hover && {backgroundColor: theme.secondary},
hover && styles?.hovered,
]}
>
<Typography.Body2 style={styles?.itemText}>
Expand Down
5 changes: 4 additions & 1 deletion stories/dooboo-ui/SelectBoxStories/SelectBoxStory.tsx
Expand Up @@ -90,12 +90,15 @@ const SelectBoxStory: FC = () => {
borderRightWidth: 0,
},
itemContainer: {
backgroundColor: theme.secondary,
backgroundColor: theme.paper,
borderTopWidth: 0,
borderBottomWidth: 0,
borderLeftWidth: 0,
borderRightWidth: 0,
},
hovered: {
backgroundColor: theme.secondary,
},
}}
/>
<Divider />
Expand Down

0 comments on commit 67c9b51

Please sign in to comment.