Skip to content

Commit a7fc484

Browse files
committed
feat: migrate to primer design tokens
Signed-off-by: Adam Setch <[email protected]>
1 parent 075fb41 commit a7fc484

File tree

11 files changed

+607
-336
lines changed

11 files changed

+607
-336
lines changed
Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
import { type FC, useContext, useMemo } from 'react';
22

3-
import { Stack } from '@primer/react';
4-
53
import { AppContext } from '../context/App';
64
import { Constants } from '../utils/constants';
75
import { hasFiltersSet } from '../utils/filters';
8-
import { Centered } from './layout/Centered';
9-
import { EmojiText } from './primitives/EmojiText';
6+
import { EmojiSplash } from './layout/EmojiSplash';
107

118
interface IAllRead {
129
fullHeight?: boolean;
@@ -25,21 +22,9 @@ export const AllRead: FC<IAllRead> = ({ fullHeight = true }: IAllRead) => {
2522
[],
2623
);
2724

28-
return (
29-
<Centered fullHeight={fullHeight}>
30-
<Stack direction="vertical" align="center">
31-
<div className="mt-2 mb-5 text-5xl">
32-
<EmojiText text={emoji} />
33-
</div>
25+
const heading = `No new ${hasFilters ? 'filtered ' : ''} notifications`;
3426

35-
{hasFilters ? (
36-
<div className="mb-2 text-xl font-semibold">
37-
No new filtered notifications
38-
</div>
39-
) : (
40-
<div className="mb-2 text-xl font-semibold">No new notifications</div>
41-
)}
42-
</Stack>
43-
</Centered>
27+
return (
28+
<EmojiSplash emoji={emoji} heading={heading} fullHeight={fullHeight} />
4429
);
4530
};

src/renderer/components/Oops.tsx

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import { type FC, useMemo } from 'react';
22

3-
import { Stack } from '@primer/react';
43
import type { GitifyError } from '../types';
5-
import { Centered } from './layout/Centered';
6-
import { EmojiText } from './primitives/EmojiText';
4+
import { EmojiSplash } from './layout/EmojiSplash';
75

86
interface IOops {
97
error: GitifyError;
@@ -17,22 +15,11 @@ export const Oops: FC<IOops> = ({ error, fullHeight = true }: IOops) => {
1715
);
1816

1917
return (
20-
<Centered fullHeight={fullHeight}>
21-
<Stack direction="vertical" align="center">
22-
<div className="mt-2 text-5xl">
23-
<EmojiText text={emoji} />
24-
</div>
25-
26-
<div className="mb-2 text-xl font-semibold">{error.title}</div>
27-
{error.descriptions.map((description, i) => {
28-
return (
29-
// biome-ignore lint/suspicious/noArrayIndexKey: using index for key to keep the error constants clean
30-
<div className="mb-2 text-center" key={`error_description_${i}`}>
31-
{description}
32-
</div>
33-
);
34-
})}
35-
</Stack>
36-
</Centered>
18+
<EmojiSplash
19+
emoji={emoji}
20+
heading={error.title}
21+
subHeadings={error.descriptions}
22+
fullHeight={fullHeight}
23+
/>
3724
);
3825
};

src/renderer/components/__snapshots__/AllRead.test.tsx.snap

Lines changed: 60 additions & 32 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/renderer/components/__snapshots__/Oops.test.tsx.snap

Lines changed: 32 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/renderer/components/layout/Centered.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ export const Centered: FC<ICentered> = ({
1212
}: ICentered) => {
1313
return (
1414
<Stack
15-
direction={'vertical'}
16-
align={'center'}
17-
justify={'center'}
18-
padding={'spacious'}
15+
direction="vertical"
16+
align="center"
17+
justify="center"
18+
padding="spacious"
1919
className={fullHeight && 'min-h-screen'}
2020
>
2121
{props.children}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { render } from '@testing-library/react';
2+
import { EmojiSplash } from './EmojiSplash';
3+
4+
describe('renderer/components/layout/EmojiSplash.tsx', () => {
5+
it('should render itself & its children - heading only', () => {
6+
const tree = render(<EmojiSplash emoji="🍺" heading="Test Heading" />);
7+
8+
expect(tree).toMatchSnapshot();
9+
});
10+
11+
it('should render itself & its children - heading and sub-heading', () => {
12+
const tree = render(
13+
<EmojiSplash
14+
emoji="🍺"
15+
heading="Test Heading"
16+
subHeadings={['Test Sub-Heading']}
17+
/>,
18+
);
19+
20+
expect(tree).toMatchSnapshot();
21+
});
22+
});

0 commit comments

Comments
 (0)