Skip to content

Commit 53be74c

Browse files
committed
core: remove a couple of styled(flex) calls
1 parent 61a04cf commit 53be74c

File tree

20 files changed

+120
-149
lines changed

20 files changed

+120
-149
lines changed

static/app/components/commandPalette/ui/content.tsx

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {Fragment, useCallback, useLayoutEffect, useMemo, useRef} from 'react';
2-
import styled from '@emotion/styled';
2+
import {useTheme} from '@emotion/react';
33
import {Item, Section} from '@react-stately/collections';
44

55
import {Flex} from '@sentry/scraps/layout';
@@ -10,6 +10,7 @@ import {COMMAND_PALETTE_GROUP_KEY_CONFIG} from 'sentry/components/commandPalette
1010
import {CommandPaletteList} from 'sentry/components/commandPalette/ui/list';
1111
import {useCommandPaletteState} from 'sentry/components/commandPalette/ui/useCommandPaletteState';
1212
import type {MenuListItemProps} from 'sentry/components/core/menuListItem';
13+
import type {Theme} from 'sentry/utils/theme';
1314
import {unreachable} from 'sentry/utils/unreachable';
1415
import normalizeUrl from 'sentry/utils/url/normalizeUrl';
1516
import {useNavigate} from 'sentry/utils/useNavigate';
@@ -21,23 +22,31 @@ type CommandPaletteActionMenuItem = MenuListItemProps & {
2122
};
2223

2324
function actionToMenuItem(
24-
action: CommandPaletteActionWithKey
25+
action: CommandPaletteActionWithKey,
26+
theme: Theme
2527
): CommandPaletteActionMenuItem {
2628
return {
2729
key: action.key,
2830
label: action.display.label,
2931
details: action.display.details,
3032
leadingItems: action.display.icon ? (
31-
<IconWrap align="center" justify="center">
33+
<Flex
34+
align="center"
35+
justify="center"
36+
width={theme.iconSizes.md}
37+
height={theme.iconSizes.md}
38+
>
3239
{action.display.icon}
33-
</IconWrap>
40+
</Flex>
3441
) : undefined,
35-
children: action.type === 'group' ? action.actions.map(actionToMenuItem) : [],
42+
children:
43+
action.type === 'group' ? action.actions.map(a => actionToMenuItem(a, theme)) : [],
3644
hideCheck: true,
3745
};
3846
}
3947

4048
export function CommandPaletteContent() {
49+
const theme = useTheme();
4150
const {actions, selectedAction, selectAction, clearSelection, query, setQuery} =
4251
useCommandPaletteState();
4352
const navigate = useNavigate();
@@ -50,7 +59,7 @@ export function CommandPaletteContent() {
5059
? (COMMAND_PALETTE_GROUP_KEY_CONFIG[action.groupingKey]?.label ?? '')
5160
: '';
5261
const list = itemsBySection.get(sectionLabel) ?? [];
53-
list.push(actionToMenuItem(action));
62+
list.push(actionToMenuItem(action, theme));
5463
itemsBySection.set(sectionLabel, list);
5564
}
5665

@@ -64,7 +73,7 @@ export function CommandPaletteContent() {
6473
};
6574
})
6675
.filter(section => section.children.length > 0);
67-
}, [actions]);
76+
}, [actions, theme]);
6877

