Skip to content

Commit

Permalink
refactor(ui): radio/checkbox hit-slopes add (#403)
Browse files Browse the repository at this point in the history
  • Loading branch information
32penkin authored May 24, 2019
1 parent 9d94b38 commit 56094b6
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/framework/ui/checkbox/checkbox.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ class CheckBoxComponent extends React.Component<CheckBoxProps> {
outlineHeight,
outlineBorderRadius,
outlineBackgroundColor,
hitSlop,
...containerParameters
} = source;

Expand Down Expand Up @@ -198,6 +199,12 @@ class CheckBoxComponent extends React.Component<CheckBoxProps> {
backgroundColor: outlineBackgroundColor,
...styles.highlight,
},
hitSlop: {
top: hitSlop,
left: hitSlop,
bottom: hitSlop,
right: hitSlop,
},
};
};

Expand Down Expand Up @@ -246,6 +253,7 @@ class CheckBoxComponent extends React.Component<CheckBoxProps> {
highlightContainer,
highlight,
selectContainer,
hitSlop,
...componentStyle
}: StyleType = this.getComponentStyle(themedStyle);

Expand All @@ -256,6 +264,7 @@ class CheckBoxComponent extends React.Component<CheckBoxProps> {
style={container}
activeOpacity={1.0}
disabled={disabled}
hitSlop={hitSlop}
onPress={this.onPress}
onPressIn={this.onPressIn}
onPressOut={this.onPressOut}>
Expand Down
9 changes: 9 additions & 0 deletions src/framework/ui/radio/radio.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ export class RadioComponent extends React.Component<RadioProps> {
outlineHeight,
outlineBorderRadius,
outlineBackgroundColor,
hitSlop,
...containerParameters
} = source;

Expand Down Expand Up @@ -190,6 +191,12 @@ export class RadioComponent extends React.Component<RadioProps> {
backgroundColor: outlineBackgroundColor,
...styles.highlight,
},
hitSlop: {
top: hitSlop,
left: hitSlop,
bottom: hitSlop,
right: hitSlop,
},
};
};

Expand Down Expand Up @@ -220,6 +227,7 @@ export class RadioComponent extends React.Component<RadioProps> {
selectContainer,
icon,
highlight,
hitSlop,
...componentStyles
} = this.getComponentStyle(themedStyle);

Expand All @@ -230,6 +238,7 @@ export class RadioComponent extends React.Component<RadioProps> {
style={container}
activeOpacity={1.0}
disabled={disabled}
hitSlop={hitSlop}
onPress={this.onPress}
onPressIn={this.onPressIn}
onPressOut={this.onPressOut}>
Expand Down
8 changes: 8 additions & 0 deletions src/framework/ui/radio/radio.spec.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ exports[`@radio: matches snapshot checked disabled 1`] = `
exports[`@radio: matches snapshot default 1`] = `
<TouchableOpacity
activeOpacity={1}
hitSlop={
Object {
"bottom": 16,
"left": 16,
"right": 16,
"top": 16,
}
}
onPress={[Function]}
onPressIn={[Function]}
onPressOut={[Function]}
Expand Down
20 changes: 20 additions & 0 deletions src/framework/ui/support/tests/mapping.json
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,9 @@
"meta": {
"scope": "mobile",
"parameters": {
"minHeight": {
"type": "number"
},
"paddingVertical": {
"type": "number"
},
Expand Down Expand Up @@ -247,6 +250,7 @@
"appearances": {
"default": {
"mapping": {
"minHeight": 56,
"paddingVertical": 4,
"backgroundColor": "background-color-default-1",
"indicatorHeight": 4,
Expand Down Expand Up @@ -887,6 +891,9 @@
"height": {
"type": "number"
},
"hitSlop": {
"type": "number"
},
"borderWidth": {
"type": "number"
},
Expand Down Expand Up @@ -1145,6 +1152,7 @@
"tiny": {
"width": 16,
"height": 16,
"hitSlop": 24,
"iconWidth": 9,
"iconHeight": 9,
"outlineWidth": 24,
Expand All @@ -1163,6 +1171,7 @@
"small": {
"width": 20,
"height": 20,
"hitSlop": 20,
"iconWidth": 10,
"iconHeight": 10,
"outlineWidth": 32,
Expand All @@ -1181,6 +1190,7 @@
"medium": {
"width": 24,
"height": 24,
"hitSlop": 16,
"iconWidth": 12,
"iconHeight": 12,
"outlineWidth": 40,
Expand All @@ -1199,6 +1209,7 @@
"large": {
"width": 32,
"height": 32,
"hitSlop": 8,
"iconWidth": 16,
"iconHeight": 16,
"outlineWidth": 48,
Expand All @@ -1217,6 +1228,7 @@
"giant": {
"width": 40,
"height": 40,
"hitSlop": 0,
"iconWidth": 20,
"iconHeight": 20,
"outlineWidth": 56,
Expand Down Expand Up @@ -1851,6 +1863,9 @@
"height": {
"type": "number"
},
"hitSlop": {
"type": "number"
},
"borderRadius": {
"type": "number"
},
Expand Down Expand Up @@ -2071,6 +2086,7 @@
"tiny": {
"width": 16,
"height": 16,
"hitSlop": 24,
"iconWidth": 9,
"iconHeight": 9,
"outlineWidth": 24,
Expand All @@ -2086,6 +2102,7 @@
"small": {
"width": 20,
"height": 20,
"hitSlop": 20,
"iconWidth": 12,
"iconHeight": 12,
"outlineWidth": 32,
Expand All @@ -2101,6 +2118,7 @@
"medium": {
"width": 24,
"height": 24,
"hitSlop": 16,
"iconWidth": 16,
"iconHeight": 16,
"outlineWidth": 40,
Expand All @@ -2116,6 +2134,7 @@
"large": {
"width": 32,
"height": 32,
"hitSlop": 0,
"iconWidth": 22,
"iconHeight": 22,
"outlineWidth": 48,
Expand All @@ -2131,6 +2150,7 @@
"giant": {
"width": 40,
"height": 40,
"hitSlop": 0,
"iconWidth": 28,
"iconHeight": 28,
"outlineWidth": 56,
Expand Down

0 comments on commit 56094b6

Please sign in to comment.