Skip to content

style: legend text and icon alignment #1340

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 1 commit into from
Jul 8, 2024
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
2 changes: 1 addition & 1 deletion src/components/settings/AppearanceSettings.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { mockAuth, mockSettings } from '../../__mocks__/state-mocks';
import { AppContext } from '../../context/App';
import { AppearanceSettings } from './AppearanceSettings';

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

afterEach(() => {
Expand Down
6 changes: 2 additions & 4 deletions src/components/settings/AppearanceSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { Size, Theme } from '../../types';
import { setTheme } from '../../utils/theme';
import { Checkbox } from '../fields/Checkbox';
import { RadioGroup } from '../fields/RadioGroup';
import { Legend } from './Legend';

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

return (
<fieldset>
<legend id="appearance" className="mb-1 mt-2 font-semibold">
<PaintbrushIcon className="mr-2" />
Appearance
</legend>
<Legend icon={PaintbrushIcon}>Appearance</Legend>
<RadioGroup
name="theme"
label="Theme:"
Expand Down
11 changes: 11 additions & 0 deletions src/components/settings/Legend.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { PersonFillIcon } from '@primer/octicons-react';
import { render } from '@testing-library/react';
import { Legend } from './Legend';

describe('routes/components/settings/Legend.tsx', () => {
it('should render the legend', async () => {
const { container } = render(<Legend icon={PersonFillIcon}>Legend</Legend>);

expect(container).toMatchSnapshot();
});
});
19 changes: 19 additions & 0 deletions src/components/settings/Legend.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import type { Icon } from '@primer/octicons-react';
import type { FC } from 'react';

interface ILegend {
icon: Icon;
children: string;
}

export const Legend: FC<ILegend> = (props) => {
return (
<legend
id={props.children.toLowerCase().replace(' ', '-')}
className="mb-1 mt-2 font-semibold flex items-center"
>
<props.icon className="mr-2" />
{props.children}
</legend>
);
};
2 changes: 1 addition & 1 deletion src/components/settings/NotificationSettings.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { AppContext } from '../../context/App';
import * as comms from '../../utils/comms';
import { NotificationSettings } from './NotificationSettings';

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

afterEach(() => {
Expand Down
6 changes: 2 additions & 4 deletions src/components/settings/NotificationSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,14 @@ import { GroupBy } from '../../types';
import { openGitHubParticipatingDocs } from '../../utils/links';
import { Checkbox } from '../fields/Checkbox';
import { RadioGroup } from '../fields/RadioGroup';
import { Legend } from './Legend';

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

return (
<fieldset>
<legend id="notifications" className="mb-1 mt-2 font-semibold">
<BellIcon className="mr-2" />
Notifications
</legend>
<Legend icon={BellIcon}>Notifications</Legend>
<RadioGroup
name="groupBy"
label="Group by:"
Expand Down
2 changes: 1 addition & 1 deletion src/components/settings/SettingsFooter.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jest.mock('react-router-dom', () => ({
useNavigate: () => mockNavigate,
}));

describe('routes/components/SettingsFooter.tsx', () => {
describe('routes/components/settings/SettingsFooter.tsx', () => {
afterEach(() => {
jest.clearAllMocks();
process.env = originalEnv;
Expand Down
2 changes: 1 addition & 1 deletion src/components/settings/SystemSettings.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { mockAuth, mockSettings } from '../../__mocks__/state-mocks';
import { AppContext } from '../../context/App';
import { SystemSettings } from './SystemSettings';

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

afterEach(() => {
Expand Down
6 changes: 2 additions & 4 deletions src/components/settings/SystemSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,14 @@ import { AppContext } from '../../context/App';
import Constants from '../../utils/constants';
import { isLinux, isMacOS } from '../../utils/platform';
import { Checkbox } from '../fields/Checkbox';
import { Legend } from './Legend';

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

return (
<fieldset>
<legend id="system" className="mb-1 mt-2 font-semibold">
<DeviceDesktopIcon className="mr-2" />
System
</legend>
<Legend icon={DeviceDesktopIcon}>System</Legend>
<Checkbox
name="kbdShortcutEnabled"
label="Enable keyboard shortcut"
Expand Down
26 changes: 26 additions & 0 deletions src/components/settings/__snapshots__/Legend.test.tsx.snap

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

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

6 changes: 3 additions & 3 deletions src/routes/__snapshots__/Settings.test.tsx.snap

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