6978
const handleSelect = useCallback(
7079
(action: CommandPaletteActionWithKey) => {
@@ -132,8 +141,3 @@ export function CommandPaletteContent() {
132141
</Fragment>
133142
);
134143
}
135-
136-
const IconWrap = styled(Flex)`
137-
width: ${p => p.theme.iconSizes.md};
138-
height: ${p => p.theme.iconSizes.md};
139-
`;

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ const omitFlexProps = new Set<keyof FlexLayoutProps | 'as'>([
1717
'wrap',
1818
]);
1919

20+
type PlaceItems = 'start' | 'end' | 'center' | 'baseline' | 'stretch';
21+
2022
interface FlexLayoutProps {
2123
/**
2224
* Aligns flex items along the cross axis of the current line of flex items.
@@ -39,13 +41,19 @@ interface FlexLayoutProps {
3941
* Specifies the spacing between flex items.
4042
*/
4143
gap?: Responsive<SpacingSize | `${SpacingSize} ${SpacingSize}`>;
44+
4245
/**
4346
* Aligns flex items along the block axis of the current line of flex items.
4447
* Uses CSS justify-content property.
4548
*/
4649
justify?: Responsive<
4750
'start' | 'end' | 'center' | 'between' | 'around' | 'evenly' | 'left' | 'right'
4851
>;
52+
/**
53+
* Shorthand property for align-items and justify-items.
54+
*
55+
*/
56+
placeItems?: Responsive<PlaceItems | `${PlaceItems} ${PlaceItems}`>;
4957
/**
5058
* Specifies the wrapping behavior of the flex items.
5159
*/
@@ -70,6 +78,7 @@ export const Flex = styled(Container, {
7078
${p => rc('flex-direction', p.direction, p.theme)};
7179
${p => rc('flex-wrap', p.wrap, p.theme)};
7280
${p => rc('flex', p.flex, p.theme)};
81+
${p => rc('place-items', p.placeItems, p.theme)};
7382
${p =>
7483
rc('justify-content', p.justify, p.theme, (value, _breakpoint, _theme) => {
7584
switch (value) {

static/app/components/events/groupingInfo/groupingInfo.tsx

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import {Fragment, useState} from 'react';
2-
import styled from '@emotion/styled';
32

4-
import {Flex} from 'sentry/components/core/layout';
3+
import {Flex} from '@sentry/scraps/layout';
4+
import {Separator} from '@sentry/scraps/separator';
5+
56
import {SegmentedControl} from 'sentry/components/core/segmentedControl';
67
import {GroupInfoSummary} from 'sentry/components/events/groupingInfo/groupingSummary';
78
import {useEventGroupingInfo} from 'sentry/components/events/groupingInfo/useEventGroupingInfo';
@@ -70,7 +71,7 @@ export default function GroupingInfo({
7071

7172
return (
7273
<Fragment>
73-
<ConfigHeader>
74+
<Flex justify="between" gap="md" marginBottom="2xs">
7475
{hasStreamlinedUI && (
7576
<GroupInfoSummary
7677
event={event}
@@ -86,8 +87,8 @@ export default function GroupingInfo({
8687
{feedbackComponent}
8788
</div>
8889
)}
89-
</ConfigHeader>
90-
<ToggleContainer>
90+
</Flex>
91+
<Flex justify="start" paddingBottom="lg">
9192
<SegmentedControl
9293
aria-label={t('Filter by contribution')}
9394
size="xs"
@@ -99,7 +100,7 @@ export default function GroupingInfo({
99100
</SegmentedControl.Item>
100101
<SegmentedControl.Item key="all">{t('All Values')}</SegmentedControl.Item>
101102
</SegmentedControl>
102-
</ToggleContainer>
103+
</Flex>
103104
{isError ? <LoadingError message={t('Failed to fetch grouping info.')} /> : null}
104105
{isPending && !hasPerformanceGrouping ? <LoadingIndicator /> : null}
105106
{hasPerformanceGrouping || isSuccess
@@ -112,27 +113,12 @@ export default function GroupingInfo({
112113
variant={variant}
113114
showNonContributing={showNonContributing}
114115
/>
115-
{index < filteredVariants.length - 1 && <VariantDivider />}
116+
{index < filteredVariants.length - 1 && (
117+
<Separator orientation="horizontal" />
118+
)}
116119
</Fragment>
117120
))
118121
: null}
119122
</Fragment>
120123
);
121124
}
122-
123-
const ConfigHeader = styled('div')`
124-
display: flex;
125-
justify-content: space-between;
126-
gap: ${p => p.theme.space.md};
127-
margin-bottom: ${p => p.theme.space['2xs']};
128-
`;
129-
130-
const ToggleContainer = styled(Flex)`
131-
justify-content: flex-start;
132-
padding-bottom: ${p => p.theme.space.lg};
133-
`;
134-
135-
const VariantDivider = styled('hr')`
136-
padding-top: ${p => p.theme.space.md};
137-
border-top: 1px solid ${p => p.theme.border};
138-
`;

static/app/components/events/interfaces/crashContent/exception/content.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -206,15 +206,15 @@ function InnerContent({
206206
{...{hiddenExceptions, toggleRelatedExceptions, values, exception}}
207207
/>
208208
{exception.mechanism || hasCoverageData ? (
209-
<RowWrapper direction="row" justify="between">
209+
<Flex direction="row" justify="between" margin="xl 0 xs 0">
210210
{exception.mechanism && (
211211
<Mechanism
212212
data={exception.mechanism}
213213
meta={meta?.[exceptionIdx]?.mechanism}
214214
/>
215215
)}
216216
{hasCoverageData ? <LineCoverageLegend /> : null}
217-
</RowWrapper>
217+
</Flex>
218218
) : null}
219219
<RelatedExceptions
220220
mechanism={exception.mechanism}
@@ -411,7 +411,3 @@ const StyledFoldSection = styled(FoldSection)`
411411
margin-right: ${p => p.theme.space.xl};
412412
}
413413
`;
414-
415-
const RowWrapper = styled(Flex)`
416-
margin: ${p => p.theme.space.xl} 0 ${p => p.theme.space.xs} 0;
417-
`;

static/app/components/events/interfaces/threads/threadSelector/index.tsx

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import {useMemo, useState} from 'react';
22
import styled from '@emotion/styled';
33

4+
import {Flex, type FlexProps} from '@sentry/scraps/layout';
5+
46
import {CompactSelect} from 'sentry/components/core/compactSelect';
5-
import {Flex} from 'sentry/components/core/layout';
67
import {IconArrow} from 'sentry/icons';
78
import {t} from 'sentry/locale';
89
import {space} from 'sentry/styles/space';
@@ -264,10 +265,15 @@ const SortableThreadSelectorGridCell = styled(ThreadSelectorGridCell)`
264265
}
265266
`;
266267

267-
const HeaderText = styled(Flex)`
268-
display: flex;
269-
align-items: center;
270-
justify-content: flex-start;
271-
gap: ${space(0.5)};
272-
padding: 0 ${space(0.5)};
273-
`;
268+
function HeaderText(props: FlexProps) {
269+
return (
270+
<Flex
271+
gap="xs"
272+
display="flex"
273+
align="center"
274+
justify="start"
275+
padding="0 xs"
276+
{...props}
277+
/>
278+
);
279+
}

static/app/components/feedback/list/feedbackListItem.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import styled from '@emotion/styled';
33
import {ActorAvatar} from 'sentry/components/core/avatar/actorAvatar';
44
import {Checkbox} from 'sentry/components/core/checkbox';
55
import InteractionStateLayer from 'sentry/components/core/interactionStateLayer';
6-
import {Flex} from 'sentry/components/core/layout';
6+
import {Flex, type FlexProps} from 'sentry/components/core/layout';
77
import {Link} from 'sentry/components/core/link';
88
import {Tooltip} from 'sentry/components/core/tooltip';
99
import IssueTrackingSignals from 'sentry/components/feedback/list/issueTrackingSignals';
@@ -202,9 +202,9 @@ const LinkedFeedbackCard = styled(Link)`
202202
align-items: center;
203203
`;
204204

205-
const Row = styled(Flex)`
206-
place-items: center;
207-
`;
205+
function Row(props: FlexProps) {
206+
return <Flex place-items="center" {...props} />;
207+
}
208208

209209
const BottomGrid = styled('div')`
210210
display: grid;

static/app/components/profiling/flamegraph/flamegraphContextMenu.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -642,10 +642,10 @@ function ProfileIdsSubMenu(props: {
642642
setIsOpen(true);
643643
}}
644644
>
645-
<FullWidthFlex justify="between" align="center">
645+
<Flex justify="between" align="center" width="100%">
646646
<div>{t('Appears in %s profiles', props.profileIds.length)}</div>
647647
<IconChevron direction="right" size="xs" />
648-
</FullWidthFlex>
648+
</Flex>
649649
</ProfilingContextMenuItemButton>
650650
{isOpen &&
651651
props.subMenuPortalRef &&
@@ -712,7 +712,3 @@ function ProfileIdsSubMenu(props: {
712712
</Fragment>
713713
);
714714
}
715-
716-
const FullWidthFlex = styled(Flex)`
717-
width: 100%;
718-
`;

static/app/components/replays/list/__stories__/replayListItem.tsx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import {useTheme} from '@emotion/react';
12
import styled from '@emotion/styled';
23
import invariant from 'invariant';
34

@@ -25,6 +26,7 @@ interface Props {
2526
}
2627

2728
export default function ReplayListItem({replay, onClick}: Props) {
29+
const theme = useTheme();
2830
const organization = useOrganization();
2931
const project = useProjectFromId({project_id: replay.project_id ?? undefined});
3032

@@ -36,9 +38,9 @@ export default function ReplayListItem({replay, onClick}: Props) {
3638
if (replay.is_archived) {
3739
return (
3840
<Flex gap="md" align="center" justify="center">
39-
<ArchivedWrapper>
41+
<Flex justify="center" align="center" width={theme.space['2xl']}>
4042
<IconDelete color="gray500" size="md" />
41-
</ArchivedWrapper>
43+
</Flex>
4244

4345
<Flex direction="column" gap="xs">
4446
<DisplayName>{t('Deleted Replay')}</DisplayName>
@@ -105,12 +107,6 @@ const CardSpacing = styled('div')`
105107
padding: ${space(0.5)} ${space(0.5)} 0 ${space(0.5)};
106108
`;
107109

108-
const ArchivedWrapper = styled(Flex)`
109-
width: ${p => p.theme.space['2xl']};
110-
align-items: center;
111-
justify-content: center;
112-
`;
113-
114110
const SubText = styled('div')`
115111
font-size: 0.875em;
116112
line-height: normal;

static/app/components/replays/table/replayTableColumns.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {PlatformIcon} from 'platformicons';
66

77
import {LinkButton} from 'sentry/components/core/button/linkButton';
88
import {Checkbox} from 'sentry/components/core/checkbox';
9-
import {Flex} from 'sentry/components/core/layout/flex';
9+
import {Flex, type FlexProps} from 'sentry/components/core/layout/flex';
1010
import {ExternalLink, Link} from 'sentry/components/core/link';
1111
import {Tooltip} from 'sentry/components/core/tooltip';
1212
import Duration from 'sentry/components/duration/duration';
@@ -588,11 +588,9 @@ const DetailsLink = styled(Link)`
588588
line-height: 0;
589589
`;
590590

591-
const DropdownContainer = styled(Flex)`
592-
position: relative;
593-
flex-direction: column;
594-
justify-content: center;
595-
`;
591+
function DropdownContainer(props: FlexProps) {
592+
return <Flex position="relative" direction="column" justify="center" {...props} />;
593+
}
596594

597595
const TabularNumber = styled('div')`
598596
font-variant-numeric: tabular-nums;

static/app/views/automations/components/automationBuilder.tsx

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import styled from '@emotion/styled';
44
import {fetchOrgMembers} from 'sentry/actionCreators/members';
55
import {Alert} from 'sentry/components/core/alert';
66
import {Button} from 'sentry/components/core/button';
7-
import {Flex} from 'sentry/components/core/layout';
7+
import {Flex, Stack, type FlexProps} from 'sentry/components/core/layout';
88
import {Select} from 'sentry/components/core/select';
99
import {ConditionBadge} from 'sentry/components/workflowEngine/ui/conditionBadge';
1010
import {PurpleTextButton} from 'sentry/components/workflowEngine/ui/purpleTextButton';
@@ -234,16 +234,13 @@ function ActionFilterBlock({actionFilter}: ActionFilterBlockProps) {
234234
);
235235
}
236236

237-
const Step = styled(Flex)`
238-
flex-direction: column;
239-
gap: ${p => p.theme.space.sm};
240-
`;
237+
function Step(props: FlexProps) {
238+
return <Stack gap="sm" {...props} />;
239+
}
241240

242-
const StepLead = styled(Flex)`
243-
align-items: center;
244-
gap: ${p => p.theme.space.xs};
245-
margin-bottom: ${p => p.theme.space.xs};
246-
`;
241+
function StepLead(props: FlexProps) {
242+
return <Flex align="center" gap="xs" marginBottom="xs" {...props} />;
243+
}
247244

248245
const EmbeddedSelectField = styled(Select)`
249246
padding: 0;

0 commit comments

Comments
 (0)