option to override logo component

This commit is contained in:
Mary Hipp 2024-01-04 12:46:57 -05:00 committed by Kent Keirsey
parent f27bb402fb
commit bca7ea1674
4 changed files with 18 additions and 17 deletions

View File

@ -4,7 +4,6 @@ import type { Middleware } from '@reduxjs/toolkit';
import { $socketOptions } from 'app/hooks/useSocketIO';
import { $authToken } from 'app/store/nanostores/authToken';
import { $baseUrl } from 'app/store/nanostores/baseUrl';
import { $customAppInfo } from 'app/store/nanostores/customAppInfo';
import { $customNavComponent } from 'app/store/nanostores/customNavComponent';
import type { CustomStarUi } from 'app/store/nanostores/customStarUI';
import { $customStarUI } from 'app/store/nanostores/customStarUI';
@ -22,6 +21,7 @@ import React, { lazy, memo, useEffect, useMemo } from 'react';
import { Provider } from 'react-redux';
import { addMiddleware, resetMiddlewares } from 'redux-dynamic-middlewares';
import type { ManagerOptions, SocketOptions } from 'socket.io-client';
import { $logo } from 'app/store/nanostores/logo';
const App = lazy(() => import('./App'));
const ThemeLocaleProvider = lazy(() => import('./ThemeLocaleProvider'));
@ -42,7 +42,7 @@ interface Props extends PropsWithChildren {
customStarUi?: CustomStarUi;
socketOptions?: Partial<ManagerOptions & SocketOptions>;
isDebugging?: boolean;
customAppInfo?: string;
logo?: ReactNode;
}
const InvokeAIUI = ({
@ -58,7 +58,7 @@ const InvokeAIUI = ({
customStarUi,
socketOptions,
isDebugging = false,
customAppInfo,
logo,
}: Props) => {
useEffect(() => {
// configure API client token
@ -134,14 +134,14 @@ const InvokeAIUI = ({
}, [galleryHeader]);
useEffect(() => {
if (customAppInfo) {
$customAppInfo.set(customAppInfo);
if (logo) {
$logo.set(logo);
}
return () => {
$customAppInfo.set(undefined);
$logo.set(undefined);
};
}, [customAppInfo]);
}, [logo]);
useEffect(() => {
if (socketOptions) {

View File

@ -1,3 +0,0 @@
import { atom } from 'nanostores';
export const $customAppInfo = atom<string | undefined>();

View File

@ -0,0 +1,4 @@
import { atom } from 'nanostores';
import type { ReactNode } from 'react';
export const $logo = atom<ReactNode | undefined>(undefined);

View File

@ -1,27 +1,27 @@
/* eslint-disable i18next/no-literal-string */
import { Image } from '@chakra-ui/react';
import { useStore } from '@nanostores/react';
import { $customAppInfo } from 'app/store/nanostores/customAppInfo';
import InvokeLogoYellow from 'assets/images/invoke-key-ylw-sm.svg';
import { InvText } from 'common/components/InvText/wrapper';
import { InvTooltip } from 'common/components/InvTooltip/InvTooltip';
import { memo, useMemo, useRef } from 'react';
import { useGetAppVersionQuery } from 'services/api/endpoints/appInfo';
import { $logo } from '../../../app/store/nanostores/logo';
const InvokeAILogoComponent = () => {
const { data: appVersion } = useGetAppVersionQuery();
const ref = useRef(null);
const customAppInfo = useStore($customAppInfo);
const logoOverride = useStore($logo);
const tooltip = useMemo(() => {
if (customAppInfo) {
return <InvText fontWeight="semibold">{customAppInfo}</InvText>;
}
if (appVersion) {
return <InvText fontWeight="semibold">v{appVersion.version}</InvText>;
}
return null;
}, [appVersion, customAppInfo]);
}, [appVersion]);
if (logoOverride) {
return logoOverride;
}
return (
<InvTooltip placement="right" label={tooltip} p={1} px={2} gutter={16}>