Skip to content

refactor: account, repository and notification row layouts #1777

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

Merged
merged 4 commits into from
Jan 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions src/renderer/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
useLocation,
} from 'react-router-dom';

import { BaseStyles, ThemeProvider } from '@primer/react';
import { BaseStyles, Box, ThemeProvider } from '@primer/react';

import { Loading } from './components/Loading';
import { Sidebar } from './components/Sidebar';
Expand Down Expand Up @@ -47,7 +47,7 @@ export const App = () => {
<BaseStyles>
<AppProvider>
<Router>
<div className="flex flex-col min-h-screen overflow-x-hidden overflow-y-auto pl-sidebar bg-gitify-background">
<Box className="flex flex-col min-h-screen overflow-x-hidden overflow-y-auto pl-sidebar bg-gitify-background">
<Loading />
<Sidebar />
<Routes>
Expand Down Expand Up @@ -93,7 +93,7 @@ export const App = () => {
element={<LoginWithOAuthAppRoute />}
/>
</Routes>
</div>
</Box>
</Router>
</AppProvider>
</BaseStyles>
Expand Down
10 changes: 9 additions & 1 deletion src/renderer/components/avatars/AvatarWithFallback.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,15 @@ export const AvatarWithFallback: React.FC<IAvatarWithFallback> = ({
const [isBroken, setIsBroken] = useState(false);

const isNonHuman = isNonHumanUser(userType);

// TODO explore using AnchoredOverlay component (https://primer.style/components/anchored-overlay/react/alpha) to render Avatar Card on hover
return (
<Stack
direction="horizontal"
align="center"
gap="condensed"
data-testid="avatar"
className="truncate"
>
{!src || isBroken ? (
isNonHuman ? (
Expand All @@ -48,7 +51,12 @@ export const AvatarWithFallback: React.FC<IAvatarWithFallback> = ({
onError={() => setIsBroken(true)}
/>
)}
{name && <Text>{name}</Text>}
{name && (
// TODO add truncation logic for long names
<Text className="block truncate flex-shrink overflow-ellipsis">
{name}
</Text>
)}
</Stack>
);
};

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 31 additions & 26 deletions src/renderer/components/fields/Checkbox.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import type { FC, ReactNode } from 'react';

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

import { cn } from '../../utils/cn';
import { Tooltip } from './Tooltip';

Expand All @@ -13,32 +16,34 @@ export interface ICheckbox {

export const Checkbox: FC<ICheckbox> = (props: ICheckbox) => {
return (
<div className="mt-3 mb-2 text-sm">
<div className="flex items-center">
<input
type="checkbox"
id={props.name}
className="size-4 rounded-sm cursor-pointer"
checked={props.checked}
onChange={props.onChange}
disabled={props.disabled}
/>
<Stack
direction="horizontal"
gap="condensed"
align="center"
className="text-sm"
>
<input
type="checkbox"
id={props.name}
className="size-4 rounded-sm cursor-pointer"
checked={props.checked}
onChange={props.onChange}
disabled={props.disabled}
data-testid={`checkbox-${props.name}`}
/>

<div className="flex items-center ml-3">
<label
htmlFor={props.name}
className={cn(
'font-medium text-gitify-font cursor-pointer',
props.disabled && 'line-through',
)}
>
{props.label}
</label>
{props.tooltip && (
<Tooltip name={`tooltip-${props.name}`} tooltip={props.tooltip} />
)}
</div>
</div>
</div>
<label
htmlFor={props.name}
className={cn(
'font-medium text-gitify-font cursor-pointer',
props.disabled && 'line-through',
)}
>
{props.label}
</label>
{props.tooltip && (
<Tooltip name={`tooltip-${props.name}`} tooltip={props.tooltip} />
)}
</Stack>
);
};
58 changes: 33 additions & 25 deletions src/renderer/components/fields/RadioGroup.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import type { ChangeEvent, FC } from 'react';

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

import type { RadioGroupItem } from '../../types';
import { FieldLabel } from './FieldLabel';

Expand All @@ -12,33 +15,38 @@ export interface IRadioGroup {

export const RadioGroup: FC<IRadioGroup> = (props: IRadioGroup) => {
return (
<div className="flex items-start my-2 text-sm font-medium">
<Stack
direction="horizontal"
gap="condensed"
align="center"
className="text-sm"
>
<FieldLabel name={props.name} label={props.label} />

<div
className="flex items-center space-x-4"
role="group"
aria-labelledby={props.name}
>
{props.options.map((item) => {
const name = `${props.name}_${item.value.toLowerCase()}`;
{props.options.map((item) => {
const name = `radio-${props.name}-${item.value}`.toLowerCase();

return (
<div className="flex items-center gap-2" key={name}>
<input
type="radio"
className="size-4 cursor-pointer"
id={name}
name={props.name}
value={item.value}
onChange={props.onChange}
checked={item.value === props.value}
/>
<FieldLabel name={name} label={item.label} />
</div>
);
})}
</div>
</div>
return (
<Stack
direction="horizontal"
gap="condensed"
align="center"
key={name}
>
<input
type="radio"
className="size-4 cursor-pointer"
id={name}
name={props.name}
value={item.value}
onChange={props.onChange}
checked={item.value === props.value}
data-testid={name}
/>
<FieldLabel name={name} label={item.label} />
</Stack>
);
})}
</Stack>
);
};
4 changes: 2 additions & 2 deletions src/renderer/components/fields/Tooltip.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { type ITooltip, Tooltip } from './Tooltip';

describe('renderer/components/fields/Tooltip.tsx', () => {
const props: ITooltip = {
name: 'tooltip',
name: 'test',
tooltip: 'This is some tooltip text',
};

Expand All @@ -15,7 +15,7 @@ describe('renderer/components/fields/Tooltip.tsx', () => {
it('should display on mouse enter / leave', () => {
render(<Tooltip {...props} />);

const tooltipElement = screen.getByLabelText('tooltip');
const tooltipElement = screen.getByTestId('tooltip-test');

fireEvent.mouseEnter(tooltipElement);
expect(tooltipElement).toMatchSnapshot();
Expand Down
Loading
Loading