Skip to content

Commit

Permalink
replace fontawesome with react icons
Browse files Browse the repository at this point in the history
  • Loading branch information
sophiabeluli committed Sep 4, 2024
1 parent f3b10e2 commit 094dfd5
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 26 deletions.
1 change: 0 additions & 1 deletion src/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>gSender</title>
<link rel="stylesheet" crossorigin href="./src/index.css" type="text/css"/>
<link href="https://use.fontawesome.com/releases/v5.15.4/css/all.css" rel="stylesheet" />
<script src="https://cdn.tailwindcss.com"></script>
<!--app-head-->
</head>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import React, { useState, useEffect } from 'react';
import pubsub from 'pubsub-js';
import cx from 'classnames';
import { FaExclamationTriangle } from "react-icons/fa";
import styles from './index.styl';
import ConfirmationDialogButton from './ConfirmationDialogButton';
import { DIALOG_CONFIRM, DIALOG_CANCEL } from './ConfirmationDialogLib';
Expand Down Expand Up @@ -61,7 +62,7 @@ const ConfirmationDialog = () => {
<div className={styles.confirmationDialog}>
<div className={styles.confirmationBar} />
<div className={styles.confirmationDialogTitle}>
<i className="fas fa-exclamation-triangle" />
<FaExclamationTriangle />
<span>{ title }</span>
</div>
<div className={styles.confirmationDialogContent}>
Expand Down
8 changes: 5 additions & 3 deletions src/app/src/components/RangeSlider/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

import React, { PointerEventHandler } from 'react';
import * as Slider from '@radix-ui/react-slider';
import { CiRedo } from "react-icons/ci";
import { FaMinus, FaPlus } from "react-icons/fa";

export interface RangeSliderProps {
[key: string]: any,
Expand Down Expand Up @@ -68,7 +70,7 @@ const RangeSlider = ({
className="flex w-10 h-7 items-center justify-center rounded-s-3xl rounded-e-none text-center p-1 m-0 font-bold border-solid border-[1px] border-blue-400 bg-white bg-opacity-60 text-black"
onClick={() => onChange(defaultValue)}
>
<i className="fas fa-redo"></i>
<CiRedo />
</button>
<Slider.Root
className="flex relative items-center w-full h-6"
Expand Down Expand Up @@ -101,7 +103,7 @@ const RangeSlider = ({
onChange([newValue]);
}}
>
<i className="fas fa-minus"></i>
<FaMinus />
</button>
<button
type="button"
Expand All @@ -114,7 +116,7 @@ const RangeSlider = ({
onChange([newValue]);
}}
>
<i className="fas fa-plus"></i>
<FaPlus />
</button>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/app/src/features/MachineStatus/AlarmDescriptionIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*/

import get from 'lodash/get';
import cx from 'classnames';
import { FaQuestion } from "react-icons/fa6";
import { store as reduxStore } from '../../store/redux';
import { GRBLHAL } from '../../constants';
import { GRBL_HAL_ALARMS } from '../../../../server/controllers/Grblhal/constants';
Expand All @@ -47,7 +47,7 @@ const AlarmDescriptionIcon = ({ code = 1 }: { code: ALARM_CODE }) => {
<Tooltip>
<TooltipTrigger asChild>
<div className="bg-white opacity-90 rounded-full w-8 h-8 my-0 mx-4 flex items-center justify-center shadow-[rgba(0,0,0,0.35)_0px_5px_15px] [pointer-events:_all]">
<i className={cx("fas fa-question", "text-xl text-gray-600")} />
<FaQuestion className="text-xl text-gray-600" />
</div>
</TooltipTrigger>
<TooltipContent className="max-w-64">
Expand Down
18 changes: 9 additions & 9 deletions src/app/src/features/MachineStatus/MachineStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,21 +97,21 @@ const MachineStatus: React.FC<MachineStatusProps> = ({ activeState, alarmCode, i
isConnected && activeState ? (
<>
{
activeState === GRBL_ACTIVE_STATE_ALARM ? (
<div className="flex w-full flex-row justify-center align-middle items-center font-light text-3xl mb-1">
<div className="flex justify-center">{activeState}</div>
<div className="absolute right-3 flex float-right"><AlarmDescriptionIcon code={alarmCode} /></div>
</div>
) : (
<span className="flex w-full font-light text-3xl mb-1 justify-center">{message[activeState]}</span>
)
// activeState === GRBL_ACTIVE_STATE_ALARM ? (
<div className="flex w-full flex-row justify-center align-middle items-center font-light text-3xl mb-1">
<div className="flex justify-center">{activeState}</div>
<div className="absolute right-3 flex float-right"><AlarmDescriptionIcon code={alarmCode} /></div>
</div>
// ) : (
// <span className="flex w-full font-light text-3xl mb-1 justify-center">{message[activeState]}</span>
// )
}
</>
) : <h1 className="flex w-full font-light text-3xl mb-1 justify-center">Disconnected</h1>
}
</div>
<div className="mt-4">
{ (activeState === GRBL_ACTIVE_STATE_ALARM || activeState === GRBL_ACTIVE_STATE_HOLD) && <UnlockButton onClick={unlock} alarmCode={alarmCode} activeState={activeState} /> }
<UnlockButton onClick={unlock} alarmCode={alarmCode} activeState={activeState} />
</div>
</div>
)
Expand Down
19 changes: 9 additions & 10 deletions src/app/src/features/MachineStatus/UnlockButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import React, { MouseEventHandler } from 'react';
import cx from 'classnames';
import { FaHome, FaUnlock } from "react-icons/fa";

import { GRBL_ACTIVE_STATE_ALARM } from '../../constants';
import { GRBL_ACTIVE_STATES_T } from 'definitions/general';
Expand All @@ -41,6 +42,12 @@ const UnlockButton: React.FC<UnlockProps> = ({ activeState, alarmCode, onClick }
}
return 'Click to Unlock Machine';
};

const SymbolComponent = activeState === GRBL_ACTIVE_STATE_ALARM && (alarmCode === 'Homing' || alarmCode === 11) ? (
<FaHome className="text-9xl h-16 mr-1" role="button" tabIndex={-1} />
) : (
<FaUnlock className="text-9xl h-16 mr-1" role="button" tabIndex={-1} />
);

return (
<div className="flex items-center justify-center pointer-events-auto">
Expand All @@ -51,20 +58,12 @@ const UnlockButton: React.FC<UnlockProps> = ({ activeState, alarmCode, onClick }
{
"border-red-800 bg-red-600 grow [animation:grow_2s_infinite]": activeState === GRBL_ACTIVE_STATE_ALARM,
"border-yellow-800 bg-yellow-600": activeState !== GRBL_ACTIVE_STATE_ALARM,
"pr-1": alarmCode !== 'Homing' && alarmCode !== 11 // this is for adjusting the position of the text
// "pr-1": alarmCode !== 'Homing' && alarmCode !== 11 // this is for adjusting the position of the text
}
)}
onClick={onClick}
>
<i
className={cx(
"text-5xl",
"fas",
activeState === GRBL_ACTIVE_STATE_ALARM && (alarmCode === 'Homing' || alarmCode === 11) ? 'fa-home' : 'fa-unlock'
)}
role="button"
tabIndex={-1}
/>
{SymbolComponent}
{getButtonText()}
</button>
</div>
Expand Down

0 comments on commit 094dfd5

Please sign in to comment.