diff --git a/src/components/NewUI/Availability.tsx b/src/components/NewUI/Availability.tsx index 75718bf..7ade014 100644 --- a/src/components/NewUI/Availability.tsx +++ b/src/components/NewUI/Availability.tsx @@ -1,5 +1,5 @@ import { CSSProperties } from '@material-ui/styles'; -import { useCallback, useMemo } from 'react'; +import { MouseEventHandler, useCallback, useState } from 'react'; export type AvailabilityKind = | 'going/can-bring-someone' @@ -18,10 +18,19 @@ const optionStyle: CSSProperties = { height: '3rem', backgroundColor: 'white', display: 'flex', - flexDirection: 'column', + flexDirection: 'row', justifyContent: 'center', alignItems: 'center', cursor: 'pointer', + transition: 'background-color 100ms cubic-bezier', + userSelect: 'none', + position: 'relative', + fontWeight: 'normal', +}; + +const selectedOptionStyle = { + ...optionStyle, + fontWeight: 600, }; function Option({ @@ -33,20 +42,17 @@ function Option({ current: AvailabilityKind; onSelected: (kind: AvailabilityKind) => void; }) { - const style = useMemo( - () => - current === bind - ? { ...optionStyle, backgroundColor: '#5080f0', color: 'white' } - : optionStyle, - [bind, current] + const selected = current === bind; + + const select: MouseEventHandler = useCallback( + (event) => { + onSelected(bind); + }, + [onSelected, bind] ); - const select = useCallback(() => { - onSelected(bind); - }, [onSelected, bind]); - return ( -
+
{availabilityNames[bind]}
); @@ -54,11 +60,19 @@ function Option({ export default function Availability({ selected, - onSelected, + onSelected: onSelectedInner, }: { selected: AvailabilityKind; onSelected: (kind: AvailabilityKind) => void; }) { + const [focused, setFocused] = useState(false); + const onSelected = useCallback( + (kind: AvailabilityKind) => { + setFocused(false); + onSelectedInner(kind); + }, + [onSelectedInner] + ); return (
setFocused(false)} > -
); }