Skip to content

Commit 953a189

Browse files
committedJul 8, 2024
style: legend text and icon alignment
1 parent cd40d10 commit 953a189

12 files changed

+71
-21
lines changed
 

‎src/components/settings/AppearanceSettings.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { mockAuth, mockSettings } from '../../__mocks__/state-mocks';
44
import { AppContext } from '../../context/App';
55
import { AppearanceSettings } from './AppearanceSettings';
66

7-
describe('routes/components/AppearanceSettings.tsx', () => {
7+
describe('routes/components/settings/AppearanceSettings.tsx', () => {
88
const updateSetting = jest.fn();
99

1010
afterEach(() => {

‎src/components/settings/AppearanceSettings.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { Size, Theme } from '../../types';
1313
import { setTheme } from '../../utils/theme';
1414
import { Checkbox } from '../fields/Checkbox';
1515
import { RadioGroup } from '../fields/RadioGroup';
16+
import { Legend } from './Legend';
1617

1718
export const AppearanceSettings: FC = () => {
1819
const { settings, updateSetting } = useContext(AppContext);
@@ -27,10 +28,7 @@ export const AppearanceSettings: FC = () => {
2728

2829
return (
2930
<fieldset>
30-
<legend id="appearance" className="mb-1 mt-2 font-semibold">
31-
<PaintbrushIcon className="mr-2" />
32-
Appearance
33-
</legend>
31+
<Legend icon={PaintbrushIcon}>Appearance</Legend>
3432
<RadioGroup
3533
name="theme"
3634
label="Theme:"
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { PersonFillIcon } from '@primer/octicons-react';
2+
import { render } from '@testing-library/react';
3+
import { Legend } from './Legend';
4+
5+
describe('routes/components/settings/Legend.tsx', () => {
6+
it('should render the legend', async () => {
7+
const { container } = render(<Legend icon={PersonFillIcon}>Legend</Legend>);
8+
9+
expect(container).toMatchSnapshot();
10+
});
11+
});

‎src/components/settings/Legend.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import type { Icon } from '@primer/octicons-react';
2+
import type { FC } from 'react';
3+
4+
interface ILegend {
5+
icon: Icon;
6+
children: string;
7+
}
8+
9+
export const Legend: FC<ILegend> = (props) => {
10+
return (
11+
<legend
12+
id={props.children.toLowerCase().replace(' ', '-')}
13+
className="mb-1 mt-2 font-semibold flex items-center"
14+
>
15+
<props.icon className="mr-2" />
16+
{props.children}
17+
</legend>
18+
);
19+
};

‎src/components/settings/NotificationSettings.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { AppContext } from '../../context/App';
55
import * as comms from '../../utils/comms';
66
import { NotificationSettings } from './NotificationSettings';
77

8-
describe('routes/components/NotificationSettings.tsx', () => {
8+
describe('routes/components/settings/NotificationSettings.tsx', () => {
99
const updateSetting = jest.fn();
1010

1111
afterEach(() => {

‎src/components/settings/NotificationSettings.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,14 @@ import { GroupBy } from '../../types';
55
import { openGitHubParticipatingDocs } from '../../utils/links';
66
import { Checkbox } from '../fields/Checkbox';
77
import { RadioGroup } from '../fields/RadioGroup';
8+
import { Legend } from './Legend';
89

910
export const NotificationSettings: FC = () => {
1011
const { settings, updateSetting } = useContext(AppContext);
1112

1213
return (
1314
<fieldset>
14-
<legend id="notifications" className="mb-1 mt-2 font-semibold">
15-
<BellIcon className="mr-2" />
16-
Notifications
17-
</legend>
15+
<Legend icon={BellIcon}>Notifications</Legend>
1816
<RadioGroup
1917
name="groupBy"
2018
label="Group by:"

‎src/components/settings/SettingsFooter.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jest.mock('react-router-dom', () => ({
1111
useNavigate: () => mockNavigate,
1212
}));
1313

14-
describe('routes/components/SettingsFooter.tsx', () => {
14+
describe('routes/components/settings/SettingsFooter.tsx', () => {
1515
afterEach(() => {
1616
jest.clearAllMocks();
1717
process.env = originalEnv;

‎src/components/settings/SystemSettings.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { mockAuth, mockSettings } from '../../__mocks__/state-mocks';
44
import { AppContext } from '../../context/App';
55
import { SystemSettings } from './SystemSettings';
66

7-
describe('routes/components/SystemSettings.tsx', () => {
7+
describe('routes/components/settings/SystemSettings.tsx', () => {
88
const updateSetting = jest.fn();
99

1010
afterEach(() => {

‎src/components/settings/SystemSettings.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,14 @@ import { AppContext } from '../../context/App';
44
import Constants from '../../utils/constants';
55
import { isLinux, isMacOS } from '../../utils/platform';
66
import { Checkbox } from '../fields/Checkbox';
7+
import { Legend } from './Legend';
78

89
export const SystemSettings: FC = () => {
910
const { settings, updateSetting } = useContext(AppContext);
1011

1112
return (
1213
<fieldset>
13-
<legend id="system" className="mb-1 mt-2 font-semibold">
14-
<DeviceDesktopIcon className="mr-2" />
15-
System
16-
</legend>
14+
<Legend icon={DeviceDesktopIcon}>System</Legend>
1715
<Checkbox
1816
name="kbdShortcutEnabled"
1917
label="Enable keyboard shortcut"

‎src/components/settings/__snapshots__/Legend.test.tsx.snap

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

‎src/components/settings/__snapshots__/SettingsFooter.test.tsx.snap

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

‎src/routes/__snapshots__/Settings.test.tsx.snap

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

0 commit comments

Comments
 (0)