diff --git a/core/core/src/configuration.ts b/core/core/src/configuration.ts
index cc1b203e4..25c971086 100644
--- a/core/core/src/configuration.ts
+++ b/core/core/src/configuration.ts
@@ -217,6 +217,10 @@ export interface RunOnlyConfiguration {
*/
title?: string;
+ /**
+ * logo for the site - can be a string link to an image, or a react node
+ */
+ logo?: string | ReactNode;
/**
* Deployed site url. Default is "https://component-controls.com"
*/
diff --git a/examples/gatsby/.config/runtime.tsx b/examples/gatsby/.config/runtime.tsx
index f180aaa3b..fe713110e 100644
--- a/examples/gatsby/.config/runtime.tsx
+++ b/examples/gatsby/.config/runtime.tsx
@@ -11,7 +11,7 @@ const config: RunOnlyConfiguration = {
analytics: 'UA-172446254-1',
siteTitle: `Component controls`,
siteUrl: `https://component-controls.com`,
- siteDescription: `A next-generation tool to create blazing-fast documentation sites.`,
+ siteDescription: `A next-generation tool to create blazing-fast documentation sites`,
siteLanguage: `en`,
author: `@component-controls`,
theme: {
diff --git a/examples/nextjs/.config/runtime.tsx b/examples/nextjs/.config/runtime.tsx
index 27f071608..696bd14ba 100644
--- a/examples/nextjs/.config/runtime.tsx
+++ b/examples/nextjs/.config/runtime.tsx
@@ -11,7 +11,7 @@ const config: RunOnlyConfiguration = {
analytics: 'UA-172446254-1',
siteTitle: `Component controls`,
siteUrl: `https://nextjs.component-controls.com`,
- siteDescription: `A next-generation tool to create blazing-fast documentation sites.`,
+ siteDescription: `A next-generation tool to create blazing-fast documentation sites`,
siteLanguage: `en`,
author: `@component-controls`,
theme: {
diff --git a/examples/stories/src/tutorial/getting-started/ui-customization.mdx b/examples/stories/src/tutorial/getting-started/ui-customization.mdx
index 04f844393..9d61837d5 100644
--- a/examples/stories/src/tutorial/getting-started/ui-customization.mdx
+++ b/examples/stories/src/tutorial/getting-started/ui-customization.mdx
@@ -35,6 +35,11 @@ The site meta settings are used both for SEO purposes as page `` tags an
value: '',
description: 'Standalone site title. Default is "Component controls"',
},
+ logo: {
+ type: ControlTypes.TEXT,
+ value: 'https://upload.wikimedia.org/wikipedia/commons/b/b8/Netlify_logo.svg',
+ description: 'Custom logo url',
+ },
siteUrl: {
type: ControlTypes.TEXT,
value: '',
@@ -61,18 +66,18 @@ The site meta settings are used both for SEO purposes as page `` tags an
description: 'Site author. Default is "@component-controls"',
}
}}>
- {({ siteTitle, siteUrl, siteDescription, siteCopyright, siteLanguage, author }) => {
+ {({ siteTitle, logo, siteUrl, siteDescription, siteCopyright, siteLanguage, author }) => {
return (
);
@@ -221,7 +226,7 @@ ${leftItems.length ? ` left: [\n${itemsToString(leftItems)}\n ],${rightIte
-### Insert toolbar logo
+### Insert toolbar item
You can insert a toolbar item at any position, by specifying the `order` property.
diff --git a/package.json b/package.json
index cd5c191cf..44594b0f3 100644
--- a/package.json
+++ b/package.json
@@ -53,6 +53,7 @@
"@commitlint/config-lerna-scopes": "^8.2.0",
"@component-controls/ts-markdown-docs": "^1.3.0",
"@rollup/plugin-node-resolve": "^7.1.1",
+ "@rollup/plugin-image": "^2.0.5",
"@rollup/plugin-json": "^4.0.2",
"@rollup/plugin-commonjs": "^11.0.2",
"@types/fs-extra": "^8.0.0",
diff --git a/rollup-config.js b/rollup-config.js
index f1aba92f7..cc20fe2ec 100644
--- a/rollup-config.js
+++ b/rollup-config.js
@@ -2,6 +2,7 @@ import typescript from 'rollup-plugin-typescript2';
import json from '@rollup/plugin-json';
import commonjs from '@rollup/plugin-commonjs';
import resolve from '@rollup/plugin-node-resolve';
+import image from '@rollup/plugin-image';
const defaultExternal = id =>
!id.startsWith('\0') &&
@@ -22,6 +23,7 @@ const createOutput = (dir = 'dist', defaultOpts) => {
include: /\/node_modules\//,
}),
json(),
+ image(),
typescript({
typescript: require('typescript'),
rollupCommonJSResolveHack: true,
diff --git a/ui/app/src/Header/Header.tsx b/ui/app/src/Header/Header.tsx
index b20149732..24a6f2367 100644
--- a/ui/app/src/Header/Header.tsx
+++ b/ui/app/src/Header/Header.tsx
@@ -1,6 +1,6 @@
/** @jsx jsx */
import { FC, useContext, useMemo } from 'react';
-import { jsx, Box, Heading } from 'theme-ui';
+import { jsx, Box, Heading, Image } from 'theme-ui';
import { DocType, getDocTypePath, getHomePath } from '@component-controls/core';
import { ActionBar, ActionItems, Link } from '@component-controls/components';
import {
@@ -16,6 +16,7 @@ import {
useStore,
} from '@component-controls/store';
import { Search } from '@component-controls/blocks';
+import * as logoImg from './logo.jpg';
export interface HeaderProps {
toolbar?: {
@@ -34,11 +35,38 @@ export const Header: FC = ({ toolbar = {} }) => {
const docCounts = useDocTypeCount();
const config = useConfig();
const doc = useCurrentDocument();
- const { pages, siteTitle } = config || {};
+ const { pages, siteTitle, logo, siteDescription } = config || {};
+ const LogoLink: FC = ({ children }) => (
+
+ {children}
+
+ );
+ const LogoImage: FC<{ src: string }> = ({ src }) => (
+
+ );
const leftActions: ActionItems = useMemo(() => {
const actions: ActionItems = [
{
- node: 'Home',
+ node: logo ? (
+ typeof logo === 'string' ? (
+
+
+
+ ) : (
+ logo
+ )
+ ) : logo === null ? (
+ 'Home'
+ ) : (
+
+
+
+ ),
href: homePath,
'aria-label': 'go to home page',
id: 'home',
@@ -69,14 +97,27 @@ export const Header: FC = ({ toolbar = {} }) => {
Array.prototype.push.apply(actions, pageItems);
} else {
actions[0].node = (
-
- {siteTitle}
-
+
+ {logo === null ? (
+ {siteTitle}
+ ) : (
+
+ )}
+
);
}
}
return toolbar.left ? [...actions, ...toolbar.left] : actions;
- }, [pages, toolbar.left, docCounts, homePath, store, homePage, siteTitle]);
+ }, [
+ pages,
+ toolbar.left,
+ logo,
+ docCounts,
+ homePath,
+ store,
+ homePage,
+ siteTitle,
+ ]);
const rightActions: ActionItems = useMemo(() => {
const actions: ActionItems = [
diff --git a/ui/app/src/Header/logo.jpg b/ui/app/src/Header/logo.jpg
new file mode 100644
index 000000000..87ccb53a5
Binary files /dev/null and b/ui/app/src/Header/logo.jpg differ
diff --git a/ui/app/src/typings.d.ts b/ui/app/src/typings.d.ts
index 159a5e3e6..9b76a34cc 100644
--- a/ui/app/src/typings.d.ts
+++ b/ui/app/src/typings.d.ts
@@ -1 +1,2 @@
declare module '@analytics/google-analytics';
+declare module '*.jpg';
diff --git a/ui/components/src/ActionBar/ActionBar.tsx b/ui/components/src/ActionBar/ActionBar.tsx
index 7425704f1..009b48355 100644
--- a/ui/components/src/ActionBar/ActionBar.tsx
+++ b/ui/components/src/ActionBar/ActionBar.tsx
@@ -39,6 +39,9 @@ export const ActionBar: FC = ({
sx={{
mr: index === 0 ? 1 : 0,
ml: nextGroup !== group || group === undefined ? 2 : 1,
+ display: 'flex',
+ flexDirection: 'row',
+ alignItems: 'center',
}}
>
{typeof node === 'string' ? (
diff --git a/ui/components/src/ThemeContext/theme.ts b/ui/components/src/ThemeContext/theme.ts
index 7979efca9..691216c4e 100644
--- a/ui/components/src/ThemeContext/theme.ts
+++ b/ui/components/src/ThemeContext/theme.ts
@@ -959,6 +959,11 @@ export const theme: ControlsTheme = {
fontWeight: 'normal',
':hover': { color: `secondary` },
},
+ logo: {
+ maxHeight: 30,
+ width: 'auto',
+ objectFit: 'cover',
+ },
items: {
display: 'flex',
flexDirection: 'row',
diff --git a/yarn.lock b/yarn.lock
index 24fca17a1..e37e22976 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -3230,6 +3230,14 @@
magic-string "^0.25.2"
resolve "^1.11.0"
+"@rollup/plugin-image@^2.0.5":
+ version "2.0.5"
+ resolved "https://registry.yarnpkg.com/@rollup/plugin-image/-/plugin-image-2.0.5.tgz#07859a69f5fe592643c2ad3ef59ae8a5c268a7ef"
+ integrity sha512-R+yGLJjLN1won2JlZPZmdlyZGLZwwsW8V/RYu3mTcRq8Aqd9GC2fo4Zi892bFteM5LolfbpxK8Y9QQcAhbBwSQ==
+ dependencies:
+ "@rollup/pluginutils" "^3.0.4"
+ mini-svg-data-uri "^1.1.3"
+
"@rollup/plugin-json@^4.0.2":
version "4.1.0"
resolved "https://registry.yarnpkg.com/@rollup/plugin-json/-/plugin-json-4.1.0.tgz#54e09867ae6963c593844d8bd7a9c718294496f3"
@@ -3248,7 +3256,7 @@
is-module "^1.0.0"
resolve "^1.14.2"
-"@rollup/pluginutils@^3.0.8", "@rollup/pluginutils@^3.1.0":
+"@rollup/pluginutils@^3.0.4", "@rollup/pluginutils@^3.0.8", "@rollup/pluginutils@^3.1.0":
version "3.1.0"
resolved "https://registry.yarnpkg.com/@rollup/pluginutils/-/pluginutils-3.1.0.tgz#706b4524ee6dc8b103b3c995533e5ad680c02b9b"
integrity sha512-GksZ6pr6TpIjHm8h9lSQ8pi8BE9VeubNT0OMJ3B5uZJ8pz73NPiqOtCog/x2/QzM1ENChPKxMDhiQuRHsqc+lg==
@@ -16792,6 +16800,11 @@ mini-css-extract-plugin@^0.8.2:
schema-utils "^1.0.0"
webpack-sources "^1.1.0"
+mini-svg-data-uri@^1.1.3:
+ version "1.2.3"
+ resolved "https://registry.yarnpkg.com/mini-svg-data-uri/-/mini-svg-data-uri-1.2.3.tgz#e16baa92ad55ddaa1c2c135759129f41910bc39f"
+ integrity sha512-zd6KCAyXgmq6FV1mR10oKXYtvmA9vRoB6xPSTUJTbFApCtkefDnYueVR1gkof3KcdLZo1Y8mjF2DFmQMIxsHNQ==
+
minimalistic-assert@^1.0.0, minimalistic-assert@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz#2e194de044626d4a10e7f7fbc00ce73e83e4d5c7"