diff --git a/CHANGELOG.md b/CHANGELOG.md index daade7ce2..870574c0f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ - Users may now change their display name and password (only email accounts) on the new profile page - Highlighted code blocks can now use line wrapping and line numbers at once - Images, videos, and other non-text content is now wider in View Mode +- CodiMD instances can now be branded either with a '@ ' or '@ ' after the CodiMD logo and text ### Changed diff --git a/public/acme.png b/public/acme.png new file mode 100644 index 000000000..a8ddbad5c Binary files /dev/null and b/public/acme.png differ diff --git a/public/api/v2/config b/public/api/v2/config index a0ec2dcb8..c7c7992e4 100644 --- a/public/api/v2/config +++ b/public/api/v2/config @@ -13,6 +13,10 @@ "email": true, "openid": true }, + "branding": { + "name": "ACME Corp", + "logo": "http://localhost:3000/acme.png" + }, "banner": { "text": "This is the test banner text", "timestamp": "2020-05-22T20:46:08.962Z" diff --git a/src/api/backend-config/types.ts b/src/api/backend-config/types.ts index 874861f79..844a4e334 100644 --- a/src/api/backend-config/types.ts +++ b/src/api/backend-config/types.ts @@ -1,12 +1,18 @@ export interface BackendConfig { allowAnonymous: boolean, authProviders: AuthProvidersState, + branding: BrandingConfig, banner: BannerConfig, customAuthNames: CustomAuthNames, specialLinks: SpecialLinks, version: BackendVersion, } +export interface BrandingConfig { + name: string, + logo: string, +} + export interface BannerConfig { text: string timestamp: string diff --git a/src/components/common/branding/branding.scss b/src/components/common/branding/branding.scss new file mode 100644 index 000000000..164f57f8e --- /dev/null +++ b/src/components/common/branding/branding.scss @@ -0,0 +1,7 @@ +.regular-size { + height: 50px; +} + +.inline-size { + height: 30px; +} diff --git a/src/components/common/branding/branding.tsx b/src/components/common/branding/branding.tsx new file mode 100644 index 000000000..b31289e07 --- /dev/null +++ b/src/components/common/branding/branding.tsx @@ -0,0 +1,32 @@ +import React from 'react' +import { useSelector } from 'react-redux' +import { ApplicationState } from '../../../redux' +import { ShowIf } from '../show-if/show-if' +import './branding.scss' + +export interface BrandingProps { + inline?: boolean +} + +export const Branding: React.FC = ({ inline = false }) => { + const branding = useSelector((state: ApplicationState) => state.backendConfig.branding) + const showBranding = branding.name !== '' || branding.logo !== '' + + console.log(branding.logo) + + return ( + + @ + { + branding.logo + ? {branding.name} + : branding.name + } + + ) +} diff --git a/src/components/common/document-title/document-title.tsx b/src/components/common/document-title/document-title.tsx new file mode 100644 index 000000000..3154dc5f4 --- /dev/null +++ b/src/components/common/document-title/document-title.tsx @@ -0,0 +1,13 @@ +import React, { useEffect } from 'react' +import { useSelector } from 'react-redux' +import { ApplicationState } from '../../../redux' + +export const DocumentTitle: React.FC = () => { + const branding = useSelector((state: ApplicationState) => state.backendConfig.branding) + + useEffect(() => { + document.title = `CodiMD ${branding.name ? ` @ ${branding.name}` : ''}` + }, [branding]) + + return null +} diff --git a/src/components/editor/task-bar/task-bar.tsx b/src/components/editor/task-bar/task-bar.tsx index d868cf646..5a57c0444 100644 --- a/src/components/editor/task-bar/task-bar.tsx +++ b/src/components/editor/task-bar/task-bar.tsx @@ -2,6 +2,7 @@ import React from 'react' import { Button, Nav, Navbar } from 'react-bootstrap' import { Trans, useTranslation } from 'react-i18next' import { Link } from 'react-router-dom' +import { Branding } from '../../common/branding/branding' import { ForkAwesomeIcon } from '../../common/fork-awesome/fork-awesome-icon' import { ConnectionIndicator } from './connection-indicator' import { DarkModeButton } from './dark-mode-button' @@ -15,8 +16,10 @@ const TaskBar: React.FC = () => {