Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ntrfcs 207 : Map legend open always for desktop #301

Merged
merged 6 commits into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from 5 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
9 changes: 8 additions & 1 deletion packages/seatmaps-client/src/Actions/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export interface Props {

interface DefaultProps {
showLegend: boolean;
showLegendOpenAlwaysForDesktop: boolean;
showControls: boolean;
onClearSelection(): void;
}
Expand All @@ -43,6 +44,7 @@ export default class Actions extends React.Component<

static defaultProps: DefaultProps = {
showLegend: true,
showLegendOpenAlwaysForDesktop: false,
showControls: true,
onClearSelection: () => {},
};
Expand Down Expand Up @@ -168,7 +170,12 @@ export default class Actions extends React.Component<
)}
{showRightActions && (
<ActionGroup>
<Legend ranges={this.props.ranges} />
<Legend
ranges={this.props.ranges}
showLegendOpenAlwaysForDesktop={
this.props.showLegendOpenAlwaysForDesktop
}
/>
</ActionGroup>
)}
</div>
Expand Down
32 changes: 30 additions & 2 deletions packages/seatmaps-client/src/Legend/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export interface Range {
export interface Props {
ranges: Range[];
isMobile?: boolean;
showLegendOpenAlwaysForDesktop?: boolean;
}

interface State {
Expand All @@ -29,6 +30,7 @@ interface State {
export default class Legend extends Component<Props, State> {
static defaultProps = {
isMobile: false,
showLegendOpenAlwaysForDesktop: false,
};

state = {
Expand All @@ -37,9 +39,35 @@ export default class Legend extends Component<Props, State> {

render() {
const { isOpen } = this.state;
const { ranges, isMobile } = this.props;
const { ranges, isMobile, showLegendOpenAlwaysForDesktop } = this.props;

return (
return showLegendOpenAlwaysForDesktop && !isMobile ? (
<div style={{ position: "relative" }}>
<div
style={{
position: "absolute",
backgroundColor: "white",
right: -2,
border: "2px solid lightgray",
borderRadius: "0 0 5px 5px",
}}
>
<h3 style={{ padding: "0 0 0 8px", textAlign: "left" }}>
Map Legend
</h3>
{ranges.map((range) => (
<div key={range.color} style={{ padding: 8, textAlign: "left" }}>
<Swatch color={range.color} style={{ marginRight: 8 }} />
<span>
{formatCurrency(Math.floor(range.min))}
{" - "}
{formatCurrency(Math.ceil(range.max))}
</span>
</div>
))}
</div>
</div>
) : (
<div style={{ position: "relative" }}>
<Button
onClick={() => this.setState({ isOpen: !isOpen })}
Expand Down
4 changes: 4 additions & 0 deletions packages/seatmaps-client/src/TicketMap/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export class TicketMap extends Component<Props & DefaultProps, State> {
},
ticketGroups: [],
showLegend: true,
showLegendOpenAlwaysForDesktop: false,
showControls: true,
mouseControlEnabled: true,
showZoomHelper: true,
Expand Down Expand Up @@ -668,6 +669,9 @@ export class TicketMap extends Component<Props & DefaultProps, State> {
onClearSelection={this.clearSelection}
ranges={$costRanges(this.state, this.props)}
showLegend={this.props.showLegend}
showLegendOpenAlwaysForDesktop={
this.props.showLegendOpenAlwaysForDesktop
}
showControls={this.props.showControls}
onZoomIn={this.handleZoomIn}
onZoomOut={this.handleZoomOut}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ exports[`Actions when controls are visible on desktop browsers matches snapshot
ranges={[]}
showControls={true}
showLegend={true}
showLegendOpenAlwaysForDesktop={false}
>
<div
data-testid="seatmaps-actions-menu"
Expand Down Expand Up @@ -251,6 +252,7 @@ exports[`Actions when controls are visible on desktop browsers matches snapshot
<Legend
isMobile={false}
ranges={[]}
showLegendOpenAlwaysForDesktop={false}
>
<div
style={
Expand Down Expand Up @@ -314,6 +316,7 @@ exports[`Actions when controls are visible on mobile browsers matches snapshot 1
ranges={[]}
showControls={true}
showLegend={true}
showLegendOpenAlwaysForDesktop={false}
>
<div
data-testid="seatmaps-actions-menu"
Expand Down Expand Up @@ -556,6 +559,7 @@ exports[`Actions when controls are visible on mobile browsers matches snapshot 1
<Legend
isMobile={false}
ranges={[]}
showLegendOpenAlwaysForDesktop={false}
>
<div
style={
Expand Down
1 change: 1 addition & 0 deletions packages/seatmaps-client/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const optionalConfigKeys: (keyof DefaultProps)[] = [
"sectionPercentiles",
"mapsDomain",
"showControls",
"showLegendOpenAlwaysForDesktop",
"showLegend",
"mouseControlEnabled",
"showZoomHelper",
Expand Down
1 change: 1 addition & 0 deletions packages/seatmaps-client/src/types/TicketMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export interface DefaultProps {
mapsDomain: string;
onSelection(sections: string[]): void;
showControls: boolean;
showLegendOpenAlwaysForDesktop: boolean;
mouseControlEnabled: boolean;
showZoomHelper: boolean;
missingSeatMapLogo?: React.ReactNode;
Expand Down
Loading