fix: les resistants actuels sont en grayscale

proto-module-actu-react
Jalil Arfaoui 2023-08-31 18:41:05 +02:00
parent de691cd1e4
commit f8b3476489
4 changed files with 16 additions and 9 deletions

View File

@ -1,7 +1,8 @@
import { useNavigate } from "react-router"; import { useNavigate } from "react-router";
import { isAncienResistant, Resistant } from "../../../Resistant"; import { Resistant } from "../../../Resistant";
import { getResistantPhotoUrl } from "../../../getResistantPhotoUrl"; import { getResistantPhotoUrl } from "../../../getResistantPhotoUrl";
import { Separator } from "../../../components/Separator"; import { Separator } from "../../../components/Separator";
import { getResistantGrayscaleRule } from "../../../style/getResistantGrayscaleRule";
interface Props { interface Props {
resistant: Resistant; resistant: Resistant;
@ -39,11 +40,9 @@ export const ResistantRow = ({ resistant }: Props) => {
src={getResistantPhotoUrl(resistant)} src={getResistantPhotoUrl(resistant)}
alt={resistant.noms} alt={resistant.noms}
style={{ style={{
...getResistantGrayscaleRule(resistant),
width: "200px", width: "200px",
height: "200px", height: "200px",
filter: `grayscale(${
isAncienResistant(resistant) ? "80%" : "1"
})`,
}} }}
/> />
</div> </div>

View File

@ -4,6 +4,7 @@ import { isAncienResistant, Resistant } from "../../../Resistant";
import { getResistantPhotoUrl } from "../../../getResistantPhotoUrl"; import { getResistantPhotoUrl } from "../../../getResistantPhotoUrl";
import { HomeContext } from "../../../context/HomeContext"; import { HomeContext } from "../../../context/HomeContext";
import { getResistantPageUrl } from "../../../getResistantPageUrl"; import { getResistantPageUrl } from "../../../getResistantPageUrl";
import { getResistantGrayscaleRule } from "../../../style/getResistantGrayscaleRule";
export const PopupContent = ({ resistant }: { resistant: Resistant }) => { export const PopupContent = ({ resistant }: { resistant: Resistant }) => {
const navigate = useNavigate(); const navigate = useNavigate();
@ -21,10 +22,10 @@ export const PopupContent = ({ resistant }: { resistant: Resistant }) => {
<img <img
src={getResistantPhotoUrl(resistant)} src={getResistantPhotoUrl(resistant)}
style={{ style={{
...getResistantGrayscaleRule(resistant),
float: "left", float: "left",
maxHeight: "15em", maxHeight: "15em",
marginRight: "1em", marginRight: "1em",
filter: `grayscale(${isAncienResistant(resistant) ? "80%" : "1"})`,
}} }}
alt={resistant.noms} alt={resistant.noms}
/> />

View File

@ -1,10 +1,11 @@
import { useNavigate } from "react-router"; import { useNavigate } from "react-router";
import { BackgroundImage, Text } from "@mantine/core"; import { BackgroundImage, Text } from "@mantine/core";
import { getResistantPhotoUrl } from "../../../getResistantPhotoUrl"; import { getResistantPhotoUrl } from "../../../getResistantPhotoUrl";
import { isAncienResistant, Resistant } from "../../../Resistant"; import { Resistant } from "../../../Resistant";
import React from "react"; import React from "react";
import { HomeContext } from "../../../context/HomeContext"; import { HomeContext } from "../../../context/HomeContext";
import { getResistantPageUrl } from "../../../getResistantPageUrl"; import { getResistantPageUrl } from "../../../getResistantPageUrl";
import { getResistantGrayscaleRule } from "../../../style/getResistantGrayscaleRule";
interface Props { interface Props {
resistant: Resistant; resistant: Resistant;
@ -18,9 +19,7 @@ export const ResistantThumb = ({ resistant }: Props) => {
<BackgroundImage <BackgroundImage
src={getResistantPhotoUrl(resistant)} src={getResistantPhotoUrl(resistant)}
className="resistant-thumb" className="resistant-thumb"
style={{ style={getResistantGrayscaleRule(resistant)}
filter: `grayscale(${isAncienResistant(resistant) ? "80%" : "1"})`,
}}
> >
<div <div
className="thumb resistant-thumb" className="thumb resistant-thumb"

View File

@ -0,0 +1,8 @@
import { isAncienResistant, Resistant } from "../Resistant";
import React from "react";
export const getResistantGrayscaleRule = (
resistant: Resistant
): React.CSSProperties => ({
filter: `grayscale(${isAncienResistant(resistant) ? "40%" : "0"})`,
});