forked from stashapp/stash
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Common studio overlay component (stashapp#4540)
* Move GridCard to own directory * Make common studio overlay component
- Loading branch information
1 parent
f655b12
commit 8b180ea
Showing
19 changed files
with
140 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import React, { useMemo } from "react"; | ||
import { Link } from "react-router-dom"; | ||
import { ConfigurationContext } from "src/hooks/Config"; | ||
|
||
interface IStudio { | ||
id: string; | ||
name: string; | ||
image_path?: string | null; | ||
} | ||
|
||
export const StudioOverlay: React.FC<{ | ||
studio: IStudio | null | undefined; | ||
}> = ({ studio }) => { | ||
const { configuration } = React.useContext(ConfigurationContext); | ||
|
||
const configValue = configuration?.interface.showStudioAsText; | ||
|
||
const showStudioAsText = useMemo(() => { | ||
if (configValue || !studio?.image_path) { | ||
return true; | ||
} | ||
|
||
// If the studio has a default image, show the studio name as text | ||
const studioImageURL = new URL(studio.image_path); | ||
if (studioImageURL.searchParams.get("default") === "true") { | ||
return true; | ||
} | ||
|
||
return false; | ||
}, [configValue, studio?.image_path]); | ||
|
||
if (!studio) return <></>; | ||
|
||
return ( | ||
// this class name is incorrect | ||
<div className="studio-overlay"> | ||
<Link to={`/studios/${studio.id}`}> | ||
{showStudioAsText ? ( | ||
studio.name | ||
) : ( | ||
<img | ||
className="image-thumbnail" | ||
loading="lazy" | ||
alt={studio.name} | ||
src={studio.image_path ?? ""} | ||
/> | ||
)} | ||
</Link> | ||
</div> | ||
); | ||
}; |
Oops, something went wrong.