Skip to content
This repository has been archived by the owner on Feb 23, 2022. It is now read-only.

CEM-2507_Chair Highlight #373

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
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
56 changes: 41 additions & 15 deletions src/Containers/Chair/Chair.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useState } from 'react';
import styled, { css, useTheme } from 'styled-components';
import { Eye, EyeSlash } from '@styled-icons/bootstrap';

Expand Down Expand Up @@ -70,6 +70,8 @@ export interface IChair {
chairIndex: number,
selectedIndex: number,
) => void;


}

/**
Expand All @@ -86,9 +88,21 @@ export const Chair: React.FC<IChair> = ({
tableIndex = -1,
chairIndex = -1,
selectedIndex = -1,


onChairClick,
...props
}) => {
}):React.ReactElement => {
/**
* Use useState to change state of isFocusedActive and highlite
* the chair.
*/
const [isFocusedActive, setIsFocusedActive] = useState(false);

onChairClick =() => {
setIsFocusedActive(true)
}

/**
* Returns a JSX.Element for the Chair with RoundChair styles
* @returns {JSX.Element}
Expand All @@ -101,6 +115,8 @@ export const Chair: React.FC<IChair> = ({
isSeated={isSeated}
tableUse={tableUse}
isVisible={isVisible}
tabIndex={0}
isFocusedActive={isFocusedActive}
>
{getChairText()}
</RoundChair>
Expand All @@ -110,7 +126,6 @@ export const Chair: React.FC<IChair> = ({
/**
* Returns a JSX.Element for the Chair with the correct styles based on position
* @returns {JSX.Element}
*
*/
const getPositionChair: getPositionChairType = () => (
<div {...props}>
Expand All @@ -120,6 +135,8 @@ export const Chair: React.FC<IChair> = ({
position={position}
tableUse={tableUse}
isVisible={isVisible}
tabIndex={0}
isFocusedActive={isFocusedActive}
>
{getChairText()}
</RectangleChair>
Expand Down Expand Up @@ -183,18 +200,18 @@ export const Chair: React.FC<IChair> = ({
onChairClick(tableIndex, chairIndex, selectedIndex);
};

if (tableUse === 'TableForEditCanvas') {
return (
<ChairWrapperForClick
onClick={onHandleClick}
onKeyPress={onHandleClick}
role="button"
tabIndex={0}
>
{isRound ? getRoundChair() : getPositionChair()}
</ChairWrapperForClick>
);
}

return (
<ChairWrapperForClick
onClick={onHandleClick}
onKeyPress={onHandleClick}
role="button"
tabIndex={0}
>
{isRound ? getRoundChair() : getPositionChair()}
</ChairWrapperForClick>
);


return isRound ? getRoundChair() : getPositionChair();
};
Expand Down Expand Up @@ -399,6 +416,7 @@ interface IBaseChair {
isSeated: boolean;
tableUse: tableUseTypes;
isVisible: boolean;
isFocusedActive: boolean;
}

const BaseChair = styled.div<IBaseChair>`
Expand All @@ -422,6 +440,10 @@ const RoundChair = styled(BaseChair)<Pick<IChair, 'relativeSize'>>`
relativeSize * BASE_BORDER_WIDTH_FOR_ROUND_CHAIR
}px solid black;`;
}}

box-shadow: ${({ isFocusedActive
}) => (isFocusedActive &&
'0 0 0 2px')};
`;

const RectangleChair = styled(BaseChair)<
Expand All @@ -434,6 +456,10 @@ const RectangleChair = styled(BaseChair)<
left: VerticalChairStyle,
right: VerticalChairStyle,
}[position])};

box-shadow: ${({ isFocusedActive
}) => (isFocusedActive &&
'0 0 0 2px')};
`;

const RectangleChairText = styled.div<
Expand Down