Skip to content

Commit 52f13ac

Browse files
More select buttons for maps
1 parent 52cac2f commit 52f13ac

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

client/src/components/button.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React, { MouseEvent, PropsWithChildren } from 'react'
22

33
type Props = {
44
className?: string
5+
style?: React.CSSProperties
56
onClick: (event: MouseEvent<HTMLButtonElement>) => void
67
disabled?: boolean
78
}
@@ -15,6 +16,7 @@ export const Button = (props: PropsWithChildren<Props>) => {
1516
(props.disabled ? ' opacity-50 cursor-not-allowed' : '')
1617
}
1718
onClick={props.onClick}
19+
style={props.style}
1820
>
1921
{props.children}
2022
</button>
@@ -28,6 +30,7 @@ export const SmallButton = (props: PropsWithChildren<Props>) => (
2830
(props.className ?? '')
2931
}
3032
onClick={props.onClick}
33+
style={props.style}
3134
>
3235
{props.children}
3336
</button>
@@ -40,6 +43,7 @@ export const BrightButton = (props: PropsWithChildren<Props>) => (
4043
(props.className ?? '')
4144
}
4245
onClick={props.onClick}
46+
style={props.style}
4347
>
4448
{props.children}
4549
</button>

client/src/components/sidebar/runner/runner.tsx

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ import { nativeAPI } from './native-api-wrapper'
55
import { Select } from '../../forms'
66
import { InputDialog } from '../../input-dialog'
77
import Tooltip from '../../tooltip'
8-
import { SectionHeader } from '../../section-header'
98
import { FixedSizeList, ListOnScrollProps } from 'react-window'
10-
import { OpenExternal } from '../../../icons/open-external'
119
import { BasicDialog } from '../../basic-dialog'
1210
import { RingBuffer } from '../../../util/ring-buffer'
1311
import { ProfilerDialog } from './profiler'
@@ -141,11 +139,11 @@ export const RunnerPage: React.FC<RunnerPageProps> = ({ open, scaffold }) => {
141139
<MapSelector
142140
maps={maps}
143141
availableMaps={availableMaps}
144-
onSelect={(m) => setMaps(new Set([...maps, m]))}
145-
onDeselect={(m) => setMaps(new Set([...maps].filter((x) => x !== m)))}
142+
onSelect={(m) => setMaps(new Set([...maps, ...m]))}
143+
onDeselect={(m) => setMaps(new Set([...maps].filter((x) => !m.includes(x))))}
146144
/>
147145
<SmallButton
148-
className="mt-2"
146+
className="mt-3"
149147
onClick={() => {
150148
resetSettings()
151149
reloadData()
@@ -330,8 +328,8 @@ const TeamSelector: React.FC<TeamSelectorProps> = ({ teamA, teamB, options, onCh
330328
interface MapSelectorProps {
331329
maps: Set<string>
332330
availableMaps: Set<string>
333-
onSelect: (map: string) => void
334-
onDeselect: (map: string) => void
331+
onSelect: (map: string[]) => void
332+
onDeselect: (map: string[]) => void
335333
}
336334

337335
const MapSelector: React.FC<MapSelectorProps> = ({ maps, availableMaps, onSelect, onDeselect }) => {
@@ -354,7 +352,7 @@ const MapSelector: React.FC<MapSelectorProps> = ({ maps, availableMaps, onSelect
354352
<div
355353
key={m}
356354
className={'cursor-pointer hover:bg-lightHighlight flex items-center justify-between'}
357-
onClick={() => (maps.has(m) ? onDeselect(m) : onSelect(m))}
355+
onClick={() => (maps.has(m) ? onDeselect([m]) : onSelect([m]))}
358356
>
359357
{m}
360358
<input
@@ -368,6 +366,14 @@ const MapSelector: React.FC<MapSelectorProps> = ({ maps, availableMaps, onSelect
368366
})}
369367
</div>
370368
</Resizable>
369+
<div className="flex gap-2 items-center mt-1 justify-center">
370+
<SmallButton style={{ margin: 0 }} onClick={() => onSelect([...availableMaps])}>
371+
Select All
372+
</SmallButton>
373+
<SmallButton style={{ margin: 0 }} onClick={() => onDeselect([...availableMaps])}>
374+
Deselect All
375+
</SmallButton>
376+
</div>
371377
</div>
372378
)
373379
}

0 commit comments

Comments
 (0)