Skip to content

Commit

Permalink
Merge pull request #412 from kipr/use-fa-package
Browse files Browse the repository at this point in the history
Switch to Font Awesome npm packages
  • Loading branch information
tcorbly authored Sep 20, 2022
2 parents 349e8dc + b0818d0 commit ba7ee33
Show file tree
Hide file tree
Showing 1,735 changed files with 156 additions and 134,896 deletions.
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@
"webpack-merge": "^5.7.3"
},
"dependencies": {
"@fortawesome/fontawesome-svg-core": "^6.2.0",
"@fortawesome/free-brands-svg-icons": "^6.2.0",
"@fortawesome/free-solid-svg-icons": "^6.2.0",
"@fortawesome/react-fontawesome": "^0.2.0",
"@types/react": "^16.9.25",
"babylonjs": "^4.2.0",
"babylonjs-loaders": "^4.2.0",
Expand Down
4 changes: 3 additions & 1 deletion src/components/AboutDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { Dialog } from './Dialog';
import { ThemeProps } from './theme';
import { Fa } from './Fa';

import { faCopyright } from '@fortawesome/free-solid-svg-icons';

import KIPR_LOGO_BLACK from '../assets/KIPR-Logo-Black-Text-Clear-Large.png';
import KIPR_LOGO_WHITE from '../assets/KIPR-Logo-White-Text-Clear-Large.png';

Expand Down Expand Up @@ -73,7 +75,7 @@ export class AboutDialog extends React.PureComponent<Props> {
</LogoRow>
Version {SIMULATOR_VERSION} ({SIMULATOR_GIT_HASH})
<br /> <br />
<Bold>Copyright <Fa icon='copyright' /> 2022 <Link theme={theme} href="https://kipr.org/" target="_blank">KISS Institute for Practical Robotics</Link> and External Contributors</Bold>
<Bold>Copyright <Fa icon={faCopyright} /> 2022 <Link theme={theme} href="https://kipr.org/" target="_blank">KISS Institute for Practical Robotics</Link> and External Contributors</Bold>
<br /> <br />
This software is licensed under the terms of the <Link theme={theme} href="https://www.gnu.org/licenses/gpl-3.0.en.html" target="_blank">GNU General Public License v3</Link>.
<br /> <br />
Expand Down
3 changes: 2 additions & 1 deletion src/components/ComboBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { Color } from "../state/State/Scene/Color";
import { Fa } from "./Fa";
import { Text } from "./Text";
import { ThemeProps } from "./theme";
import { faCaretDown, faCaretUp } from "@fortawesome/free-solid-svg-icons";

const Container = styled('div', (props: ThemeProps & { $focus?: boolean; $minimal?: boolean; }) => ({
width: !props.$minimal ? '100%' : undefined,
Expand Down Expand Up @@ -163,7 +164,7 @@ class ComboBox extends React.PureComponent<ComboBox.Props, ComboBox.State> {
return (
<Container ref={this.bindRef_} style={style} className={className} theme={theme} onClick={this.onClick_} $focus={focus} $minimal={minimal}>
<CurrentOptionContainer theme={theme}><Text text={options[index].text} /></CurrentOptionContainer>
<DropIcon icon={focus ? 'caret-up' : 'caret-down'} />
<DropIcon icon={focus ? faCaretUp : faCaretDown} />
{ReactDom.createPortal((focus && this.ref_)
? <DropDown theme={theme} style={dropDownStyle}>
{options.map((option, i) => (
Expand Down
4 changes: 3 additions & 1 deletion src/components/Console/ClearCharm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { Fa } from '../Fa';
import { ThemeProps } from '../theme';
import { charmColor } from '../charm-util';

import { faTimes } from '@fortawesome/free-solid-svg-icons';

export interface ClearCharmProps extends StyleProps, ThemeProps {
onClick: (event: React.MouseEvent<HTMLDivElement>) => void;
}
Expand All @@ -30,7 +32,7 @@ class ClearCharm extends React.PureComponent<Props> {

return (
<Container theme={theme} onClick={onClick}>
<Fa icon='times' /> Clear
<Fa icon={faTimes} /> Clear
</Container>
);
}
Expand Down
4 changes: 3 additions & 1 deletion src/components/Console/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import { Fa } from '../Fa';
import { Button } from '../Button';
import { BarComponent } from '../Widget';

import { faFile } from '@fortawesome/free-solid-svg-icons';

export const createConsoleBarComponents = (
theme: Theme,
onClearConsole: () => void,
Expand All @@ -22,7 +24,7 @@ export const createConsoleBarComponents = (
onClick: onClearConsole,
children:
<>
<Fa icon='file' />
<Fa icon={faFile} />
{' Clear'}
</>,
}));
Expand Down
9 changes: 5 additions & 4 deletions src/components/EditableList.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { faCog, faEye, faEyeSlash, faSync, faTimes } from "@fortawesome/free-solid-svg-icons";
import * as React from "react";
import { styled, withStyleDeep } from "styletron-react";
import { StyleProps } from "../style";
Expand Down Expand Up @@ -145,22 +146,22 @@ namespace EditableList {
<StandardItem.OptionsContainer>
{onVisibilityChange && (
<StandardItem.VisibilityIconContainer onClick={this.onVisibilityChange_}>
<StandardItem.OptionIcon icon={visible ? 'eye' : 'eye-slash'} />
<StandardItem.OptionIcon icon={visible ? faEye : faEyeSlash} />
</StandardItem.VisibilityIconContainer>
)}
{onReset && (
<StandardItem.ResetIconContainer onClick={visible ? onReset : undefined} $disabled={!visible}>
<StandardItem.OptionIcon icon='sync' />
<StandardItem.OptionIcon icon={faSync} />
</StandardItem.ResetIconContainer>
)}
{onSettings && (
<StandardItem.SettingsIconContainer onClick={onSettings}>
<StandardItem.OptionIcon icon='cog' />
<StandardItem.OptionIcon icon={faCog} />
</StandardItem.SettingsIconContainer>
)}
{onRemove && (
<StandardItem.RemoveIconContainer onClick={onRemove}>
<StandardItem.OptionIcon icon='times' />
<StandardItem.OptionIcon icon={faTimes} />
</StandardItem.RemoveIconContainer>
)}

Expand Down
6 changes: 4 additions & 2 deletions src/components/Editor/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import { Ivygate, Message } from 'ivygate';
import LanguageSelectCharm from './LanguageSelectCharm';
import ProgrammingLanguage from '../../ProgrammingLanguage';

import { faFileDownload, faIndent } from '@fortawesome/free-solid-svg-icons';

export enum EditorActionState {
None,
Compiling,
Expand Down Expand Up @@ -80,7 +82,7 @@ export const createEditorBarComponents = ({
onClick: onIndentCode,
children:
<>
<Fa icon='indent'/>
<Fa icon={faIndent} />
{' Indent'}
</>
}));
Expand All @@ -90,7 +92,7 @@ export const createEditorBarComponents = ({
onClick: onDownloadCode,
children:
<>
<Fa icon='file-download'/>
<Fa icon={faFileDownload} />
{' Download'}
</>
}));
Expand Down
4 changes: 3 additions & 1 deletion src/components/Editor/ErrorCharm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { Fa } from '../Fa';
import { ThemeProps } from '../theme';
import { charmColor } from '../charm-util';

import { faTimesCircle } from '@fortawesome/free-solid-svg-icons';

export interface ErrorCharmProps extends StyleProps, ThemeProps {
count: number;

Expand Down Expand Up @@ -33,7 +35,7 @@ class ErrorCharm extends React.PureComponent<Props> {

return (
<Container theme={theme} onClick={onClick}>
<Fa icon='times-circle' /> {count} Error{count === 1 ? '' : 's'}
<Fa icon={faTimesCircle} /> {count} Error{count === 1 ? '' : 's'}
</Container>
);
}
Expand Down
1 change: 0 additions & 1 deletion src/components/Editor/LanguageSelectCharm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import * as React from 'react';
import { styled, withStyleDeep } from 'styletron-react';
import { StyleProps } from '../../style';
import Charm from '../Charm';
import { Fa } from '../Fa';
import { ThemeProps } from '../theme';
import { charmColor } from '../charm-util';
import ComboBox from '../ComboBox';
Expand Down
4 changes: 3 additions & 1 deletion src/components/Editor/PerfectCharm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { Fa } from '../Fa';
import { ThemeProps } from '../theme';
import { charmColor } from '../charm-util';

import { faCheck } from '@fortawesome/free-solid-svg-icons';

export interface PerfectCharmProps extends StyleProps, ThemeProps {
}

Expand All @@ -28,7 +30,7 @@ class PerfectCharm extends React.PureComponent<Props> {

return (
<Container theme={theme}>
<Fa icon='check' /> Perfect!
<Fa icon={faCheck} /> Perfect!
</Container>
);
}
Expand Down
4 changes: 3 additions & 1 deletion src/components/Editor/WarningCharm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { Fa } from '../Fa';
import { ThemeProps } from '../theme';
import { charmColor } from '../charm-util';

import { faExclamationTriangle } from '@fortawesome/free-solid-svg-icons';

export interface WarningCharmProps extends StyleProps, ThemeProps {
count: number;

Expand Down Expand Up @@ -33,7 +35,7 @@ class WarningCharm extends React.PureComponent<Props> {

return (
<Container theme={theme} onClick={onClick}>
<Fa icon='exclamation-triangle' /> {count} Warning{count === 1 ? '' : 's'}
<Fa icon={faExclamationTriangle} /> {count} Warning{count === 1 ? '' : 's'}
</Container>
);
}
Expand Down
18 changes: 10 additions & 8 deletions src/components/Fa.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { IconProp } from '@fortawesome/fontawesome-svg-core';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import * as React from 'react';

import { StyleProps } from '../style';

export interface FaProps extends StyleProps {
icon: string;
brand?: boolean;
onClick?: (event: React.MouseEvent<HTMLSpanElement>) => void;
onMouseEnter?: (event: React.MouseEvent<HTMLSpanElement>) => void;
onMouseLeave?: (event: React.MouseEvent<HTMLSpanElement>) => void;
icon: IconProp;
onClick?: (event: React.MouseEvent<SVGSVGElement>) => void;
onMouseEnter?: (event: React.MouseEvent<SVGSVGElement>) => void;
onMouseLeave?: (event: React.MouseEvent<SVGSVGElement>) => void;
disabled?: boolean;
}

Expand All @@ -16,19 +17,20 @@ type Props = FaProps;
export class Fa extends React.PureComponent<Props> {
render() {
const { props } = this;
const { className, icon, onClick, onMouseEnter, onMouseLeave, disabled, brand } = props;
const { className, icon, onClick, onMouseEnter, onMouseLeave, disabled } = props;
const style: React.CSSProperties = {
...props.style,
cursor: onClick && !disabled ? 'pointer' : undefined,
opacity: disabled ? 0.5 : undefined
};
return (
<span
<FontAwesomeIcon
icon={icon}
style={style}
onClick={!disabled ? onClick : undefined}
onMouseEnter={onMouseEnter}
onMouseLeave={onMouseLeave}
className={`${className} ${brand ? `fab` : `fas`} fa-${icon}`}
className={className}
/>
);
}
Expand Down
4 changes: 3 additions & 1 deletion src/components/Feedback/SentimentCharm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ import { Fa } from '../Fa';
import { ThemeProps } from '../theme';
import { charmColor } from '../charm-util';

import { IconProp } from '@fortawesome/fontawesome-svg-core';

export interface SentimentCharmProps extends StyleProps, ThemeProps {
icon: string;
icon: IconProp;
selected: boolean;
onClick: (event: React.MouseEvent<HTMLDivElement>) => void;
}
Expand Down
10 changes: 6 additions & 4 deletions src/components/Feedback/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import DialogBar from "../DialogBar";
import { ThemeProps } from '../theme';
import { Fa } from '../Fa';

import { faFrown, faMeh, faPaperPlane, faSmileBeam } from '@fortawesome/free-solid-svg-icons';

export interface FeedbackDialogProp extends ThemeProps, StyleProps {
onClose: () => void;
onSubmit: () => void;
Expand Down Expand Up @@ -57,13 +59,13 @@ export class FeedbackDialog extends React.PureComponent<Props, State> {

return (
<FeedbackRowContainer theme={theme}>
<SentimentCharm theme={theme} icon='frown' selected={getValue(currentFeedback) === Sentiment.Sad} onClick={
<SentimentCharm theme={theme} icon={faFrown} selected={getValue(currentFeedback) === Sentiment.Sad} onClick={
() => onFeedbackChange(getUpdatedFeedback(Sentiment.Sad))
}/>
<SentimentCharm theme={theme} icon='meh' selected={getValue(currentFeedback) === Sentiment.Okay} onClick={
<SentimentCharm theme={theme} icon={faMeh} selected={getValue(currentFeedback) === Sentiment.Okay} onClick={
() => onFeedbackChange(getUpdatedFeedback(Sentiment.Okay))
}/>
<SentimentCharm theme={theme} icon='smile-beam' selected={getValue(currentFeedback) === Sentiment.Happy} onClick={
<SentimentCharm theme={theme} icon={faSmileBeam} selected={getValue(currentFeedback) === Sentiment.Happy} onClick={
() => onFeedbackChange(getUpdatedFeedback(Sentiment.Happy))
}/>
</FeedbackRowContainer>
Expand Down Expand Up @@ -176,7 +178,7 @@ export class FeedbackDialog extends React.PureComponent<Props, State> {
}
</FeedbackContainer>
<DialogBar theme={theme} onAccept={onSubmit}>
<Fa icon='paper-plane'/> Submit
<Fa icon={faPaperPlane}/> Submit
</DialogBar>
</Dialog>
);
Expand Down
6 changes: 4 additions & 2 deletions src/components/Form.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
import { IconProp } from '@fortawesome/fontawesome-svg-core';
import { faCheck, faTimes } from '@fortawesome/free-solid-svg-icons';
import * as React from 'react';
import { styled } from 'styletron-react';
import Dict from '../Dict';
Expand Down Expand Up @@ -137,7 +139,7 @@ class Form extends React.PureComponent<Form.Props, Form.State> {
StyledText.component ({
component: Fa,
props: {
icon: valid ? 'check' : 'times',
icon: valid ? faCheck : faTimes,
style: {
color: valid ? GREEN.standard : RED.standard,
},
Expand Down Expand Up @@ -187,7 +189,7 @@ namespace Form {
onFinalize: (values: { [id: string]: any }) => void;

finalizeText?: string;
finalizeIcon?: string;
finalizeIcon?: IconProp;

finalizeDisabled?: boolean;

Expand Down
3 changes: 2 additions & 1 deletion src/components/Info/Info.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { ReferenceFrame } from '../../unit-math';
import { connect } from 'react-redux';
import { State as ReduxState } from '../../state';
import { SceneAction } from '../../state/reducer';
import { faSync } from '@fortawesome/free-solid-svg-icons';


export interface InfoProps extends StyleProps, ThemeProps {
Expand Down Expand Up @@ -150,7 +151,7 @@ class Info extends React.PureComponent<Props & ReduxInfoProps, State> {
StyledText.component({
component: ResetIcon,
props: {
icon: 'sync',
icon: faSync,
onClick: this.onResetLocationClick_,
theme
}
Expand Down
5 changes: 3 additions & 2 deletions src/components/Info/SensorWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { Fa } from '../Fa';
import { connect } from 'react-redux';
import { State as ReduxState } from '../../state';
import { RobotState } from '../../RobotState';
import { faEye, faEyeSlash } from '@fortawesome/free-solid-svg-icons';

export interface SensorWidgetProps extends ThemeProps, StyleProps {
name: string;
Expand Down Expand Up @@ -147,7 +148,7 @@ class SensorWidget extends React.PureComponent<Props & ReduxSensorWidgetProps, S
StyledText.component({
component: StyledToolIcon,
props: {
icon: 'eye',
icon: faEye,
theme,
onClick: this.onShowPlotClick_,
disabled: showPlot,
Expand All @@ -158,7 +159,7 @@ class SensorWidget extends React.PureComponent<Props & ReduxSensorWidgetProps, S
StyledText.component({
component: StyledToolIcon,
props: {
icon: 'eye-slash',
icon: faEyeSlash,
theme,
onClick: this.onHidePlotClick_,
disabled: !showPlot
Expand Down
11 changes: 6 additions & 5 deletions src/components/Layout/LayoutPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { StyleProps } from '../../style';
import { Fa } from '../Fa';
import { Layout } from './Layout';
import { ThemeProps } from '../theme';
import { faCaretSquareLeft, faClone, faEye, faEyeSlash } from '@fortawesome/free-solid-svg-icons';

export interface LayoutPickerProps extends StyleProps, ThemeProps {
layout: Layout,
Expand Down Expand Up @@ -107,15 +108,15 @@ class LayoutPicker extends React.PureComponent<Props, State> {
return (
<Container theme={theme}>
<Item theme={theme} style={{ fontWeight: 500, backgroundColor: theme.borderColor }}>Layouts</Item>
<Item theme={theme} disabled={layout === Layout.Overlay} onClick={layout !== Layout.Overlay ? this.onOverlayClick_ : undefined}><ItemIcon icon='clone' /> Overlay</Item>
<Item theme={theme} disabled={layout === Layout.Side} onClick={layout !== Layout.Side ? this.onSideClick_ : undefined}><ItemIcon icon='caret-square-left' /> Side</Item>
{/* <Item theme={theme} disabled={layout === Layout.Bottom} onClick={layout !== Layout.Bottom ? this.onBottomClick_ : undefined}><ItemIcon icon='caret-square-down' /> Bottom</Item> */}
<Item theme={theme} disabled={layout === Layout.Overlay} onClick={layout !== Layout.Overlay ? this.onOverlayClick_ : undefined}><ItemIcon icon={faClone} /> Overlay</Item>
<Item theme={theme} disabled={layout === Layout.Side} onClick={layout !== Layout.Side ? this.onSideClick_ : undefined}><ItemIcon icon={faCaretSquareLeft} /> Side</Item>
{/* <Item theme={theme} disabled={layout === Layout.Bottom} onClick={layout !== Layout.Bottom ? this.onBottomClick_ : undefined}><ItemIcon icon={faCaretSquareDown} /> Bottom</Item> */}

{layout === Layout.Overlay ? (
<>
<Item theme={theme} style={{ fontWeight: 500, backgroundColor: theme.borderColor }}>Layout Options</Item>
<Item theme={theme} onClick={onShowAll}><ItemIcon icon='eye' /> Show All</Item>
<Item theme={theme} onClick={onHideAll}><ItemIcon icon='eye-slash' /> Hide All</Item>
<Item theme={theme} onClick={onShowAll}><ItemIcon icon={faEye} /> Show All</Item>
<Item theme={theme} onClick={onHideAll}><ItemIcon icon={faEyeSlash} /> Hide All</Item>
</>
) : undefined}
</Container>
Expand Down
1 change: 0 additions & 1 deletion src/components/Layout/OverlayLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { Console, createConsoleBarComponents } from '../Console';
import { Editor, createEditorBarComponents } from '../Editor';
import World, { createWorldBarComponents } from '../World';

import { Fa } from '../Fa';
import { Info } from '../Info';
import { LayoutProps } from './Layout';
import { SimulatorArea } from '../SimulatorArea';
Expand Down
Loading

0 comments on commit ba7ee33

Please sign in to comment.