Added tooltips in more places
This commit is contained in:
parent
4b30dac878
commit
3873ef44f9
|
@ -1,17 +1,25 @@
|
||||||
import Chip from "components/Chip";
|
import Chip from "components/Chip";
|
||||||
|
import ToolTip from "components/ToolTip";
|
||||||
import {
|
import {
|
||||||
Enum_Componenttranslationschronologyitem_Status,
|
Enum_Componenttranslationschronologyitem_Status,
|
||||||
GetChronologyItemsQuery,
|
GetChronologyItemsQuery,
|
||||||
|
GetWebsiteInterfaceQuery,
|
||||||
} from "graphql/operations-types";
|
} from "graphql/operations-types";
|
||||||
|
import { getStatusDescription } from "queries/helpers";
|
||||||
|
import { useState } from "react";
|
||||||
|
|
||||||
export type ChronologyItemComponentProps = {
|
export type ChronologyItemComponentProps = {
|
||||||
item: GetChronologyItemsQuery["chronologyItems"]["data"][number];
|
item: GetChronologyItemsQuery["chronologyItems"]["data"][number];
|
||||||
displayYear: boolean;
|
displayYear: boolean;
|
||||||
|
langui: GetWebsiteInterfaceQuery["websiteInterfaces"]["data"][number]["attributes"];
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function ChronologyItemComponent(
|
export default function ChronologyItemComponent(
|
||||||
props: ChronologyItemComponentProps
|
props: ChronologyItemComponentProps
|
||||||
): JSX.Element {
|
): JSX.Element {
|
||||||
|
const { langui } = props;
|
||||||
|
const [statusHovered, setStatusHovered] = useState(false);
|
||||||
|
|
||||||
function generateAnchor(year: number, month: number, day: number): string {
|
function generateAnchor(year: number, month: number, day: number): string {
|
||||||
let result: string = "";
|
let result: string = "";
|
||||||
result += year;
|
result += year;
|
||||||
|
@ -85,7 +93,23 @@ export default function ChronologyItemComponent(
|
||||||
<div className="place-items-start place-content-start grid grid-flow-col gap-2">
|
<div className="place-items-start place-content-start grid grid-flow-col gap-2">
|
||||||
{translation.status !==
|
{translation.status !==
|
||||||
Enum_Componenttranslationschronologyitem_Status.Done && (
|
Enum_Componenttranslationschronologyitem_Status.Done && (
|
||||||
<Chip>{translation.status}</Chip>
|
<Chip
|
||||||
|
onMouseEnter={() => setStatusHovered(true)}
|
||||||
|
onMouseLeave={() => setStatusHovered(false)}
|
||||||
|
>
|
||||||
|
{translation.status}
|
||||||
|
<ToolTip
|
||||||
|
direction="top"
|
||||||
|
hovered={statusHovered}
|
||||||
|
offset={"1.5rem"}
|
||||||
|
maxWidth="max-w-[10rem]"
|
||||||
|
delayShow={100}
|
||||||
|
>
|
||||||
|
<p>
|
||||||
|
{getStatusDescription(translation.status, langui)}
|
||||||
|
</p>
|
||||||
|
</ToolTip>
|
||||||
|
</Chip>
|
||||||
)}
|
)}
|
||||||
{translation.title ? <h3>{translation.title}</h3> : ""}
|
{translation.title ? <h3>{translation.title}</h3> : ""}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,14 +1,20 @@
|
||||||
import ChronologyItemComponent from "components/Chronology/ChronologyItemComponent";
|
import ChronologyItemComponent from "components/Chronology/ChronologyItemComponent";
|
||||||
import { GetChronologyItemsQuery } from "graphql/operations-types";
|
import {
|
||||||
|
GetChronologyItemsQuery,
|
||||||
|
GetWebsiteInterfaceQuery,
|
||||||
|
} from "graphql/operations-types";
|
||||||
|
|
||||||
type ChronologyYearComponentProps = {
|
type ChronologyYearComponentProps = {
|
||||||
year: number;
|
year: number;
|
||||||
items: GetChronologyItemsQuery["chronologyItems"]["data"][number][];
|
items: GetChronologyItemsQuery["chronologyItems"]["data"][number][];
|
||||||
|
langui: GetWebsiteInterfaceQuery["websiteInterfaces"]["data"][number]["attributes"];
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function ChronologyYearComponent(
|
export default function ChronologyYearComponent(
|
||||||
props: ChronologyYearComponentProps
|
props: ChronologyYearComponentProps
|
||||||
): JSX.Element {
|
): JSX.Element {
|
||||||
|
const { langui } = props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className="target:bg-mid rounded-2xl target:py-4 target:my-4"
|
className="target:bg-mid rounded-2xl target:py-4 target:my-4"
|
||||||
|
@ -19,6 +25,7 @@ export default function ChronologyYearComponent(
|
||||||
key={index}
|
key={index}
|
||||||
item={item}
|
item={item}
|
||||||
displayYear={index === 0}
|
displayYear={index === 0}
|
||||||
|
langui={langui}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -4,7 +4,7 @@ type SubPanelProps = {
|
||||||
|
|
||||||
export default function SubPanel(props: SubPanelProps): JSX.Element {
|
export default function SubPanel(props: SubPanelProps): JSX.Element {
|
||||||
return (
|
return (
|
||||||
<div className="grid pt-10 pb-20 px-6 desktop:py-8 desktop:px-10 gap-y-2 justify-items-center text-center">
|
<div className="grid pt-10 pb-20 px-6 desktop:py-8 desktop:px-10 gap-y-2 text-center">
|
||||||
{props.children}
|
{props.children}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
@ -3,15 +3,17 @@ import { useEffect, useState } from "react";
|
||||||
type ToolTipProps = {
|
type ToolTipProps = {
|
||||||
hovered: boolean;
|
hovered: boolean;
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
delayShow?: number;
|
|
||||||
direction: "right" | "bottom" | "top" | "left";
|
direction: "right" | "bottom" | "top" | "left";
|
||||||
offset: string;
|
offset: string;
|
||||||
|
delayShow?: number;
|
||||||
|
maxWidth?: "max-w-[10rem]" | "max-w-xs" | "max-w-sm" | "max-w-md";
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function ToolTip(props: ToolTipProps): JSX.Element {
|
export default function ToolTip(props: ToolTipProps): JSX.Element {
|
||||||
const { children, hovered, direction, offset } = props;
|
const { children, hovered, direction, offset } = props;
|
||||||
let { delayShow } = props;
|
let { delayShow, maxWidth } = props;
|
||||||
if (delayShow === undefined) delayShow = 500;
|
if (delayShow === undefined) delayShow = 300;
|
||||||
|
if (maxWidth === undefined) maxWidth = "max-w-sm";
|
||||||
|
|
||||||
const [show, setShow] = useState(false);
|
const [show, setShow] = useState(false);
|
||||||
|
|
||||||
|
@ -62,7 +64,7 @@ export default function ToolTip(props: ToolTipProps): JSX.Element {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={`fixed z-[100] drop-shadow-shade-xl transition-opacity max-w-sm ${
|
className={`fixed z-[100] drop-shadow-shade-xl transition-opacity ${maxWidth} ${
|
||||||
show
|
show
|
||||||
? "opacity-100 pointer-events-auto"
|
? "opacity-100 pointer-events-auto"
|
||||||
: "opacity-0 pointer-events-none"
|
: "opacity-0 pointer-events-none"
|
||||||
|
@ -74,7 +76,7 @@ export default function ToolTip(props: ToolTipProps): JSX.Element {
|
||||||
className={`w-0 h-0 border-8 border-[transparent] place-self-center ${arrowCSS}`}
|
className={`w-0 h-0 border-8 border-[transparent] place-self-center ${arrowCSS}`}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="p-2 px-4 bg-light rounded-md">{children}</div>
|
<div className="p-4 px-6 bg-light rounded-md">{children}</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ import ThumbnailHeader from "components/Content/ThumbnailHeader";
|
||||||
import AppLayout from "components/AppLayout";
|
import AppLayout from "components/AppLayout";
|
||||||
import Markdawn from "components/Markdown/Markdawn";
|
import Markdawn from "components/Markdown/Markdawn";
|
||||||
import {
|
import {
|
||||||
|
getStatusDescription,
|
||||||
prettyinlineTitle,
|
prettyinlineTitle,
|
||||||
prettyLanguage,
|
prettyLanguage,
|
||||||
prettySlug,
|
prettySlug,
|
||||||
|
@ -26,6 +27,8 @@ import Chip from "components/Chip";
|
||||||
import RecorderChip from "components/RecorderChip";
|
import RecorderChip from "components/RecorderChip";
|
||||||
import { AppStaticProps, getAppStaticProps } from "queries/getAppStaticProps";
|
import { AppStaticProps, getAppStaticProps } from "queries/getAppStaticProps";
|
||||||
import TOC from "components/Markdown/TOC";
|
import TOC from "components/Markdown/TOC";
|
||||||
|
import ToolTip from "components/ToolTip";
|
||||||
|
import { useState } from "react";
|
||||||
|
|
||||||
interface ContentReadProps extends AppStaticProps {
|
interface ContentReadProps extends AppStaticProps {
|
||||||
content: GetContentTextQuery["contents"]["data"][number]["attributes"];
|
content: GetContentTextQuery["contents"]["data"][number]["attributes"];
|
||||||
|
@ -37,6 +40,8 @@ export default function ContentRead(props: ContentReadProps): JSX.Element {
|
||||||
const { langui, content, languages } = props;
|
const { langui, content, languages } = props;
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
|
const [statusHovered, setStatusHovered] = useState(false);
|
||||||
|
|
||||||
const subPanel = (
|
const subPanel = (
|
||||||
<SubPanel>
|
<SubPanel>
|
||||||
<ReturnButton
|
<ReturnButton
|
||||||
|
@ -77,7 +82,23 @@ export default function ContentRead(props: ContentReadProps): JSX.Element {
|
||||||
<div className="grid grid-flow-col place-items-center place-content-center gap-2">
|
<div className="grid grid-flow-col place-items-center place-content-center gap-2">
|
||||||
<p className="font-headers">{langui.status}:</p>
|
<p className="font-headers">{langui.status}:</p>
|
||||||
|
|
||||||
<Chip>{content.text_set[0].status}</Chip>
|
<Chip
|
||||||
|
onMouseEnter={() => setStatusHovered(true)}
|
||||||
|
onMouseLeave={() => setStatusHovered(false)}
|
||||||
|
>
|
||||||
|
{content.text_set[0].status}
|
||||||
|
<ToolTip
|
||||||
|
direction="top"
|
||||||
|
hovered={statusHovered}
|
||||||
|
offset={"1.5rem"}
|
||||||
|
maxWidth="max-w-[10rem]"
|
||||||
|
delayShow={100}
|
||||||
|
>
|
||||||
|
<p>
|
||||||
|
{getStatusDescription(content.text_set[0].status, langui)}
|
||||||
|
</p>
|
||||||
|
</ToolTip>
|
||||||
|
</Chip>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{content.text_set[0].transcribers.data.length > 0 && (
|
{content.text_set[0].transcribers.data.length > 0 && (
|
||||||
|
|
|
@ -25,7 +25,7 @@ interface ChronologyProps extends AppStaticProps {
|
||||||
|
|
||||||
export default function Chronology(props: ChronologyProps): JSX.Element {
|
export default function Chronology(props: ChronologyProps): JSX.Element {
|
||||||
useTesting(props);
|
useTesting(props);
|
||||||
const { chronologyItems, chronologyEras } = props;
|
const { chronologyItems, chronologyEras, langui } = props;
|
||||||
|
|
||||||
// Group by year the Chronology items
|
// Group by year the Chronology items
|
||||||
let chronologyItemYearGroups: GetChronologyItemsQuery["chronologyItems"]["data"][number][][][] =
|
let chronologyItemYearGroups: GetChronologyItemsQuery["chronologyItems"]["data"][number][][][] =
|
||||||
|
@ -102,6 +102,7 @@ export default function Chronology(props: ChronologyProps): JSX.Element {
|
||||||
key={`${eraIndex}-${index}`}
|
key={`${eraIndex}-${index}`}
|
||||||
year={items[0].attributes.year}
|
year={items[0].attributes.year}
|
||||||
items={items}
|
items={items}
|
||||||
|
langui={langui}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</>
|
</>
|
||||||
|
|
|
@ -4,6 +4,7 @@ import {
|
||||||
ImageQuality,
|
ImageQuality,
|
||||||
} from "components/Img";
|
} from "components/Img";
|
||||||
import {
|
import {
|
||||||
|
Enum_Componentsetstextset_Status,
|
||||||
GetCurrenciesQuery,
|
GetCurrenciesQuery,
|
||||||
GetLanguagesQuery,
|
GetLanguagesQuery,
|
||||||
GetLibraryItemQuery,
|
GetLibraryItemQuery,
|
||||||
|
@ -251,6 +252,28 @@ export function sortContent(
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getStatusDescription(
|
||||||
|
status: string,
|
||||||
|
langui: GetWebsiteInterfaceQuery["websiteInterfaces"]["data"][number]["attributes"]
|
||||||
|
): string {
|
||||||
|
switch (status) {
|
||||||
|
case Enum_Componentsetstextset_Status.Incomplete:
|
||||||
|
return langui.status_incomplete;
|
||||||
|
|
||||||
|
case Enum_Componentsetstextset_Status.Draft:
|
||||||
|
return langui.status_draft;
|
||||||
|
|
||||||
|
case Enum_Componentsetstextset_Status.Review:
|
||||||
|
return langui.status_review;
|
||||||
|
|
||||||
|
case Enum_Componentsetstextset_Status.Done:
|
||||||
|
return langui.status_done;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function slugify(str: string): string {
|
export function slugify(str: string): string {
|
||||||
return str
|
return str
|
||||||
.replace(/[ÀÁÂÃÄÅàáâãäåæÆ]/g, "a")
|
.replace(/[ÀÁÂÃÄÅàáâãäåæÆ]/g, "a")
|
||||||
|
|
Loading…
Reference in New Issue