Skip to content

Commit 1f90a1e

Browse files
committed
Merge branch 'main' into feat/color-scheme
Signed-off-by: Adam Setch <[email protected]>
2 parents 0ee7bd5 + 854ff25 commit 1f90a1e

File tree

10 files changed

+347
-330
lines changed

10 files changed

+347
-330
lines changed

src/renderer/components/fields/Checkbox.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { FC, ReactNode } from 'react';
2+
import { cn } from '../../utils/cn';
23
import { Tooltip } from './Tooltip';
34

45
export interface ICheckbox {
@@ -26,10 +27,10 @@ export const Checkbox: FC<ICheckbox> = (props: ICheckbox) => {
2627
<div className="flex items-center ml-3">
2728
<label
2829
htmlFor={props.name}
29-
className="font-medium text-gitify-font cursor-pointer"
30-
style={
31-
props.disabled ? { textDecoration: 'line-through' } : undefined
32-
}
30+
className={cn(
31+
'font-medium text-gitify-font cursor-pointer',
32+
props.disabled && 'line-through',
33+
)}
3334
>
3435
{props.label}
3536
</label>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { render } from '@testing-library/react';
2+
import { FieldLabel, type IFieldLabel } from './FieldLabel';
3+
4+
describe('renderer/components/fields/FieldLabel.tsx', () => {
5+
const props: IFieldLabel = {
6+
name: 'appearance',
7+
label: 'Appearance',
8+
};
9+
10+
it('should render', () => {
11+
const tree = render(<FieldLabel {...props} />);
12+
expect(tree).toMatchSnapshot();
13+
});
14+
});
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import type { FC } from 'react';
2+
3+
export interface IFieldLabel {
4+
name: string;
5+
label: string;
6+
}
7+
8+
export const FieldLabel: FC<IFieldLabel> = (props: IFieldLabel) => {
9+
return (
10+
<label htmlFor={props.name} className="mr-3 font-medium cursor-pointer">
11+
{props.label}
12+
</label>
13+
);
14+
};

src/renderer/components/fields/RadioGroup.tsx

Lines changed: 27 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,43 @@
1-
import type { ChangeEvent, FC, ReactNode } from 'react';
1+
import type { ChangeEvent, FC } from 'react';
22
import type { RadioGroupItem } from '../../types';
3-
import { cn } from '../../utils/cn';
4-
import { Tooltip } from './Tooltip';
3+
import { FieldLabel } from './FieldLabel';
54

65
export interface IRadioGroup {
76
name: string;
87
label: string;
9-
tooltip?: ReactNode | string;
108
options: RadioGroupItem[];
119
value: string;
12-
disabled?: boolean;
1310
onChange: (event: ChangeEvent<HTMLInputElement>) => void;
14-
className?: string;
1511
}
1612

1713
export const RadioGroup: FC<IRadioGroup> = (props: IRadioGroup) => {
1814
return (
19-
<div className={cn('mt-3 mb-2 text-sm', props.className)}>
20-
<div className="flex items-start">
21-
<div className="mr-3">
22-
<label
23-
htmlFor={props.name}
24-
className="font-medium text-gitify-font"
25-
style={
26-
props.disabled ? { textDecoration: 'line-through' } : undefined
27-
}
28-
>
29-
{props.label}
30-
{props.tooltip && (
31-
<Tooltip name={`tooltip-${props.name}`} tooltip={props.tooltip} />
32-
)}
33-
</label>
34-
</div>
15+
<div className="flex items-start my-2 text-sm font-medium">
16+
<FieldLabel name={props.name} label={props.label} />
3517

36-
<div
37-
className="flex flex-wrap items-center space-x-4"
38-
role="group"
39-
aria-labelledby={props.name}
40-
>
41-
{props.options.map((item) => {
42-
return (
43-
<div
44-
className="flex items-center"
45-
key={`radio_item_${item.value.toLowerCase()}`}
46-
>
47-
<input
48-
type="radio"
49-
className="size-4 cursor-pointer"
50-
id={`${props.name}_${item.value.toLowerCase()}`}
51-
name={props.name}
52-
value={item.value}
53-
onChange={props.onChange}
54-
checked={item.value === props.value}
55-
disabled={props.disabled}
56-
/>
57-
<label
58-
htmlFor={`${props.name}_${item.value.toLowerCase()}`}
59-
className="ml-3 block text-sm font-medium text-gitify-font cursor-pointer"
60-
>
61-
{item.label}
62-
</label>
63-
</div>
64-
);
65-
})}
66-
</div>
18+
<div
19+
className="flex items-center space-x-4"
20+
role="group"
21+
aria-labelledby={props.name}
22+
>
23+
{props.options.map((item) => {
24+
const name = `${props.name}_${item.value.toLowerCase()}`;
25+
26+
return (
27+
<div className="flex items-center gap-2" key={name}>
28+
<input
29+
type="radio"
30+
className="size-4 cursor-pointer"
31+
id={name}
32+
name={props.name}
33+
value={item.value}
34+
onChange={props.onChange}
35+
checked={item.value === props.value}
36+
/>
37+
<FieldLabel name={name} label={item.label} />
38+
</div>
39+
);
40+
})}
6741
</div>
6842
</div>
6943
);

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

Lines changed: 76 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)