Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: adopt primer design system ui components #1589

Open
wants to merge 46 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
324d302
refactor: adopt primer ui components
setchy Oct 12, 2024
a4b8cf4
refactor: adopt primer ui components
setchy Oct 12, 2024
e3b9306
refactor: adopt primer ui components
setchy Oct 12, 2024
5f929a3
refactor: adopt primer ui components
setchy Oct 13, 2024
5084f8e
refactor: adopt primer ui components
setchy Oct 13, 2024
5dac73c
refactor: adopt primer ui components
setchy Oct 13, 2024
9a48cd2
refactor: adopt primer ui components
setchy Oct 13, 2024
8285d8a
refactor: adopt primer ui components
setchy Oct 13, 2024
d261edc
refactor: adopt primer ui components
setchy Oct 13, 2024
ac86153
refactor: adopt primer ui components
setchy Oct 13, 2024
717be94
refactor: adopt primer ui components
setchy Oct 13, 2024
79e7e8b
refactor: adopt primer ui components
setchy Oct 13, 2024
b1f8307
refactor: test
setchy Oct 14, 2024
575b818
refactor
setchy Oct 14, 2024
8f2b5c0
fix tests
setchy Oct 14, 2024
e88f9f5
feat: shrink sidebar width
setchy Oct 14, 2024
486f3d7
fix hover group alignment
setchy Oct 14, 2024
abb921a
sidebar width
setchy Oct 14, 2024
479559a
test: fix sidebar tests
setchy Oct 14, 2024
d7e4665
test: update test cases
setchy Oct 14, 2024
360b0f3
test: update test cases
setchy Oct 14, 2024
706f570
test: update test cases
setchy Oct 14, 2024
f231de5
test: update test cases
setchy Oct 14, 2024
7459698
Merge branch 'main' into refactor/primer-design-system
setchy Oct 14, 2024
45e75e7
fix small ui issues
setchy Oct 15, 2024
3a0de64
fix small ui issues
setchy Oct 15, 2024
12e73f2
fix account rendering for long names
setchy Oct 15, 2024
c63c17d
refactor: extract filters and show on all read screen
setchy Oct 15, 2024
967a545
fix heading alignment
setchy Oct 15, 2024
b1afe07
Merge branch 'main' into refactor/primer-design-system
setchy Oct 15, 2024
eec2e45
Merge branch 'main' into refactor/primer-design-system
setchy Oct 15, 2024
542b6f4
Merge branch 'main' into refactor/primer-design-system
setchy Oct 24, 2024
9aec736
Merge branch 'main' into refactor/primer-design-system
setchy Oct 24, 2024
c1edf25
feat: dialog
setchy Oct 26, 2024
8f621c9
fix tooltips
setchy Oct 26, 2024
0ac3997
feat: Avatar shape based on user type
setchy Oct 26, 2024
fef6ea1
Merge branch 'main' into refactor/primer-design-system
setchy Oct 29, 2024
f52fa19
Merge branch 'main' into refactor/primer-design-system
setchy Oct 29, 2024
905bf8e
feat: Avatar shape based on user type
setchy Oct 31, 2024
593a430
Merge branch 'main' into refactor/primer-design-system
setchy Dec 3, 2024
15c3589
incorporate feedback
setchy Dec 3, 2024
8baa2a8
incorporate feedback
setchy Dec 3, 2024
49c230a
incorporate feedback: border red on error
setchy Dec 3, 2024
e9ab9a5
fix account view formatting
setchy Dec 3, 2024
c0e6ba4
fix: formatting
afonsojramos Dec 6, 2024
835e46a
Merge branch 'main' into refactor/primer-design-system
afonsojramos Dec 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import type { Config } from 'jest';

