Skip to content

Commit

Permalink
display tag description and tag image on hover
Browse files Browse the repository at this point in the history
  • Loading branch information
pickleahead authored and WithoutPants committed Sep 22, 2022
1 parent 334d851 commit bf2a083
Show file tree
Hide file tree
Showing 11 changed files with 116 additions and 2 deletions.
1 change: 1 addition & 0 deletions graphql/documents/data/config.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ fragment ConfigGeneralData on ConfigGeneralResult {

fragment ConfigInterfaceData on ConfigInterfaceResult {
menuItems
showTagCardOnHover
soundOnPreview
wallShowTitle
wallPlayback
Expand Down
6 changes: 6 additions & 0 deletions graphql/schema/types/config.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,9 @@ input ConfigInterfaceInput {
"""Ordered list of items that should be shown in the menu"""
menuItems: [String!]

"""Show tag card when hovering tags"""
showTagCardOnHover: Boolean

"""Enable sound on mouseover previews"""
soundOnPreview: Boolean

Expand Down Expand Up @@ -291,6 +294,9 @@ type ConfigInterfaceResult {
"""Ordered list of items that should be shown in the menu"""
menuItems: [String!]

"""Show tag card when hovering tags"""
showTagCardOnHover: Boolean

"""Enable sound on mouseover previews"""
soundOnPreview: Boolean

Expand Down
1 change: 1 addition & 0 deletions internal/api/resolver_mutation_configure.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ func (r *mutationResolver) ConfigureInterface(ctx context.Context, input ConfigI
c.Set(config.MenuItems, input.MenuItems)
}

setBool(config.ShowTagCardOnHover, input.ShowTagCardOnHover)
setBool(config.SoundOnPreview, input.SoundOnPreview)
setBool(config.WallShowTitle, input.WallShowTitle)

Expand Down
2 changes: 2 additions & 0 deletions internal/api/resolver_query_configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ func makeConfigGeneralResult() *ConfigGeneralResult {
func makeConfigInterfaceResult() *ConfigInterfaceResult {
config := config.GetInstance()
menuItems := config.GetMenuItems()
showTagCardOnHover := config.GetShowTagCardOnHover()
soundOnPreview := config.GetSoundOnPreview()
wallShowTitle := config.GetWallShowTitle()
showScrubber := config.GetShowScrubber()
Expand All @@ -151,6 +152,7 @@ func makeConfigInterfaceResult() *ConfigInterfaceResult {

return &ConfigInterfaceResult{
MenuItems: menuItems,
ShowTagCardOnHover: &showTagCardOnHover,
SoundOnPreview: &soundOnPreview,
WallShowTitle: &wallShowTitle,
WallPlayback: &wallPlayback,
Expand Down
6 changes: 6 additions & 0 deletions internal/manager/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ const (
// Interface options
MenuItems = "menu_items"

ShowTagCardOnHover = "show_tag_card_on_hover"

SoundOnPreview = "sound_on_preview"

WallShowTitle = "wall_show_title"
Expand Down Expand Up @@ -877,6 +879,10 @@ func (i *Instance) GetMenuItems() []string {
return defaultMenuItems
}

func (i *Instance) GetShowTagCardOnHover() bool {
return i.getBool(ShowTagCardOnHover)
}

func (i *Instance) GetSoundOnPreview() bool {
return i.getBool(SoundOnPreview)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,14 @@ export const SettingsInterfacePanel: React.FC = () => {
onChange={(v) => saveInterface({ menuItems: v })}
/>
</div>

<BooleanSetting
id="show-tag-card-on-hover"
headingID="config.ui.show_tag_card_on_hover.heading"
subHeadingID="config.ui.show_tag_card_on_hover.description"
checked={iface.showTagCardOnHover ?? undefined}
onChange={(v) => saveInterface({ showTagCardOnHover: v })}
/>
</SettingSection>

<SettingSection headingID="config.ui.desktop_integration.desktop_integration">
Expand Down
7 changes: 6 additions & 1 deletion ui/v2.5/src/components/Shared/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { ConfigurationContext } from "src/hooks/Config";
import { useIntl } from "react-intl";
import { objectTitle } from "src/core/files";
import { galleryTitle } from "src/core/galleries";
import { TagPopover } from "../Tags/TagPopover";

export type ValidTypes =
| GQL.SlimPerformerDataFragment
Expand Down Expand Up @@ -659,7 +660,11 @@ export const TagSelect: React.FC<IFilterProps & { excludeIds?: string[] }> = (
};
}

return <reactSelectComponents.Option {...thisOptionProps} />;
return (
<TagPopover id={optionProps.data.value}>
<reactSelectComponents.Option {...thisOptionProps} />
</TagPopover>
);
};

const filterOption = (option: Option, rawInput: string): boolean => {
Expand Down
7 changes: 6 additions & 1 deletion ui/v2.5/src/components/Shared/TagLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import TextUtils from "src/utils/text";
import { objectTitle } from "src/core/files";
import { galleryTitle } from "src/core/galleries";
import * as GQL from "src/core/generated-graphql";
import { TagPopover } from "../Tags/TagPopover";

interface IFile {
path: string;
Expand All @@ -37,6 +38,7 @@ interface IProps {
}

export const TagLink: React.FC<IProps> = (props: IProps) => {
let id: string = "";
let link: string = "#";
let title: string = "";
if (props.tag) {
Expand All @@ -55,6 +57,7 @@ export const TagLink: React.FC<IProps> = (props: IProps) => {
link = NavUtils.makeTagImagesUrl(props.tag);
break;
}
id = props.tag.id || "";
title = props.tag.name || "";
} else if (props.performer) {
link = NavUtils.makePerformerScenesUrl(props.performer);
Expand All @@ -76,7 +79,9 @@ export const TagLink: React.FC<IProps> = (props: IProps) => {
}
return (
<Badge className={cx("tag-item", props.className)} variant="secondary">
<Link to={link}>{title}</Link>
<TagPopover id={id}>
<Link to={link}>{title}</Link>
</TagPopover>
</Badge>
);
};
57 changes: 57 additions & 0 deletions ui/v2.5/src/components/Tags/TagPopover.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import React from "react";
import { ErrorMessage, LoadingIndicator } from "../Shared";
import { HoverPopover } from "src/components/Shared";
import { useFindTag } from "../../core/StashService";
import { TagCard } from "./TagCard";
import { ConfigurationContext } from "../../hooks/Config";

interface ITagPopoverProps {
id?: string;
}

export const TagPopoverCard: React.FC<ITagPopoverCardProps> = ({ id }) => {
const { data, loading, error } = useFindTag(id ?? "");

if (loading)
return (
<div className="tag-popover-card-placeholder">
<LoadingIndicator card={true} message={""} />
</div>
);
if (error) return <ErrorMessage error={error.message} />;
if (!data?.findTag)
return <ErrorMessage error={`No tag found with id ${id}.`} />;

const tag = data.findTag;

return (
<div className="tag-popover-card">
<TagCard tag={tag} zoomIndex={0} />
</div>
);
};

export const TagPopover: React.FC<ITagPopoverProps> = ({ id, children }) => {
const { configuration: config } = React.useContext(ConfigurationContext);

const showTagCardOnHover = config?.interface.showTagCardOnHover ?? true;

if (!id || !showTagCardOnHover) {
return <>{children}</>;
}

return (
<HoverPopover
placement={"top"}
enterDelay={500}
leaveDelay={100}
content={<TagPopoverCard id={id} />}
>
{children}
</HoverPopover>
);
};

interface ITagPopoverCardProps {
id?: string;
}
19 changes: 19 additions & 0 deletions ui/v2.5/src/components/Tags/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,22 @@
margin-top: 1rem;
}
}

.tag-popover-card-placeholder {
display: flex;
max-width: 240px;
min-height: 314px;
width: calc(100vw - 2rem);
}

.tag-popover-card {
padding: 0.5rem;
text-align: left;

.card {
background: transparent;
box-shadow: none;
max-width: calc(100vw - 2rem);
padding: 0;
}
}
4 changes: 4 additions & 0 deletions ui/v2.5/src/locales/en-GB.json
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,10 @@
"description": "Show or hide different types of content on the navigation bar",
"heading": "Menu Items"
},
"show_tag_card_on_hover": {
"description": "Show tag card when hovering tag badges",
"heading": "Tag card tooltips"
},
"performers": {
"options": {
"image_location": {
Expand Down

0 comments on commit bf2a083

Please sign in to comment.