Skip to content

Commit 85e3abe

Browse files
committed
Start using Phosphor icons, initially for sidebar & View empty state
1 parent d5cf301 commit 85e3abe

File tree

8 files changed

+82
-27
lines changed

8 files changed

+82
-27
lines changed

package-lock.json

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

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
"@httptoolkit/accounts": "^2.1.1",
4646
"@httptoolkit/httpsnippet": "^2.1.7",
4747
"@open-rpc/meta-schema": "^1.14.2",
48+
"@phosphor-icons/react": "^2.1.5",
4849
"@reach/router": "^1.2.1",
4950
"@sentry/browser": "^7.112.2",
5051
"@sentry/webpack-plugin": "^2.16.1",

src/components/app.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import { PlanPicker } from './account/plan-picker';
3434
import { ModalOverlay } from './account/modal-overlay';
3535
import { CheckoutSpinner } from './account/checkout-spinner';
3636
import { HtmlContextMenu } from './html-context-menu';
37+
import { Icons } from '../icons';
3738

3839
const AppContainer = styled.div<{ inert?: boolean }>`
3940
display: flex;
@@ -109,15 +110,15 @@ class App extends React.Component<{
109110
{
110111
name: 'Intercept',
111112
title: `Connect clients to HTTP Toolkit (${Ctrl}+1)`,
112-
icon: ['fas', 'plug'],
113+
icon: Icons.Plugs,
113114
position: 'top',
114115
type: 'router',
115116
url: '/intercept'
116117
},
117118
{
118119
name: 'View',
119120
title: `View intercepted HTTP traffic (${Ctrl}+2)`,
120-
icon: ['fas', 'search'],
121+
icon: Icons.MagnifyingGlass,
121122
position: 'top',
122123
type: 'router',
123124
url: '/view'
@@ -133,7 +134,7 @@ class App extends React.Component<{
133134
? [{
134135
name: 'Mock',
135136
title: `Add rules to mock & rewrite HTTP traffic (${Ctrl}+3)`,
136-
icon: ['fas', 'theater-masks'],
137+
icon: Icons.Pencil,
137138
position: 'top',
138139
type: 'router',
139140
url: '/mock'
@@ -145,7 +146,7 @@ class App extends React.Component<{
145146
? [{
146147
name: 'Send',
147148
title: `Send HTTP requests directly (${Ctrl}+4)`,
148-
icon: ['far', 'paper-plane'],
149+
icon: Icons.PaperPlaneTilt,
149150
position: 'top',
150151
type: 'router',
151152
url: '/send'
@@ -157,15 +158,15 @@ class App extends React.Component<{
157158
? {
158159
name: 'Settings',
159160
title: `Reconfigure HTTP Toolkit and manage your account (${Ctrl}+9)`,
160-
icon: ['fas', 'cog'],
161+
icon: Icons.GearSix,
161162
position: 'bottom',
162163
type: 'router',
163164
url: '/settings'
164165
}
165166
: {
166167
name: 'Get Pro',
167168
title: "Sign up for HTTP Toolkit Pro",
168-
icon: ['far', 'star'],
169+
icon: Icons.Star,
169170
position: 'bottom',
170171
type: 'callback',
171172
onClick: () => this.props.accountStore.getPro('sidebar')
@@ -175,7 +176,7 @@ class App extends React.Component<{
175176
{
176177
name: 'Give feedback',
177178
title: "Suggest features or report issues",
178-
icon: ['far', 'comment'],
179+
icon: Icons.ChatText,
179180
position: 'bottom',
180181
highlight: true,
181182
type: 'web',

src/components/common/empty-state.tsx

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,15 @@ import * as React from 'react';
22
import * as _ from 'lodash';
33

44
import { styled } from '../../styles'
5-
import { Icon, IconProp } from '../../icons';
5+
import { PhosphorIcon } from '../../icons';
66

77
export const EmptyState = styled((props: React.HTMLAttributes<HTMLDivElement> & {
88
className?: string,
9-
icon: IconProp,
10-
spin?: true | 'slow',
9+
icon: PhosphorIcon,
1110
children?: React.ReactNode
1211
}) => (
13-
<div {..._.omit(props, ['message', 'icon', 'spin'])}>
14-
<Icon
15-
icon={props.icon}
16-
spin={props.spin === true}
17-
className={props.spin === 'slow' ? 'slow-spin' : undefined}
18-
/>
12+
<div className={props.className}>
13+
<props.icon />
1914
{ props.children && <>
2015
<br/>
2116
{ props.children }

src/components/sidebar.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ import { Link, Match } from '@reach/router';
55
import * as dedent from 'dedent';
66

77
import { styled, css, Theme } from '../styles';
8-
import { Icon, IconProp } from '../icons';
8+
import { PhosphorIcon } from '../icons';
99
import { UI_VERSION, desktopVersion, serverVersion } from '../services/service-versions';
1010

1111
import { UnstyledButton } from './common/inputs';
1212
import logo from '../images/logo-icon.svg';
1313

1414
export interface SidebarItem {
1515
name: string;
16-
icon: IconProp;
16+
icon: PhosphorIcon;
1717
position: 'top' | 'bottom';
1818
highlight?: true;
1919

@@ -49,8 +49,8 @@ const SidebarNav = styled.nav`
4949
`
5050

5151
const sidebarItemStyles = css`
52-
width: 70px;
53-
height: 70px;
52+
width: 72px;
53+
height: 72px;
5454
margin: 0 auto;
5555
5656
display: flex;
@@ -151,8 +151,8 @@ const SidebarButton = styled(
151151
export const Sidebar = observer((props: SidebarProps) => {
152152
const items = props.items.map((item, i) => {
153153
const itemContent = <>
154-
<Icon size='2x' icon={item.icon} />
155-
{item.name}
154+
<item.icon size={34} />
155+
{ item.name }
156156
</>;
157157

158158
if (item.type === 'web') {

src/components/view/view-event-list.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import AutoSizer from 'react-virtualized-auto-sizer';
77
import { FixedSizeList as List, ListChildComponentProps } from 'react-window';
88

99
import { css, highContrastTheme, styled } from '../../styles'
10-
import { ArrowIcon, Icon, WarningIcon } from '../../icons';
10+
import { ArrowIcon, Icon, WarningIcon, Icons } from '../../icons';
1111

1212
import {
1313
CollectedEvent,
@@ -792,16 +792,16 @@ export class ViewEventList extends React.Component<ViewEventListProps> {
792792
{
793793
events.length === 0
794794
? (isPaused
795-
? <EmptyStateOverlay icon={['fas', 'pause']}>
795+
? <EmptyStateOverlay icon={Icons.Pause}>
796796
Interception is paused, resume it to collect intercepted requests
797797
</EmptyStateOverlay>
798-
: <EmptyStateOverlay icon={['fas', 'plug']}>
798+
: <EmptyStateOverlay icon={Icons.Plug}>
799799
Connect a client and intercept some requests, and they'll appear here
800800
</EmptyStateOverlay>
801801
)
802802

803803
: filteredEvents.length === 0
804-
? <EmptyStateOverlay icon={['fas', 'question']}>
804+
? <EmptyStateOverlay icon={Icons.QuestionMark}>
805805
No requests match this search filter{
806806
isPaused ? ' and interception is paused' : ''
807807
}

src/components/view/view-page.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import * as portals from 'react-reverse-portal';
1515

1616
import { WithInjected, CollectedEvent } from '../../types';
1717
import { NARROW_LAYOUT_BREAKPOINT, styled } from '../../styles';
18+
import { Icons } from '../../icons';
1819
import { useHotkeys, isEditable, windowSize } from '../../util/ui';
1920
import { debounceComputed } from '../../util/observable';
2021
import { UnreachableCheck } from '../../util/error';
@@ -306,7 +307,7 @@ class ViewPage extends React.Component<ViewPageProps> {
306307
let rightPane: JSX.Element | null;
307308
if (!this.selectedEvent) {
308309
if (this.splitDirection === 'vertical') {
309-
rightPane = <EmptyState key='details' icon={['fas', 'arrow-left']}>
310+
rightPane = <EmptyState key='details' icon={Icons.ArrowLeft}>
310311
Select an exchange to see the full details.
311312
</EmptyState>;
312313
} else {

src/icons.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,45 @@
11
import * as React from 'react';
22
import { styled, warningColor } from './styles';
33

4+
// Import required Phosphor icons:
5+
import {
6+
type Icon as PhosphorIcon,
7+
type IconProps as PhosphorIconProps,
8+
9+
// Sidebar icons
10+
Plugs,
11+
MagnifyingGlass,
12+
Pencil,
13+
PaperPlaneTilt,
14+
GearSix,
15+
Star,
16+
ChatText,
17+
18+
// Functional icons
19+
Pause,
20+
Plug,
21+
QuestionMark,
22+
ArrowLeft,
23+
} from '@phosphor-icons/react';
24+
25+
export type { PhosphorIcon, PhosphorIconProps };
26+
export type PhosphorIconKey = keyof typeof Icons;
27+
28+
export const Icons = {
29+
Plugs,
30+
MagnifyingGlass,
31+
Pencil,
32+
PaperPlaneTilt,
33+
GearSix,
34+
Star,
35+
ChatText,
36+
37+
Pause,
38+
Plug,
39+
QuestionMark,
40+
ArrowLeft,
41+
} as const;
42+
443
// Import required FA icons:
544
import {
645
library,

0 commit comments

Comments
 (0)