Make multiset mode buttons more obvious (#1435)

This commit is contained in:
WithoutPants
2021-06-01 08:55:15 +10:00
committed by GitHub
parent eec071f248
commit 975343d2e9
3 changed files with 38 additions and 39 deletions

View File

@@ -7,6 +7,7 @@
* Added [DLNA server](/settings?tab=dlna). ([#1364](https://github.com/stashapp/stash/pull/1364))
### 🎨 Improvements
* Make multi-set mode buttons more obvious in multi-edit dialog. ([#1435](https://github.com/stashapp/stash/pull/1435))
* Filter modifiers and sort by options are now sorted alphabetically. ([#1406](https://github.com/stashapp/stash/pull/1406))
* Add `CreatedAt` and `UpdatedAt` (and `FileModTime` where applicable) to API objects. ([#1421](https://github.com/stashapp/stash/pull/1421))
* Add Studios Performer filter criterion. ([#1405](https://github.com/stashapp/stash/pull/1405))

View File

@@ -1,8 +1,7 @@
import * as React from "react";
import * as GQL from "src/core/generated-graphql";
import { Button, InputGroup } from "react-bootstrap";
import { Icon } from "src/components/Shared";
import { Button, ButtonGroup } from "react-bootstrap";
import { FilterSelect } from "./Select";
type ValidTypes =
@@ -23,25 +22,20 @@ interface IMultiSetProps {
const MultiSet: React.FunctionComponent<IMultiSetProps> = (
props: IMultiSetProps
) => {
const modes = [
GQL.BulkUpdateIdMode.Set,
GQL.BulkUpdateIdMode.Add,
GQL.BulkUpdateIdMode.Remove,
];
function onUpdate(items: ValidTypes[]) {
props.onUpdate(items);
}
function getModeIcon() {
switch (props.mode) {
function getModeText(mode: GQL.BulkUpdateIdMode) {
switch (mode) {
case GQL.BulkUpdateIdMode.Set:
return "pencil-alt";
case GQL.BulkUpdateIdMode.Add:
return "plus";
case GQL.BulkUpdateIdMode.Remove:
return "times";
}
}
function getModeText() {
switch (props.mode) {
case GQL.BulkUpdateIdMode.Set:
return "Set";
return "Overwrite";
case GQL.BulkUpdateIdMode.Add:
return "Add";
case GQL.BulkUpdateIdMode.Remove:
@@ -49,31 +43,25 @@ const MultiSet: React.FunctionComponent<IMultiSetProps> = (
}
}
function nextMode() {
switch (props.mode) {
case GQL.BulkUpdateIdMode.Set:
return GQL.BulkUpdateIdMode.Add;
case GQL.BulkUpdateIdMode.Add:
return GQL.BulkUpdateIdMode.Remove;
case GQL.BulkUpdateIdMode.Remove:
return GQL.BulkUpdateIdMode.Set;
}
function renderModeButton(mode: GQL.BulkUpdateIdMode) {
return (
<Button
variant="primary"
active={props.mode === mode}
size="sm"
onClick={() => props.onSetMode(mode)}
disabled={props.disabled}
>
{getModeText(mode)}
</Button>
);
}
return (
<InputGroup className="multi-set">
<InputGroup.Prepend>
<Button
size="sm"
variant="primary"
onClick={() => props.onSetMode(nextMode())}
title={getModeText()}
disabled={props.disabled}
>
<Icon icon={getModeIcon()} className="fa-fw" />
</Button>
</InputGroup.Prepend>
<div>
<ButtonGroup className="button-group-above">
{modes.map((m) => renderModeButton(m))}
</ButtonGroup>
<FilterSelect
type={props.type}
isDisabled={props.disabled}
@@ -82,7 +70,7 @@ const MultiSet: React.FunctionComponent<IMultiSetProps> = (
onSelect={onUpdate}
ids={props.ids ?? []}
/>
</InputGroup>
</div>
);
};

View File

@@ -631,3 +631,13 @@ div.dropdown-menu {
border-color: inherit;
box-shadow: inherit;
}
.button-group-above {
.btn:first-child {
border-bottom-left-radius: 0;
}
.btn:last-child {
border-bottom-right-radius: 0;
}
}