Skip to content

Commit

Permalink
changes to unlock button
Browse files Browse the repository at this point in the history
  • Loading branch information
sophiabeluli committed Sep 3, 2024
1 parent 884e982 commit ea335f6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
4 changes: 1 addition & 3 deletions src/app/src/features/MachineStatus/MachineStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ interface Message {
* @param {Object} actions Actions object given from parent component
*/
const MachineStatus: React.FC<MachineStatusProps> = ({ activeState, alarmCode, isConnected }) => {
console.log(activeState);

const unlock = (): void => {
if (
alarmCode === 1 ||
Expand Down Expand Up @@ -113,7 +111,7 @@ const MachineStatus: React.FC<MachineStatusProps> = ({ activeState, alarmCode, i
}
</div>
<div className="mt-4">
{ activeState === GRBL_ACTIVE_STATE_ALARM && <UnlockButton onClick={unlock} alarmCode={alarmCode} activeState={activeState} /> }
{ (activeState === GRBL_ACTIVE_STATE_ALARM || activeState === GRBL_ACTIVE_STATE_HOLD) && <UnlockButton onClick={unlock} alarmCode={alarmCode} activeState={activeState} /> }
</div>
</div>
)
Expand Down
9 changes: 4 additions & 5 deletions src/app/src/features/MachineStatus/UnlockButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import React, { MouseEventHandler } from 'react';
import cx from 'classnames';

import { GRBL_ACTIVE_STATE_ALARM, GRBL_ACTIVE_STATE_HOLD } from '../../constants';
import { GRBL_ACTIVE_STATE_ALARM } from '../../constants';
import { GRBL_ACTIVE_STATES_T } from 'definitions/general';
import { ALARM_CODE } from './definitions';

Expand All @@ -36,9 +36,7 @@ export interface UnlockProps {

const UnlockButton: React.FC<UnlockProps> = ({ activeState, alarmCode, onClick }) => {
const getButtonText = (): string => {
if (activeState === GRBL_ACTIVE_STATE_HOLD) {
return 'Cycle Start';
} else if (alarmCode === 11) {
if (alarmCode === 11) {
return 'Click to Run Homing';
}
return 'Click to Unlock Machine';
Expand All @@ -49,10 +47,11 @@ const UnlockButton: React.FC<UnlockProps> = ({ activeState, alarmCode, onClick }
<button
type="button"
className={cx(
"max-w-40 w-10/12 flex flex-row items-center justify-center p-4 rounded-[2rem] font-bold text-white border-solid border-[1px] opacity-90 hover:opacity-70",
"w-[8.5rem] flex flex-row items-center justify-between p-3 rounded-3xl leading-tight line-s text-white border-solid border-[1px] opacity-90 hover:opacity-70",
{
"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
}
)}
onClick={onClick}
Expand Down

0 comments on commit ea335f6

Please sign in to comment.