Skip to content

Commit 63a9bc0

Browse files
committed
ref(onboarding): Extract ScmSelectableContainer for border compensation
1 parent f19f2e0 commit 63a9bc0

File tree

4 files changed

+49
-16
lines changed

4 files changed

+49
-16
lines changed

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

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import {Container, Flex, Grid, Stack} from '@sentry/scraps/layout';
1+
import {Flex, Grid, Stack} from '@sentry/scraps/layout';
22
import {Radio} from '@sentry/scraps/radio';
33
import {Text} from '@sentry/scraps/text';
44

55
import {ScmCardButton} from 'sentry/views/onboarding/components/scmCardButton';
6+
import {ScmSelectableContainer} from 'sentry/views/onboarding/components/scmSelectableContainer';
67

78
interface ScmAlertOptionCardProps {
89
icon: React.ReactNode;
@@ -22,20 +23,15 @@ export function ScmAlertOptionCard({
2223
return (
2324
<ScmCardButton aria-checked={isSelected} onClick={onSelect}>
2425
<Stack gap="lg">
25-
<Container
26-
border={isSelected ? 'accent' : 'secondary'}
27-
padding="lg"
28-
radius="md"
29-
style={isSelected ? {marginBottom: 1} : {borderBottomWidth: 2}}
30-
>
26+
<ScmSelectableContainer isSelected={isSelected} padding="lg">
3127
<Grid gap="md" align="center" columns="min-content 1fr min-content">
3228
<Radio size="sm" readOnly checked={isSelected} tabIndex={-1} />
3329
<Text bold={isSelected} size="md" density="comfortable">
3430
{label}
3531
</Text>
3632
<Flex align="center">{icon}</Flex>
3733
</Grid>
38-
</Container>
34+
</ScmSelectableContainer>
3935
{children}
4036
</Stack>
4137
</ScmCardButton>

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {Tooltip} from '@sentry/scraps/tooltip';
88
import type {SVGIconProps} from 'sentry/icons/svgIcon';
99

1010
import {ScmCardButton} from './scmCardButton';
11+
import {ScmSelectableContainer} from './scmSelectableContainer';
1112

1213
interface ScmFeatureCardProps {
1314
description: string;
@@ -42,12 +43,11 @@ export function ScmFeatureCard({
4243
disabled={disabled}
4344
style={{width: '100%', height: '100%'}}
4445
>
45-
<Container
46-
border={isSelected ? 'accent' : 'secondary'}
46+
<ScmSelectableContainer
47+
isSelected={isSelected}
4748
padding="xl"
48-
radius="md"
4949
height="100%"
50-
style={isSelected ? {marginBottom: 2} : {borderBottomWidth: 3}} // this prevents el height from changing when switching border variant
50+
borderCompensation={3}
5151
>
5252
<Flex>
5353
<Grid
@@ -90,7 +90,7 @@ export function ScmFeatureCard({
9090
/>
9191
</Flex>
9292
</Flex>
93-
</Container>
93+
</ScmSelectableContainer>
9494
</ScmCardButton>
9595
</Tooltip>
9696
);

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import {PlatformIcon} from 'platformicons';
22

3-
import {Container, Grid, Stack} from '@sentry/scraps/layout';
3+
import {Grid, Stack} from '@sentry/scraps/layout';
44
import {Text} from '@sentry/scraps/text';
55

66
import type {PlatformKey} from 'sentry/types/project';
77

88
import {ScmCardButton} from './scmCardButton';
9+
import {ScmSelectableContainer} from './scmSelectableContainer';
910

1011
interface ScmPlatformCardProps {
1112
isSelected: boolean;
@@ -24,7 +25,7 @@ export function ScmPlatformCard({
2425
}: ScmPlatformCardProps) {
2526
return (
2627
<ScmCardButton onClick={onClick} role="radio" aria-checked={isSelected}>
27-
<Container border={isSelected ? 'accent' : 'secondary'} padding="lg" radius="md">
28+
<ScmSelectableContainer isSelected={isSelected} padding="lg">
2829
<Grid gap="md" align="center" columns="max-content min-content">
2930
<PlatformIcon platform={platform} size={28} />
3031
<Stack gap="0">
@@ -36,7 +37,7 @@ export function ScmPlatformCard({
3637
</Text>
3738
</Stack>
3839
</Grid>
39-
</Container>
40+
</ScmSelectableContainer>
4041
</ScmCardButton>
4142
);
4243
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import type {ComponentProps} from 'react';
2+
3+
import {Container} from '@sentry/scraps/layout';
4+
5+
interface ScmSelectableContainerProps extends ComponentProps<typeof Container> {
6+
isSelected: boolean;
7+
/**
8+
* Accent borders are thicker than secondary borders, causing a layout
9+
* shift when toggling selection. This compensation value offsets the
10+
* difference via marginBottom (selected) / borderBottomWidth (unselected).
11+
* Will be unnecessary once the design system provides a stable-height
12+
* selected border variant.
13+
*/
14+
borderCompensation?: number;
15+
}
16+
17+
export function ScmSelectableContainer({
18+
isSelected,
19+
borderCompensation = 2,
20+
style,
21+
...props
22+
}: ScmSelectableContainerProps) {
23+
return (
24+
<Container
25+
border={isSelected ? 'accent' : 'secondary'}
26+
radius="md"
27+
style={{
28+
...(isSelected
29+
? {marginBottom: borderCompensation - 1}
30+
: {borderBottomWidth: borderCompensation}),
31+
...style,
32+
}}
33+
{...props}
34+
/>
35+
);
36+
}

0 commit comments

Comments
 (0)