Files
orca/mobile/src/browser/MobileBrowserPointerModifiers.tsx
T
Kelvin Amoaba a079f51991 feat(mobile): unify corner radii across the app (#36437)
* feat(mobile): give every corner one of three shapes

Corners had drifted to 17 different radii, so a screen mixed 6 pt
buttons, 14 pt cards, 12 pt groups and 4 pt badges. Every corner now
comes from the shape of what it is:

- control (12): anything you tap — buttons, icon buttons, fields,
  pickers, segmented controls, key caps.
- surface (16): anything that holds content — cards, groups, sheets,
  banners, code boxes. Dialogs and the composer box use floating (24).
- pill: badges, chips, status pills, dots, avatars and the composer's
  own round buttons.
- tile (10) for icon squares and mark (4) for inline code and check
  squares; nested shapes take the parent's radius minus the gap.

Every rounded style also asks for the continuous (squircle) corner
curve; iOS draws it, Android and the web ignore it.

* fix(mobile): keep circles and pills on the circular corner curve

The continuous curve squares off a corner radius that reaches half the element's size, so the FAB, dots, avatars and the composer's round buttons stopped being round on iOS.

* fix(mobile): put the anchored detail card on the surface radius

* fix(mobile): keep the circular curve on unclipped bordered styles

React Native strokes an unclipped visible border on a circular path while it fills the background with the continuous curve, so the two edges drifted apart at the corners.
2026-10-30 21:27:30 +00:00

107 lines
2.9 KiB
TypeScript

import { Pressable, Text, View } from 'react-native'
import { useMobileTranslation } from '../i18n/use-mobile-translation'
import { colors, radii, spacing, typography } from '../theme/mobile-theme'
import { themedStyleSheet } from '../theme/themed-styles'
import { useMobileColorScheme } from '../theme/use-mobile-color-scheme'
export type BrowserPointerModifier = 'cmd' | 'ctrl' | 'alt' | 'shift'
const BROWSER_POINTER_MODIFIERS: { id: BrowserPointerModifier; label: string }[] = [
{ id: 'cmd', label: 'Cmd' },
{ id: 'ctrl', label: 'Ctrl' },
{ id: 'alt', label: 'Alt' },
{ id: 'shift', label: 'Shift' }
]
type Props = {
disabled: boolean
selectedModifiers: BrowserPointerModifier[]
onToggle: (modifier: BrowserPointerModifier) => void
}
export function MobileBrowserPointerModifiers({
disabled,
selectedModifiers,
onToggle
}: Props): React.JSX.Element {
const t = useMobileTranslation()
useMobileColorScheme()
return (
<View style={styles.modifierRow}>
{BROWSER_POINTER_MODIFIERS.map((modifier) => {
const selected = selectedModifiers.includes(modifier.id)
return (
<Pressable
key={modifier.id}
style={({ pressed }) => [
styles.keyButton,
selected && styles.keyButtonSelected,
pressed && !selected && styles.keyButtonPressed,
disabled && styles.disabled
]}
disabled={disabled}
onPress={() => onToggle(modifier.id)}
accessibilityRole="button"
accessibilityState={{ selected, disabled }}
accessibilityLabel={t(
'browser.pointerModifiers.clickModifier',
'{{key}} click modifier',
{
key: modifier.label
}
)}
>
<Text
style={[
styles.keyButtonText,
selected && styles.keyButtonTextSelected,
disabled && styles.disabledText
]}
>
{modifier.label}
</Text>
</Pressable>
)
})}
</View>
)
}
const styles = themedStyleSheet(() => ({
modifierRow: {
flexDirection: 'row',
gap: spacing.xs,
paddingHorizontal: spacing.sm,
paddingTop: spacing.xs
},
keyButton: {
minHeight: 30,
minWidth: 42,
alignItems: 'center',
justifyContent: 'center',
borderRadius: radii.control,
backgroundColor: colors.bgRaised,
paddingHorizontal: spacing.sm
},
keyButtonPressed: {
backgroundColor: colors.borderSubtle
},
keyButtonSelected: {
backgroundColor: colors.textPrimary
},
keyButtonText: {
color: colors.textSecondary,
fontSize: 12,
fontFamily: typography.monoFamily
},
keyButtonTextSelected: {
color: colors.bgBase
},
disabled: {
opacity: 0.35
},
disabledText: {
color: colors.textMuted
}
}))