const config: Config = {
preset: 'ts-jest',
setupFiles: ['<rootDir>/src/renderer/__helpers__/setupEnvVars.js'],
setupFiles: [
'<rootDir>/src/renderer/__helpers__/setupEnvVars.js',
'<rootDir>/jest.setup.js',
],
testEnvironment: 'jsdom',
collectCoverage: true,
collectCoverageFrom: ['src/**/*', '!**/__snapshots__/**'],
Expand Down
7 changes: 7 additions & 0 deletions jest.setup.js.js
setchy marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
if (typeof CSS === 'undefined') {
global.CSS = {};
}

if (!CSS.supports) {
CSS.supports = () => true;
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@
"@discordapp/twemoji": "15.1.0",
"@electron/notarize": "2.5.0",
"@primer/octicons-react": "19.11.0",
"@primer/react": "36.27.0",
"@testing-library/react": "16.0.1",
"@types/jest": "29.5.13",
"@types/node": "20.16.11",
Expand All @@ -148,7 +149,6 @@
"@types/react-router-dom": "5.3.3",
"autoprefixer": "10.4.20",
"axios": "1.7.7",
"class-variance-authority": "0.7.0",
"clsx": "2.1.1",
"concurrently": "9.0.1",
"copy-webpack-plugin": "12.0.2",
Expand Down
930 changes: 917 additions & 13 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

108 changes: 57 additions & 51 deletions src/renderer/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import { LoginWithOAuthAppRoute } from './routes/LoginWithOAuthApp';
import { LoginWithPersonalAccessTokenRoute } from './routes/LoginWithPersonalAccessToken';
import { NotificationsRoute } from './routes/Notifications';
import { SettingsRoute } from './routes/Settings';

import { BaseStyles, ThemeProvider } from '@primer/react';
import './App.css';

function RequireAuth({ children }) {
Expand All @@ -31,56 +33,60 @@ function RequireAuth({ children }) {

export const App = () => {
return (
<AppProvider>
<Router>
<div className="flex h-full overflow-y-auto flex-col pl-14">
<Loading />
<Sidebar />
<Routes>
<Route
path="/"
element={
<RequireAuth>
<NotificationsRoute />
</RequireAuth>
}
/>
<Route
path="/filters"
element={
<RequireAuth>
<FiltersRoute />
</RequireAuth>
}
/>
<Route
path="/settings"
element={
<RequireAuth>
<SettingsRoute />
</RequireAuth>
}
/>
<Route
path="/accounts"
element={
<RequireAuth>
<AccountsRoute />
</RequireAuth>
}
/>
<Route path="/login" element={<LoginRoute />} />
<Route
path="/login-personal-access-token"
element={<LoginWithPersonalAccessTokenRoute />}
/>
<Route
path="/login-oauth-app"
element={<LoginWithOAuthAppRoute />}
/>
</Routes>
</div>
</Router>
</AppProvider>
<ThemeProvider>
<BaseStyles>
<AppProvider>
<Router>
<div className="flex h-full overflow-y-auto flex-col pl-14">
<Loading />
<Sidebar />
<Routes>
<Route
path="/"
element={
<RequireAuth>
<NotificationsRoute />
</RequireAuth>
}
/>
<Route
path="/filters"
element={
<RequireAuth>
<FiltersRoute />
</RequireAuth>
}
/>
<Route
path="/settings"
element={
<RequireAuth>
<SettingsRoute />
</RequireAuth>
}
/>
<Route
path="/accounts"
element={
<RequireAuth>
<AccountsRoute />
</RequireAuth>
}
/>
<Route path="/login" element={<LoginRoute />} />
<Route
path="/login-personal-access-token"
element={<LoginWithPersonalAccessTokenRoute />}
/>
<Route
path="/login-oauth-app"
element={<LoginWithOAuthAppRoute />}
/>
</Routes>
</div>
</Router>
</AppProvider>
</BaseStyles>
</ThemeProvider>
);
};
75 changes: 39 additions & 36 deletions src/renderer/components/AccountNotifications.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
import {
FeedPersonIcon,
GitPullRequestIcon,
IssueOpenedIcon,
} from '@primer/octicons-react';
import { type FC, type MouseEvent, useContext, useMemo, useState } from 'react';

import { GitPullRequestIcon, IssueOpenedIcon } from '@primer/octicons-react';
import {
Avatar,
Button,
IconButton,
Stack,
Text,
Tooltip,
} from '@primer/react';

import { AppContext } from '../context/App';
import { type Account, type GitifyError, Opacity, Size } from '../types';
import { type Account, type GitifyError, Size } from '../types';
import type { Notification } from '../typesGitHub';
import { cn } from '../utils/cn';
import { getChevronDetails } from '../utils/helpers';
Expand All @@ -19,9 +25,6 @@ import { HoverGroup } from './HoverGroup';
import { NotificationRow } from './NotificationRow';
import { Oops } from './Oops';
import { RepositoryNotifications } from './RepositoryNotifications';
import { InteractionButton } from './buttons/InteractionButton';
import { AvatarIcon } from './icons/AvatarIcon';
import { PlatformIcon } from './icons/PlatformIcon';

interface IAccountNotifications {
account: Account;
Expand Down Expand Up @@ -74,61 +77,61 @@ export const AccountNotifications: FC<IAccountNotifications> = (
{showAccountHeader && (
<div
className={cn(
'group flex items-center justify-between px-3 py-1.5 text-sm font-semibold dark:text-white',
'group flex items-center justify-between pr-3 py-1.5 text-sm font-semibold dark:text-white',
props.error
? 'bg-red-300 dark:bg-red-500'
: 'bg-gray-300 dark:bg-gray-darkest',
Opacity.LOW,
)}
onClick={toggleAccountNotifications}
>
<div className="flex">
<button
type="button"
title="Open Profile"
<Tooltip text="Open profile" direction="s">
<Button
variant="invisible"
alignContent="center"
count={notifications.length}
onClick={(event: MouseEvent<HTMLElement>) => {
// Don't trigger onClick of parent element.
event.stopPropagation();
openAccountProfile(account);
}}
>
<div className="flex">
<AvatarIcon
title={account.user.login}
url={account.user.avatar}
size={Size.SMALL}
defaultIcon={FeedPersonIcon}
/>
<span className="ml-2">@{account.user.login}</span>
</div>
</button>
</div>
<Stack direction="horizontal" gap="condensed" align="center">
<Avatar src={account.user.avatar} size={Size.MEDIUM} />
<Text>@{account.user.login}</Text>
</Stack>
</Button>
</Tooltip>

<HoverGroup>
<PlatformIcon type={account.platform} size={Size.SMALL} />
<InteractionButton
title="My Issues"
<IconButton
aria-label="My Issues"
icon={IssueOpenedIcon}
size={Size.SMALL}
size="small"
variant="invisible"
onClick={(event: MouseEvent<HTMLElement>) => {
// Don't trigger onClick of parent element.
event.stopPropagation();
openGitHubIssues(account.hostname);
}}
/>
<InteractionButton
title="My Pull Requests"

<IconButton
aria-label="My Pull Requests"
icon={GitPullRequestIcon}
size={Size.SMALL}
size="small"
variant="invisible"
onClick={(event: MouseEvent<HTMLElement>) => {
// Don't trigger onClick of parent element.
event.stopPropagation();
openGitHubPulls(account.hostname);
}}
/>
<InteractionButton
title={Chevron.label}

<IconButton
aria-label={Chevron.label}
icon={Chevron.icon}
size={Size.SMALL}
size="small"
variant="invisible"
onClick={toggleAccountNotifications}
/>
</HoverGroup>
Expand Down
18 changes: 12 additions & 6 deletions src/renderer/components/AllRead.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { type FC, useMemo } from 'react';

import { Stack } from '@primer/react';

import { Constants } from '../utils/constants';
import { EmojiText } from './EmojiText';
import { Centered } from './primitives/Centered';

export const AllRead: FC = () => {
const emoji = useMemo(
Expand All @@ -12,12 +16,14 @@ export const AllRead: FC = () => {
);

return (
<div className="flex flex-1 flex-col items-center justify-center bg-white p-4 text-black dark:bg-gray-dark dark:text-white">
<div className="mt-2 mb-5 text-5xl">
<EmojiText text={emoji} />
</div>
<Centered>
<Stack direction="vertical" align="center">
<div className="mt-2 mb-5 text-5xl">
<EmojiText text={emoji} />
</div>

<div className="mb-2 text-xl font-semibold">No new notifications.</div>
</div>
<div className="mb-2 text-xl font-semibold">No new notifications</div>
</Stack>
</Centered>
);
};
1 change: 1 addition & 0 deletions src/renderer/components/EmojiText.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { type FC, useEffect, useRef } from 'react';

import { convertTextToEmojiImgHtml } from '../utils/emojis';

export interface IEmojiText {
Expand Down
48 changes: 27 additions & 21 deletions src/renderer/components/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { ArrowLeftIcon, type Icon } from '@primer/octicons-react';
import { type FC, useContext } from 'react';
import { useNavigate } from 'react-router-dom';

import { ArrowLeftIcon, type Icon } from '@primer/octicons-react';

import { Heading, IconButton, Octicon, Stack } from '@primer/react';
import { AppContext } from '../context/App';
import { Size } from '../types';
import { Legend } from './settings/Legend';

interface IHeader {
icon: Icon;
Expand All @@ -17,28 +19,32 @@ export const Header: FC<IHeader> = (props: IHeader) => {
const { fetchNotifications } = useContext(AppContext);

return (
<div className="mx-8 mt-2 flex items-center justify-between py-2">
<button
type="button"
className="focus:outline-none"
title="Go Back"
onClick={() => {
navigate(-1);
if (props.fetchOnBack) {
fetchNotifications();
}
}}
>
<ArrowLeftIcon
size={Size.XLARGE}
className="hover:text-gray-400"
<div className="mx-6 mt-2 py-2">
<Stack direction="horizontal" justify="space-between">
<IconButton
aria-label="Go Back"
variant="invisible"
tooltipDirection="e"
icon={ArrowLeftIcon}
onClick={() => {
navigate(-1);
if (props.fetchOnBack) {
fetchNotifications();
}
}}
/>
</button>

<h3 className="text-lg font-semibold flex items-center">
<Legend icon={props.icon}>{props.children}</Legend>
</h3>
<Stack direction="horizontal" align="center" gap="condensed">
<Octicon icon={props.icon} size={Size.LARGE} />
<Heading
sx={{
fontSize: 3,
}}
>
{props.children}
</Heading>
</Stack>
</Stack>
</div>
);
};
Loading
Loading