Repository navigation
fix!: expand interactive targets to the 48dp minimum #5108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
27ee271
1c70fde
aab7ec7
5e8645a
eee19e9
3a99241
ffc991f
2985c8a
d3671d7
d6eba47
898490c
02e157f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| /** | ||
| * MD3 Chip spec dimensions. | ||
| * @see https://m3.material.io/components/chips/specs | ||
| */ | ||
| export const ChipTokens = { | ||
| containerHeight: 32, | ||
| } as const; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| import * as React from 'react'; | ||
| import { StyleSheet, View } from 'react-native'; | ||
| import { Platform, StyleSheet, View } from 'react-native'; | ||
| import type { | ||
| ColorValue, | ||
| GestureResponderEvent, | ||
|
|
@@ -12,6 +12,7 @@ import Animated, { type AnimatedStyle } from 'react-native-reanimated'; | |
| import { getIconButtonColor } from './utils'; | ||
| import { useInternalTheme } from '../../core/theming'; | ||
| import type { ThemeProp } from '../../theme/types'; | ||
| import getMinInteractiveSizeHitSlop from '../../utils/getMinInteractiveSizeHitSlop'; | ||
| import ActivityIndicator from '../ActivityIndicator'; | ||
| import CrossFadeIcon from '../CrossFadeIcon'; | ||
| import Icon from '../Icon'; | ||
|
|
@@ -151,13 +152,25 @@ const IconButton = ({ | |
| }); | ||
|
|
||
| const buttonSize = size + 2 * PADDING; | ||
| const borderWidth = mode === 'outlined' && !selected ? 1 : 0; | ||
|
|
||
| const shapeStyle = { borderRadius: buttonSize / 2 }; | ||
|
|
||
| const borderStyles = { | ||
| borderWidth: mode === 'outlined' && !selected ? 1 : 0, | ||
| borderRadius: buttonSize / 2, | ||
| borderWidth, | ||
| borderColor, | ||
| ...shapeStyle, | ||
| }; | ||
|
|
||
| const touchableSize = buttonSize - 2 * borderWidth; | ||
|
|
||
| const hitSlop = disabled | ||
| ? undefined | ||
| : getMinInteractiveSizeHitSlop({ | ||
| width: touchableSize, | ||
| height: touchableSize, | ||
| }); | ||
|
|
||
| return ( | ||
| <Animated.View | ||
| ref={ref} | ||
|
|
@@ -178,6 +191,7 @@ const IconButton = ({ | |
| style={[ | ||
| StyleSheet.absoluteFill, | ||
| { backgroundColor, opacity: backgroundOpacity }, | ||
| shapeStyle, | ||
| ]} | ||
| /> | ||
| )} | ||
|
|
@@ -186,16 +200,19 @@ const IconButton = ({ | |
| centered | ||
| onPress={onPress} | ||
| aria-label={ariaLabel} | ||
| style={[styles.touchable, contentStyle]} | ||
| style={[ | ||
| styles.touchable, | ||
| shapeStyle, | ||
| // Clip the ripple to the button shape. Not on web, where | ||
| // `overflow: 'hidden'` would also clip the hit slop target. | ||
| Platform.OS !== 'web' && styles.clipToShape, | ||
| contentStyle, | ||
| ]} | ||
| role="button" | ||
| aria-disabled={disabled} | ||
| disabled={disabled} | ||
| hitSlop={ | ||
| TouchableRipple.supported | ||
| ? { top: 10, left: 10, bottom: 10, right: 10 } | ||
| : { top: 6, left: 6, bottom: 6, right: 6 } | ||
| } | ||
| testID={testID} | ||
| hitSlop={hitSlop} | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Codex: We need to account for joined controls when adding this default.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While working on When Since Options I see:
Which direction would you like for this PR, or should it be handled separately from the 48dp work?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After private chat we decided to remove any changes to ToggleButton components. So my question was resolved :) |
||
| {...rest} | ||
| > | ||
| <View style={{ opacity: iconOpacity }}> | ||
|
|
@@ -213,13 +230,15 @@ const IconButton = ({ | |
| const styles = StyleSheet.create({ | ||
| container: { | ||
| margin: 6, | ||
| overflow: 'hidden', | ||
| }, | ||
| touchable: { | ||
| flexGrow: 1, | ||
| justifyContent: 'center', | ||
| alignItems: 'center', | ||
| }, | ||
| clipToShape: { | ||
| overflow: 'hidden', | ||
| }, | ||
| }); | ||
|
|
||
| export default IconButton; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment repeats the review discussion about material-web's SCSS. The earlier review asked to keep only comments that explain unclear code. A short description is enough here.
(via Claude, verify if it makes sense)