Skip to content

Commit dfec2a2

Browse files
committed
refactor: notification row layouts
Signed-off-by: Adam Setch <[email protected]>
1 parent 37d5907 commit dfec2a2

36 files changed

+4202
-3710
lines changed

src/renderer/components/avatars/AvatarWithFallback.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export const AvatarWithFallback: React.FC<IAvatarWithFallback> = ({
3232
align="center"
3333
gap="condensed"
3434
data-testid="avatar"
35+
className="truncate"
3536
>
3637
{!src || isBroken ? (
3738
isNonHuman ? (
@@ -48,7 +49,12 @@ export const AvatarWithFallback: React.FC<IAvatarWithFallback> = ({
4849
onError={() => setIsBroken(true)}
4950
/>
5051
)}
51-
{name && <Text>{name}</Text>}
52+
{name && (
53+
// TODO add truncation logic for long names
54+
<Text className="block truncate flex-shrink overflow-ellipsis">
55+
{name}
56+
</Text>
57+
)}
5258
</Stack>
5359
);
5460
};

src/renderer/components/avatars/__snapshots__/AvatarWithFallback.test.tsx.snap

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

src/renderer/components/fields/Checkbox.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export const Checkbox: FC<ICheckbox> = (props: ICheckbox) => {
2222
checked={props.checked}
2323
onChange={props.onChange}
2424
disabled={props.disabled}
25+
data-testid={`checkbox-${props.name}`}
2526
/>
2627

2728
<div className="flex items-center ml-3">

src/renderer/components/fields/RadioGroup.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export const RadioGroup: FC<IRadioGroup> = (props: IRadioGroup) => {
2121
aria-labelledby={props.name}
2222
>
2323
{props.options.map((item) => {
24-
const name = `${props.name}_${item.value.toLowerCase()}`;
24+
const name = `radio-${props.name}-${item.value}`.toLowerCase();
2525

2626
return (
2727
<div className="flex items-center gap-2" key={name}>
@@ -33,6 +33,7 @@ export const RadioGroup: FC<IRadioGroup> = (props: IRadioGroup) => {
3333
value={item.value}
3434
onChange={props.onChange}
3535
checked={item.value === props.value}
36+
data-testid={name}
3637
/>
3738
<FieldLabel name={name} label={item.label} />
3839
</div>

src/renderer/components/fields/Tooltip.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { type ITooltip, Tooltip } from './Tooltip';
33

44
describe('renderer/components/fields/Tooltip.tsx', () => {
55
const props: ITooltip = {
6-
name: 'tooltip',
6+
name: 'test',
77
tooltip: 'This is some tooltip text',
88
};
99

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

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

2020
fireEvent.mouseEnter(tooltipElement);
2121
expect(tooltipElement).toMatchSnapshot();
Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { QuestionIcon } from '@primer/octicons-react';
2+
import { Box } from '@primer/react';
23
import { type FC, type ReactNode, useState } from 'react';
34

45
export interface ITooltip {
@@ -10,21 +11,22 @@ export const Tooltip: FC<ITooltip> = (props: ITooltip) => {
1011
const [showTooltip, setShowTooltip] = useState(false);
1112

1213
return (
13-
<span
14+
<Box
1415
id={props.name}
1516
aria-label={props.name}
1617
className="relative"
1718
onMouseEnter={() => setShowTooltip(true)}
1819
onMouseLeave={() => setShowTooltip(false)}
20+
data-testid={`tooltip-${props.name}`}
1921
>
2022
<QuestionIcon className="ml-1 text-gitify-tooltip-icon" />
2123
{showTooltip && (
22-
<div className="absolute left-[-80px] z-10 w-60 rounded-sm border border-gray-300 p-2 shadow-sm bg-gitify-tooltip-popout">
23-
<div className="text-left text-xs text-gitify-font">
24+
<Box className="absolute left-[-80px] z-10 w-60 rounded-sm border border-gray-300 p-2 shadow-sm bg-gitify-tooltip-popout">
25+
<Box className="text-left text-xs text-gitify-font">
2426
{props.tooltip}
25-
</div>
26-
</div>
27+
</Box>
28+
</Box>
2729
)}
28-
</span>
30+
</Box>
2931
);
3032
};

src/renderer/components/fields/__snapshots__/Checkbox.test.tsx.snap

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

0 commit comments

Comments
 (0)