Skip to content

Commit 5097ed1

Browse files
authored
Merge pull request #258 from IFRCGo/feature/use-spacing-tokens-in-grid
Minor styling fixes
2 parents c5bbff5 + 615049b commit 5097ed1

File tree

10 files changed

+136
-172
lines changed

10 files changed

+136
-172
lines changed

src/components/Grid/index.tsx

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,14 @@ import { _cs, isNotDefined } from '@togglecorp/fujs';
33

44
import Message from '#components/Message';
55
import RawList, { type Props as RawListProps, type ListKey } from '#components/RawList';
6-
import type { SpacingType } from '#components/types';
76
import useTranslation from '#hooks/useTranslation';
7+
import { type SpacingType } from '#components/types';
8+
import useSpacingTokens from '#hooks/useSpacingTokens';
89

910
import i18n from './i18n.json';
1011
import styles from './styles.module.css';
1112

1213
type NumColumn = 2 | 3 | 4 | 5;
13-
const spacingTypeToClassNameMap: Record<SpacingType, string> = {
14-
none: styles.noSpacing,
15-
condensed: styles.condensedSpacing,
16-
compact: styles.compactSpacing,
17-
cozy: styles.cozySpacing,
18-
default: styles.defaultSpacing,
19-
comfortable: styles.comfortableSpacing,
20-
relaxed: styles.relaxedSpacing,
21-
loose: styles.looseSpacing,
22-
};
2314

2415
export interface Props<
2516
DATUM,
@@ -93,6 +84,8 @@ function Grid<DATUM, KEY extends ListKey, RENDERER_PROPS>(
9384
[pending, filtered, errored, errorMessage, pendingMessage, filteredMessage, emptyMessage],
9485
);
9586

87+
const gapSpacing = useSpacingTokens({ spacing });
88+
9689
return (
9790
<div
9891
className={_cs(
@@ -101,7 +94,7 @@ function Grid<DATUM, KEY extends ListKey, RENDERER_PROPS>(
10194
numPreferredColumns === 3 && styles.threeColumns,
10295
numPreferredColumns === 4 && styles.fourColumns,
10396
numPreferredColumns === 5 && styles.fiveColumns,
104-
spacingTypeToClassNameMap[spacing],
97+
gapSpacing,
10598
pending && styles.pending,
10699
compact && styles.compact,
107100
className,

src/components/Grid/styles.module.css

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
.grid {
2-
--spacing: var(--go-ui-spacing-md);
32
--num-columns: 2;
43
--max-width: calc(var(--go-ui-page-width-max) * 0.8);
54

65
display: grid;
7-
grid-gap: var(--spacing);
86
grid-template-columns: repeat(auto-fill, minmax(calc(var(--max-width) / var(--num-columns)), 1fr));
97
position: relative;
108
min-height: var(--go-ui-content-min-height);
@@ -55,36 +53,4 @@
5553
&.five-columns {
5654
--num-columns: 5;
5755
}
58-
59-
&.no-spacing {
60-
--spacing: 0;
61-
}
62-
63-
&.condensed-spacing {
64-
--spacing: var(--go-ui-spacing-2xs);
65-
}
66-
67-
&.compact-spacing {
68-
--spacing: var(--go-ui-spacing-xs);
69-
}
70-
71-
&.cozy-spacing {
72-
--spacing: var(--go-ui-spacing-sm);
73-
}
74-
75-
&.default-spacing {
76-
--spacing: var(--go-ui-spacing-md);
77-
}
78-
79-
&.comfortable-spacing {
80-
--spacing: var(--go-ui-spacing-lg);
81-
}
82-
83-
&.relaxed-spacing {
84-
--spacing: var(--go-ui-spacing-xl);
85-
}
86-
87-
&.loose-spacing {
88-
--spacing: var(--go-ui-spacing-2xl);
89-
}
9056
}

src/components/Header/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ function Header(props: Props) {
106106
iconsContainerClassName,
107107
withoutWrap: !wrapHeadingContent,
108108
spacing,
109+
variant: 'sm',
109110
});
110111

111112
const gapSpacing = useSpacingTokens({

src/components/Link/index.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ export type Props<OMISSION extends string = never> = Omit<RouterLinkProps, 'to'
106106
withLinkIcon?: boolean;
107107
withUnderline?: boolean;
108108
ellipsize?: boolean;
109+
spacing?: ButtonFeatureProps['spacing'];
109110
}, OMISSION> & ({
110111
external?: never;
111112
to: keyof WrappedRoutes | undefined | null;
@@ -136,6 +137,7 @@ function Link(props: Props) {
136137
withLinkIcon,
137138
variant = 'tertiary',
138139
ellipsize,
140+
spacing,
139141

140142
// eslint-disable-next-line @typescript-eslint/no-unused-vars
141143
external,
@@ -178,6 +180,7 @@ function Link(props: Props) {
178180
variant,
179181
ellipsize,
180182
disabled,
183+
spacing,
181184
actions: (isDefined(actions) || withLinkIcon) ? (
182185
<>
183186
{actions}

src/components/Page/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ function Page(props: Props) {
100100
)}
101101
</div>
102102
)}
103-
{beforeHeaderContent}
103+
<PageContainer>
104+
{beforeHeaderContent}
105+
</PageContainer>
104106
{isNotDefined(blockingContent) && showPageContainer && (
105107
<PageHeader
106108
className={_cs(

src/components/domain/HighlightedOperations/OperationCard/index.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,6 @@ function OperationCard(props: Props) {
178178
<Link
179179
to="emergenciesLayout"
180180
urlParams={{ emergencyId: id }}
181-
ellipsize
182181
>
183182
{strings.operationCardTargetedPopulation}
184183
</Link>
@@ -194,7 +193,6 @@ function OperationCard(props: Props) {
194193
<Link
195194
to="emergencyReportsAndDocuments"
196195
urlParams={{ emergencyId: id }}
197-
ellipsize
198196
>
199197
{strings.operationCardFunding}
200198
</Link>

src/components/domain/OperationListItem/index.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ function OperationInfoCard(props: Props) {
5252
// FIXME: Let's add a link
5353
heading={name}
5454
headingLevel={5}
55-
ellipsizeHeading
5655
spacing="none"
5756
actions={(
5857
<Button

src/hooks/useBasicLayout/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ function useBasicLayout(props: Props) {
4141
variant,
4242
mode: 'gap',
4343
});
44+
4445
const innerGapSpacing = useSpacingTokens({
4546
spacing,
4647
variant,

0 commit comments

Comments
 (0)