Skip to content

Commit 850dd5e

Browse files
committed
ref(onboarding): Use ScmCardButton for alert option cards
Replace manual onClick, tabIndex, and onKeyDown handling with the shared ScmCardButton component which already provides click, keyboard, and cursor semantics.
1 parent 8e28842 commit 850dd5e

File tree

1 file changed

+26
-32
lines changed

1 file changed

+26
-32
lines changed

static/app/views/onboarding/components/scmAlertFrequency.tsx

Lines changed: 26 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ import {
2020
RuleAction,
2121
} from 'sentry/views/projectInstall/issueAlertOptions';
2222

23+
import {ScmCardButton} from './scmCardButton';
24+
2325
interface ScmAlertFrequencyProps extends Partial<AlertRuleOptions> {
2426
onFieldChange: <K extends keyof AlertRuleOptions>(
2527
key: K,
@@ -45,39 +47,31 @@ function AlertOptionCard({
4547
}: AlertOptionCardProps) {
4648
return (
4749
<Stack gap="md">
48-
<Container
49-
border={isSelected ? 'accent' : 'secondary'}
50-
padding="lg"
51-
radius="md"
52-
style={isSelected ? {marginBottom: 1} : {borderBottomWidth: 2}}
53-
role="radio"
54-
aria-checked={isSelected}
55-
onClick={onSelect}
56-
tabIndex={0}
57-
onKeyDown={(e: React.KeyboardEvent) => {
58-
if (e.key === ' ' || e.key === 'Enter') {
59-
e.preventDefault();
60-
onSelect();
61-
}
62-
}}
63-
>
64-
<Flex gap="md" align="center">
65-
<Container padding="xs 0 0 0">
66-
<Radio size="sm" readOnly checked={isSelected} tabIndex={-1} />
67-
</Container>
68-
<Text
69-
bold={isSelected}
70-
style={{flex: 1, lineHeight: '22px'}}
71-
size="md"
72-
density="comfortable"
73-
>
74-
{label}
75-
</Text>
76-
<Flex align="center" style={{paddingTop: 2}}>
77-
{icon}
50+
<ScmCardButton role="radio" aria-checked={isSelected} onClick={onSelect}>
51+
<Container
52+
border={isSelected ? 'accent' : 'secondary'}
53+
padding="lg"
54+
radius="md"
55+
style={isSelected ? {marginBottom: 1} : {borderBottomWidth: 2}}
56+
>
57+
<Flex gap="md" align="center">
58+
<Container padding="xs 0 0 0">
59+
<Radio size="sm" readOnly checked={isSelected} tabIndex={-1} />
60+
</Container>
61+
<Text
62+
bold={isSelected}
63+
style={{flex: 1, lineHeight: '22px'}}
64+
size="md"
65+
density="comfortable"
66+
>
67+
{label}
68+
</Text>
69+
<Flex align="center" style={{paddingTop: 2}}>
70+
{icon}
71+
</Flex>
7872
</Flex>
79-
</Flex>
80-
</Container>
73+
</Container>
74+
</ScmCardButton>
8175
{children}
8276
</Stack>
8377
);

0 commit comments

Comments
 (0)