Refresh HiveGrid Cloud reference snapshot
This commit is contained in:
1 parent
5e99e14772
commit
7f88026f79
5955 files changed
+1177325
-188362
No files matched your search
+61
@@ -0,0 +1,61 @@
|
||||
import "@testing-library/jest-dom";
|
||||
import { cleanup, render, screen } from "@testing-library/react";
|
||||
import { MemoryRouter } from "react-router";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import Icon from "./Icon";
|
||||
import Logo from "./Logo";
|
||||
import LogoLightMode from "./LogoLightMode";
|
||||
|
||||
vi.mock("react-i18next", () => ({
|
||||
useTranslation: () => ({
|
||||
t: (key: string) => ({ "shared.icon": "Symbol", "shared.logo": "Logo" })[key] ?? key,
|
||||
}),
|
||||
}));
|
||||
|
||||
vi.mock("~/utils/data/useRootData", () => ({
|
||||
useRootData: () => ({
|
||||
appConfiguration: {
|
||||
app: { name: "HiveGrid" },
|
||||
branding: {
|
||||
icon: "/icon-light.svg",
|
||||
iconDarkMode: "/icon-dark.svg",
|
||||
logo: "/logo-light.svg",
|
||||
logoDarkMode: "/logo-dark.svg",
|
||||
},
|
||||
},
|
||||
}),
|
||||
}));
|
||||
|
||||
afterEach(cleanup);
|
||||
|
||||
describe("brand asset alt text", () => {
|
||||
it("localizes the configured product logo label", () => {
|
||||
render(
|
||||
<MemoryRouter>
|
||||
<Logo />
|
||||
</MemoryRouter>
|
||||
);
|
||||
|
||||
expect(screen.getAllByAltText("HiveGrid Logo")).toHaveLength(2);
|
||||
});
|
||||
|
||||
it("localizes the configured product icon label", () => {
|
||||
render(
|
||||
<MemoryRouter>
|
||||
<Icon />
|
||||
</MemoryRouter>
|
||||
);
|
||||
|
||||
expect(screen.getAllByAltText("HiveGrid Symbol")).toHaveLength(2);
|
||||
});
|
||||
|
||||
it("localizes the light-mode product logo label", () => {
|
||||
render(
|
||||
<MemoryRouter>
|
||||
<LogoLightMode />
|
||||
</MemoryRouter>
|
||||
);
|
||||
|
||||
expect(screen.getByAltText("HiveGrid Logo")).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
@@ -3,6 +3,7 @@ import { Link } from "react-router";
|
||||
import { iconLight, iconDark } from "~/assets/brand/default";
|
||||
import { useRootData } from "~/utils/data/useRootData";
|
||||
import { Fragment } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
interface Props {
|
||||
className?: string;
|
||||
@@ -12,17 +13,20 @@ interface Props {
|
||||
|
||||
export default function Icon({ className = "", size = "h-9", fromConfig = true }: Props) {
|
||||
const { appConfiguration } = useRootData();
|
||||
const { t } = useTranslation();
|
||||
const productName = appConfiguration?.app?.name?.trim();
|
||||
const iconAlt = productName ? `${productName} ${t("shared.icon")}` : t("shared.icon");
|
||||
return (
|
||||
<Link to="/" className={clsx(className, "flex")}>
|
||||
{fromConfig && appConfiguration?.branding.icon ? (
|
||||
<Fragment>
|
||||
<img className={clsx(size, "hidden w-auto dark:block")} src={appConfiguration.branding.iconDarkMode ?? appConfiguration.branding.icon} alt="Icon" />
|
||||
<img className={clsx(size, "w-auto dark:hidden")} src={appConfiguration.branding.icon} alt="Icon" />
|
||||
<img className={clsx(size, "hidden w-auto dark:block")} src={appConfiguration.branding.iconDarkMode ?? appConfiguration.branding.icon} alt={iconAlt} />
|
||||
<img className={clsx(size, "w-auto dark:hidden")} src={appConfiguration.branding.icon} alt={iconAlt} />
|
||||
</Fragment>
|
||||
) : (
|
||||
<Fragment>
|
||||
<img className={clsx(size, "hidden w-auto dark:block")} src={iconDark} alt="Logo" />
|
||||
<img className={clsx(size, "w-auto dark:hidden")} src={iconLight} alt="Logo" />
|
||||
<img className={clsx(size, "hidden w-auto dark:block")} src={iconDark} alt={iconAlt} />
|
||||
<img className={clsx(size, "w-auto dark:hidden")} src={iconLight} alt={iconAlt} />
|
||||
</Fragment>
|
||||
)}
|
||||
</Link>
|
||||
|
||||
@@ -3,6 +3,7 @@ import clsx from "clsx";
|
||||
import { Link } from "react-router";
|
||||
import { useRootData } from "~/utils/data/useRootData";
|
||||
import { Fragment } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
interface Props {
|
||||
className?: string;
|
||||
@@ -12,6 +13,9 @@ interface Props {
|
||||
|
||||
export default function Logo({ className = "", size = "h-9", to }: Props) {
|
||||
const { appConfiguration } = useRootData();
|
||||
const { t } = useTranslation();
|
||||
const productName = appConfiguration?.app?.name?.trim();
|
||||
const logoAlt = productName ? `${productName} ${t("shared.logo")}` : t("shared.logo");
|
||||
return (
|
||||
<Link to={to ?? "/"} className={clsx(className, "flex")}>
|
||||
{/* <BrandLogo className="h-10 w-auto mx-auto" /> */}
|
||||
@@ -20,14 +24,14 @@ export default function Logo({ className = "", size = "h-9", to }: Props) {
|
||||
<img
|
||||
className={clsx(size, "mx-auto hidden w-auto dark:block")}
|
||||
src={appConfiguration.branding.logoDarkMode ?? appConfiguration.branding.logo}
|
||||
alt="Logo"
|
||||
alt={logoAlt}
|
||||
/>
|
||||
<img className={clsx(size, "mx-auto w-auto dark:hidden")} src={appConfiguration.branding.logo} alt="Logo" />
|
||||
<img className={clsx(size, "mx-auto w-auto dark:hidden")} src={appConfiguration.branding.logo} alt={logoAlt} />
|
||||
</Fragment>
|
||||
) : (
|
||||
<Fragment>
|
||||
<img className={clsx(size, "mx-auto hidden w-auto dark:block")} src={logoDark} alt="Logo" />
|
||||
<img className={clsx(size, "mx-auto w-auto dark:hidden")} src={logoLight} alt="Logo" />
|
||||
<img className={clsx(size, "mx-auto hidden w-auto dark:block")} src={logoDark} alt={logoAlt} />
|
||||
<img className={clsx(size, "mx-auto w-auto dark:hidden")} src={logoLight} alt={logoAlt} />
|
||||
</Fragment>
|
||||
)}
|
||||
</Link>
|
||||
|
||||
+6
-2
@@ -3,6 +3,7 @@ import clsx from "clsx";
|
||||
import { Link } from "react-router";
|
||||
import { useRootData } from "~/utils/data/useRootData";
|
||||
import { Fragment } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
interface Props {
|
||||
className?: string;
|
||||
@@ -12,16 +13,19 @@ interface Props {
|
||||
|
||||
export default function LogoLightMode({ className = "", size = "h-9", to }: Props) {
|
||||
const { appConfiguration } = useRootData();
|
||||
const { t } = useTranslation();
|
||||
const productName = appConfiguration?.app?.name?.trim();
|
||||
const logoAlt = productName ? `${productName} ${t("shared.logo")}` : t("shared.logo");
|
||||
return (
|
||||
<Link to={to ?? "/"} className={clsx(className, "flex")}>
|
||||
{/* <BrandLogo className="h-10 w-auto mx-auto" /> */}
|
||||
{appConfiguration?.branding.logo ? (
|
||||
<Fragment>
|
||||
<img className={clsx(size, "mx-auto w-auto")} src={appConfiguration.branding.logo} alt="Logo" />
|
||||
<img className={clsx(size, "mx-auto w-auto")} src={appConfiguration.branding.logo} alt={logoAlt} />
|
||||
</Fragment>
|
||||
) : (
|
||||
<Fragment>
|
||||
<img className={clsx(size, "mx-auto w-auto")} src={logoLight} alt="Logo" />
|
||||
<img className={clsx(size, "mx-auto w-auto")} src={logoLight} alt={logoAlt} />
|
||||
</Fragment>
|
||||
)}
|
||||
</Link>
|
||||
|
||||
Reference in new issue
Block a user