mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-18 11:36:53 +02:00
feat(v2): themed logo in footer (#3993)
* feat: attempt 1 at themedlogo in footer * Add srcDark to website for temp debug * typo fix * Got it now! except for centering * style: centered new themed image logo * style: change ThemedImage styleing to center footer logo * style: Change ThemeImage Style to initial This was my mistake. Removed temp `srcDark` footer logo
This commit is contained in:
parent
8a9dfcf96c
commit
5dfa665281
4 changed files with 14 additions and 8 deletions
|
@ -12,6 +12,7 @@ import Link from '@docusaurus/Link';
|
||||||
import {useThemeConfig} from '@docusaurus/theme-common';
|
import {useThemeConfig} from '@docusaurus/theme-common';
|
||||||
import useBaseUrl from '@docusaurus/useBaseUrl';
|
import useBaseUrl from '@docusaurus/useBaseUrl';
|
||||||
import styles from './styles.module.css';
|
import styles from './styles.module.css';
|
||||||
|
import ThemedImage from '@theme/ThemedImage';
|
||||||
|
|
||||||
function FooterLink({to, href, label, prependBaseUrlToHref, ...props}: any) {
|
function FooterLink({to, href, label, prependBaseUrlToHref, ...props}: any) {
|
||||||
const toUrl = useBaseUrl(to);
|
const toUrl = useBaseUrl(to);
|
||||||
|
@ -35,15 +36,18 @@ function FooterLink({to, href, label, prependBaseUrlToHref, ...props}: any) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const FooterLogo = ({url, alt}) => (
|
const FooterLogo = ({sources, alt}) => (
|
||||||
<img className="footer__logo" alt={alt} src={url} />
|
<ThemedImage className="footer__logo" alt={alt} sources={sources} />
|
||||||
);
|
);
|
||||||
|
|
||||||
function Footer(): JSX.Element | null {
|
function Footer(): JSX.Element | null {
|
||||||
const {footer} = useThemeConfig();
|
const {footer} = useThemeConfig();
|
||||||
|
|
||||||
const {copyright, links = [], logo = {}} = footer || {};
|
const {copyright, links = [], logo = {}} = footer || {};
|
||||||
const logoUrl = useBaseUrl(logo.src);
|
const sources = {
|
||||||
|
light: useBaseUrl(logo.src),
|
||||||
|
dark: useBaseUrl(logo.srcDark || logo.src),
|
||||||
|
};
|
||||||
|
|
||||||
if (!footer) {
|
if (!footer) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -91,7 +95,7 @@ function Footer(): JSX.Element | null {
|
||||||
)}
|
)}
|
||||||
{(logo || copyright) && (
|
{(logo || copyright) && (
|
||||||
<div className="footer__bottom text--center">
|
<div className="footer__bottom text--center">
|
||||||
{logo && logo.src && (
|
{logo && (logo.src || logo.srcDark) && (
|
||||||
<div className="margin-bottom--sm">
|
<div className="margin-bottom--sm">
|
||||||
{logo.href ? (
|
{logo.href ? (
|
||||||
<a
|
<a
|
||||||
|
@ -99,10 +103,10 @@ function Footer(): JSX.Element | null {
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
className={styles.footerLogoLink}>
|
className={styles.footerLogoLink}>
|
||||||
<FooterLogo alt={logo.alt} url={logoUrl} />
|
<FooterLogo alt={logo.alt} sources={sources} />
|
||||||
</a>
|
</a>
|
||||||
) : (
|
) : (
|
||||||
<FooterLogo alt={logo.alt} url={logoUrl} />
|
<FooterLogo alt={logo.alt} sources={sources} />
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
|
@ -3,9 +3,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
html[data-theme='light'] .themedImage--light {
|
html[data-theme='light'] .themedImage--light {
|
||||||
display: block;
|
display: initial;
|
||||||
}
|
}
|
||||||
|
|
||||||
html[data-theme='dark'] .themedImage--dark {
|
html[data-theme='dark'] .themedImage--dark {
|
||||||
display: block;
|
display: initial;
|
||||||
}
|
}
|
||||||
|
|
|
@ -265,6 +265,7 @@ const ThemeConfigSchema = Joi.object({
|
||||||
logo: Joi.object({
|
logo: Joi.object({
|
||||||
alt: Joi.string().allow(''),
|
alt: Joi.string().allow(''),
|
||||||
src: Joi.string(),
|
src: Joi.string(),
|
||||||
|
srcDark: Joi.string(),
|
||||||
href: Joi.string(),
|
href: Joi.string(),
|
||||||
}),
|
}),
|
||||||
copyright: Joi.string(),
|
copyright: Joi.string(),
|
||||||
|
|
|
@ -46,6 +46,7 @@ export type Footer = {
|
||||||
logo?: {
|
logo?: {
|
||||||
alt?: string;
|
alt?: string;
|
||||||
src?: string;
|
src?: string;
|
||||||
|
srcDark?: string;
|
||||||
href?: string;
|
href?: string;
|
||||||
};
|
};
|
||||||
copyright?: string;
|
copyright?: string;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue