Skip to content

Commit 8e05eb6

Browse files
TkDodoandrewshie-sentry
authored andcommitted
ref(ui): use space tokens for gap on Flex (#95775)
| before | after | |--------|--------| | `<Flex gap={space(1)}>` | `<Flex gap=“md”>` | This also caught one issue where we did `gap={0.5}` instead of `gap={space(0.5)}`, resulting in 0.5px spacing, which is pretty likely not what we wanted.
1 parent 5e26532 commit 8e05eb6

File tree

102 files changed

+287
-243
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+287
-243
lines changed

static/app/components/codecov/branchSelector/branchSelector.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export function BranchSelector() {
8787
{...triggerProps}
8888
>
8989
<TriggerLabelWrap>
90-
<Flex align="center" gap={space(0.75)}>
90+
<Flex align="center" gap="sm">
9191
<IconContainer>
9292
<IconBranch />
9393
</IconContainer>

static/app/components/codecov/dateSelector/dateSelector.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import DropdownButton from 'sentry/components/dropdownButton';
99
import {getArbitraryRelativePeriod} from 'sentry/components/timeRangeSelector/utils';
1010
import {IconCalendar} from 'sentry/icons/iconCalendar';
1111
import {t} from 'sentry/locale';
12-
import {space} from 'sentry/styles/space';
1312

1413
export const CODECOV_DEFAULT_RELATIVE_PERIODS = {
1514
'24h': t('Last 24 hours'),
@@ -65,7 +64,7 @@ export function DateSelector() {
6564
{...triggerProps}
6665
>
6766
<TriggerLabelWrap>
68-
<Flex align="center" gap={space(0.75)}>
67+
<Flex align="center" gap="sm">
6968
<IconCalendar />
7069
<TriggerLabel>{defaultLabel}</TriggerLabel>
7170
</Flex>

static/app/components/codecov/integratedOrgSelector/integratedOrgSelector.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ function OrgFooterMessage() {
3636
<Fragment>
3737
<AddIntegratedOrgButton />
3838
<MenuFooterDivider />
39-
<Flex justify="flex-start" gap={space(1)}>
39+
<Flex justify="flex-start" gap="md">
4040
<IconInfo size="sm" style={{margin: '2px 0'}} />
4141
<div>
4242
<FooterInfoHeading>
@@ -102,7 +102,7 @@ export function IntegratedOrgSelector() {
102102
{...triggerProps}
103103
>
104104
<TriggerLabelWrap>
105-
<Flex justify="flex-start" gap={space(0.75)} align="center">
105+
<Flex justify="flex-start" gap="sm" align="center">
106106
<IconContainer>
107107
<IconIntegratedOrg />
108108
</IconContainer>

static/app/components/codecov/repoSelector/repoSelector.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ export function RepoSelector() {
128128
{...triggerProps}
129129
>
130130
<TriggerLabelWrap>
131-
<Flex align="center" gap={space(0.75)}>
131+
<Flex align="center" gap="sm">
132132
<IconContainer>
133133
<IconRepository />
134134
</IconContainer>

static/app/components/contentSliderDiff/contentSliderDiff.stories.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import GoodStackTraceExample from 'sentry-images/issue_details/good-stack-trace-
66
import {Flex} from 'sentry/components/core/layout';
77
import QuestionTooltip from 'sentry/components/questionTooltip';
88
import * as Storybook from 'sentry/stories';
9-
import {space} from 'sentry/styles/space';
109

1110
import {ContentSliderDiff} from '.';
1211

@@ -29,11 +28,11 @@ export default Storybook.story('ContentSliderDiff', story => {
2928
</p>
3029
<div>
3130
<ContentSliderDiff.Header>
32-
<Flex align="center" gap={space(0.5)}>
31+
<Flex align="center" gap="xs">
3332
Before
3433
<QuestionTooltip title="This is the before image" size="xs" />
3534
</Flex>
36-
<Flex align="center" gap={space(0.5)}>
35+
<Flex align="center" gap="xs">
3736
After
3837
<QuestionTooltip title="This is the after image" size="xs" />
3938
</Flex>

static/app/components/core/badge/alertBadge.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import {
1212
} from 'sentry/icons';
1313
import type {SVGIconProps} from 'sentry/icons/svgIcon';
1414
import {t} from 'sentry/locale';
15-
import {space} from 'sentry/styles/space';
1615
import {withChonk} from 'sentry/utils/theme/withChonk';
1716
import {IncidentStatus} from 'sentry/views/alerts/types';
1817

@@ -51,7 +50,7 @@ export function AlertBadge(props: AlertBadgeProps) {
5150
);
5251

5352
return (
54-
<PaddedContainer data-test-id="alert-badge" align="center" gap={space(1.5)}>
53+
<PaddedContainer data-test-id="alert-badge" align="center" gap="lg">
5554
<DiamondBackground
5655
{...props}
5756
role="presentation"

static/app/components/core/button/buttonBar.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
import type {Theme} from '@emotion/react';
21
import {css} from '@emotion/react';
32
import styled from '@emotion/styled';
43

54
import {StyledButton} from 'sentry/components/core/button';
6-
7-
type Gap = keyof Theme['space'];
5+
// eslint-disable-next-line boundaries/element-types
6+
import type {Space} from 'sentry/utils/theme/theme';
87

98
interface ButtonBarProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'className'> {
109
children: React.ReactNode;
11-
gap?: Gap;
10+
gap?: Space;
1211
merged?: boolean;
1312
}
1413

@@ -25,7 +24,7 @@ export function ButtonBar({
2524
);
2625
}
2726

28-
const StyledButtonBar = styled('div')<{gap: Gap; merged: boolean}>`
27+
const StyledButtonBar = styled('div')<{gap: Space; merged: boolean}>`
2928
display: grid;
3029
grid-auto-flow: column;
3130
grid-column-gap: ${p => p.theme.space[p.gap]};

static/app/components/core/compactSelect/composite.stories.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import {Button} from 'sentry/components/core/button';
44
import {Flex} from 'sentry/components/core/layout';
55
import {IconSentry, IconStar} from 'sentry/icons';
66
import * as Storybook from 'sentry/stories';
7-
import {space} from 'sentry/styles/space';
87

98
import {CompositeSelect} from './composite';
109
import {CompactSelect} from './';
@@ -129,7 +128,7 @@ export default Storybook.story('CompositeSelect', story => {
129128
<code>CompactSelect</code> deal with multiple single-select sections:
130129
</p>
131130

132-
<Flex gap={space(1)}>
131+
<Flex gap="md">
133132
<CompositeSelect
134133
trigger={triggerProps => (
135134
<Button

static/app/components/core/layout/flex.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
import type {CSSProperties} from 'react';
22
import isPropValid from '@emotion/is-prop-valid';
3+
import {css} from '@emotion/react';
34
import styled from '@emotion/styled';
45

6+
import type {space} from 'sentry/styles/space';
7+
import type {Space} from 'sentry/utils/theme/theme';
8+
59
interface FlexProps {
610
align?: CSSProperties['alignItems'];
711
direction?: CSSProperties['flexDirection'];
812
flex?: CSSProperties['flex'];
9-
gap?: CSSProperties['gap'];
13+
gap?: Space | ReturnType<typeof space>;
1014
/**
1115
* Determines whether the flex container should be displayed as an inline-flex.
1216
*/
@@ -24,7 +28,11 @@ export const Flex = styled('div', {
2428
flex-direction: ${p => p.direction};
2529
justify-content: ${p => p.justify};
2630
align-items: ${p => p.align};
27-
gap: ${p => p.gap};
31+
${p =>
32+
p.gap &&
33+
css`
34+
gap: ${p.gap in p.theme.space ? p.theme.space[p.gap as Space] : p.gap};
35+
`};
2836
flex-wrap: ${p => p.wrap};
2937
flex: ${p => p.flex};
3038
`;
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
import {Fragment} from 'react';
2+
3+
import {Button} from 'sentry/components/core/button';
4+
import {Flex} from 'sentry/components/core/layout';
5+
import {Tooltip} from 'sentry/components/core/tooltip';
6+
import * as Storybook from 'sentry/stories';
7+
8+
import types from '!!type-loader!sentry/components/core/tooltip';
9+
10+
export default Storybook.story('Tooltip', (story, APIReference) => {
11+
APIReference(types.Tooltip);
12+
13+
story('Default', () => {
14+
return (
15+
<Fragment>
16+
<p>
17+
Tooltip is a component that displays a tooltip when hovering over an element
18+
(duh).
19+
</p>
20+
<p>
21+
By default, a tooltip renders a wrapper around the children element and renders
22+
the tooltip content in a portal. The wrapper can be skipped by passing the{' '}
23+
<Storybook.JSXProperty name="skipWrapper" value="true" /> prop.
24+
</p>
25+
<Storybook.SideBySide>
26+
<Tooltip title="Tooltip">
27+
<Button>Hover me</Button>
28+
</Tooltip>
29+
</Storybook.SideBySide>
30+
</Fragment>
31+
);
32+
});
33+
34+
story('Hoverable Tooltip', () => {
35+
return (
36+
<Fragment>
37+
<p>
38+
A tooltip is not hoverable by default and will hide before the pointer enters
39+
it's container - to make it hoverable, pass the{' '}
40+
<Storybook.JSXProperty name="isHoverable" value="true" /> prop.
41+
</p>
42+
<Storybook.SideBySide>
43+
<Tooltip title="This can be copied" isHoverable skipWrapper>
44+
<Button>Hoverable Tooltip</Button>
45+
</Tooltip>
46+
<Tooltip title="This cannot be copied" skipWrapper>
47+
<Button>Non Hoverable Tooltip</Button>
48+
</Tooltip>
49+
</Storybook.SideBySide>
50+
</Fragment>
51+
);
52+
});
53+
54+
story('All Positions', () => {
55+
return (
56+
<Fragment>
57+
<p>
58+
Tooltips can be positioned in different directions. Use the{' '}
59+
<Storybook.JSXNode name="position" /> prop to control placement.
60+
</p>
61+
<Flex direction="column" gap="md" align="center">
62+
<div
63+
style={{
64+
display: 'flex',
65+
flexDirection: 'column',
66+
gap: '8px',
67+
margin: '40px 0 40px 0',
68+
alignItems: 'center',
69+
}}
70+
>
71+
<Tooltip title="Top Tooltip Position" position="top" forceVisible>
72+
<Button>Top</Button>
73+
</Tooltip>
74+
<div style={{display: 'flex', gap: '8px'}}>
75+
<Tooltip title="Left Tooltip Position" position="left" forceVisible>
76+
<Button>Left</Button>
77+
</Tooltip>
78+
<Tooltip title="Right Tooltip Position" position="right" forceVisible>
79+
<Button>Right</Button>
80+
</Tooltip>
81+
</div>
82+
<Tooltip title="Bottom Tooltip Position" position="bottom" forceVisible>
83+
<Button>Bottom</Button>
84+
</Tooltip>
85+
</div>
86+
</Flex>
87+
</Fragment>
88+
);
89+
});
90+
});

0 commit comments

Comments
 (0)