Skip to content

Commit 58a5d9e

Browse files
committed
fix(Seat): display as div when non-clickable
If the Seat is available and has onClick set, renders it as an interactive button, otherwise renders it as a non-interactive div Closes FEPLT-2265
1 parent 1b39e2d commit 58a5d9e

File tree

2 files changed

+43
-32
lines changed

2 files changed

+43
-32
lines changed

packages/orbit-components/src/Seat/Seat.stories.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ export const Playground: Story = {
7171
true: action("onClick"),
7272
false: undefined,
7373
},
74-
defaultValue: true,
7574
},
7675
},
7776
};

packages/orbit-components/src/Seat/index.tsx

+43-31
Original file line numberDiff line numberDiff line change
@@ -29,40 +29,52 @@ const Seat = ({
2929
const randomId = useRandomIdSeed();
3030
const titleId = title ? randomId("title") : "";
3131
const descrId = description ? randomId("descr") : "";
32-
const clickable = type !== TYPES.UNAVAILABLE;
32+
const isAvailable = type !== TYPES.UNAVAILABLE;
33+
const clickable = isAvailable && onClick !== undefined;
3334

34-
return (
35-
<Stack inline grow={false} spacing="50" direction="column" align="center">
36-
<button
37-
className={cx(
38-
"orbit-seat font-base group relative",
39-
size === SIZE_OPTIONS.SMALL ? "w-800 h-[36px]" : "size-[46px]",
40-
)}
41-
data-test={dataTest}
42-
id={id}
43-
disabled={!clickable}
44-
onClick={clickable ? onClick : undefined}
45-
tabIndex={clickable ? 0 : -1}
46-
type="button"
35+
const commonProps = {
36+
className: cx(
37+
"orbit-seat font-base group relative",
38+
isAvailable && "cursor-pointer",
39+
size === SIZE_OPTIONS.SMALL ? "w-800 h-[36px]" : "size-[46px]",
40+
),
41+
id,
42+
"data-test": dataTest,
43+
};
44+
45+
const seatContent = (
46+
<>
47+
<svg
48+
viewBox={size === SIZE_OPTIONS.SMALL ? "0 0 32 36" : "0 0 46 46"}
49+
aria-labelledby={`${[ariaLabelledBy, titleId, descrId].join(" ").trim()}` || undefined}
50+
fill="none"
51+
role="img"
4752
>
48-
<svg
49-
viewBox={size === SIZE_OPTIONS.SMALL ? "0 0 32 36" : "0 0 46 46"}
50-
aria-labelledby={`${[ariaLabelledBy, titleId, descrId].join(" ").trim()}` || undefined}
51-
fill="none"
52-
role="img"
53-
>
54-
{title && <title id={titleId}>{title}</title>}
55-
{description && <desc id={descrId}>{description}</desc>}
53+
{title && <title id={titleId}>{title}</title>}
54+
{description && <desc id={descrId}>{description}</desc>}
55+
56+
{size === SIZE_OPTIONS.SMALL ? (
57+
<SeatSmall type={type} selected={selected} label={label} />
58+
) : (
59+
<SeatNormal type={type} selected={selected} label={label} />
60+
)}
61+
</svg>
62+
{selected && isAvailable && <SeatCircle size={size} type={type} />}
63+
</>
64+
);
5665

57-
{size === SIZE_OPTIONS.SMALL ? (
58-
<SeatSmall type={type} selected={selected} label={label} />
59-
) : (
60-
<SeatNormal type={type} selected={selected} label={label} />
61-
)}
62-
</svg>
63-
{selected && clickable && <SeatCircle size={size} type={type} />}
64-
</button>
65-
{price && !(selected && type === TYPES.UNAVAILABLE) && (
66+
return (
67+
<Stack inline grow={false} spacing="50" direction="column" align="center">
68+
{clickable ? (
69+
<button {...commonProps} onClick={onClick} type="button" aria-pressed={selected}>
70+
{seatContent}
71+
</button>
72+
) : (
73+
<div {...commonProps} role="button" aria-pressed={selected} aria-disabled="true">
74+
{seatContent}
75+
</div>
76+
)}
77+
{price && !(selected && !isAvailable) && (
6678
<Text size="small" type="secondary">
6779
{price}
6880
</Text>

0 commit comments

Comments
 (0)