Skip to content

Commit

Permalink
feat: config logo
Browse files Browse the repository at this point in the history
  • Loading branch information
asabotovich committed Feb 29, 2024
1 parent 77746e5 commit 6089542
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 22 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"@sentry/nextjs": "7.92.0",
"@tanstack/react-query": "4.29.5",
"@tanstack/react-query-devtools": "4.29.6",
"@taskany/bricks": "5.16.2",
"@taskany/bricks": "5.17.0",
"@taskany/colors": "1.11.0",
"@taskany/icons": "2.0.1",
"@tippyjs/react": "4.2.6",
Expand Down
2 changes: 2 additions & 0 deletions prisma/migrations/20240228135246_config_logo/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "AppConfig" ADD COLUMN "favicon" TEXT;
5 changes: 3 additions & 2 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@ model Team {
}

model AppConfig {
id String @id @default(cuid())
logo String?
id String @id @default(cuid())
favicon String?
logo String?
}
4 changes: 2 additions & 2 deletions src/components/Page/Page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export const Page: React.FC<PageProps> = ({ user, ssrTime, title = 'Untitled', c
return (
<pageContext.Provider value={{ user, theme, themeId: mapThemeOnId[theme], ssrTime }}>
<Head>
<link rel="icon" href={config?.logo || '/favicon.png'} />
<link rel="icon" href={config?.favicon || '/favicon.png'} />
<title>{title}</title>
<link rel="stylesheet" id="themeVariables" href={`/theme/${theme}.css`} />
</Head>
Expand All @@ -83,7 +83,7 @@ export const Page: React.FC<PageProps> = ({ user, ssrTime, title = 'Untitled', c
position="bottom-right"
/>

<PageHeader />
<PageHeader logo={config?.logo ?? undefined} />

<main className={s.PageMain} {...attrs}>
{children}
Expand Down
6 changes: 3 additions & 3 deletions src/components/PageHeader/PageHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FC, useCallback } from 'react';
import { ComponentProps, FC, useCallback } from 'react';
import NextLink from 'next/link';
import {
Header,
Expand All @@ -22,7 +22,7 @@ import { BetaBadge } from '../BetaBadge';
import { tr } from './PageHeader.i18n';
import s from './PageHeader.module.css';

export const PageHeader: FC = () => {
export const PageHeader: FC<{ logo?: ComponentProps<typeof PageHeaderLogo>['logo'] }> = ({ logo }) => {
const { userSettings, signIn } = useRouter();
const { user } = usePageContext();

Expand Down Expand Up @@ -52,7 +52,7 @@ export const PageHeader: FC = () => {
className={s.PageHeader}
logo={
<HeaderLogo>
<PageHeaderLogo />
<PageHeaderLogo logo={logo} />
</HeaderLogo>
}
menu={
Expand Down
16 changes: 6 additions & 10 deletions src/components/PageHeaderLogo.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import NextLink from 'next/link';
import { TaskanyLogo } from '@taskany/bricks';
import { TaskanyLogo } from '@taskany/bricks/harmony';

import { routes } from '../hooks/router';

export const PageHeaderLogo: React.FC = () => {
// TODO: resolve custom logo from settings in db

return (
<NextLink href={routes.index()} passHref>
<TaskanyLogo />
</NextLink>
);
};
export const PageHeaderLogo: React.FC<{ logo?: string }> = ({ logo }) => (
<NextLink href={routes.index()} passHref>
<TaskanyLogo src={logo} />
</NextLink>
);

0 comments on commit 6089542

Please sign in to comment.