-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
split footer into smaller components and various cleanups + swizzle c…
…onfig
- Loading branch information
Showing
11 changed files
with
307 additions
and
151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
packages/docusaurus-theme-classic/src/theme/Footer/Copyright/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import React from 'react'; | ||
import type {Props} from '@theme/Footer/Copyright'; | ||
|
||
export default function Logo({copyright}: Props): JSX.Element { | ||
return ( | ||
<div | ||
className="footer__copyright" | ||
// Developer provided the HTML, so assume it's safe. | ||
// eslint-disable-next-line react/no-danger | ||
dangerouslySetInnerHTML={{ | ||
__html: copyright, | ||
}} | ||
/> | ||
); | ||
} |
38 changes: 38 additions & 0 deletions
38
packages/docusaurus-theme-classic/src/theme/Footer/LinkItem/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import React from 'react'; | ||
|
||
import Link from '@docusaurus/Link'; | ||
import useBaseUrl from '@docusaurus/useBaseUrl'; | ||
import isInternalUrl from '@docusaurus/isInternalUrl'; | ||
import IconExternalLink from '@theme/IconExternalLink'; | ||
import type {Props} from '@theme/Footer/LinkItem'; | ||
|
||
export default function LinkItem({item}: Props): JSX.Element { | ||
const {to, href, label, prependBaseUrlToHref, ...props} = item; | ||
const toUrl = useBaseUrl(to); | ||
const normalizedHref = useBaseUrl(href, {forcePrependBaseUrl: true}); | ||
|
||
return ( | ||
<Link | ||
className="footer__link-item" | ||
{...(href | ||
? { | ||
href: prependBaseUrlToHref ? normalizedHref : href, | ||
} | ||
: { | ||
to: toUrl, | ||
})} | ||
{...props}> | ||
<span> | ||
{label} | ||
{href && !isInternalUrl(href) && <IconExternalLink />} | ||
</span> | ||
</Link> | ||
); | ||
} |
45 changes: 45 additions & 0 deletions
45
packages/docusaurus-theme-classic/src/theme/Footer/Logo/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import React from 'react'; | ||
|
||
import Link from '@docusaurus/Link'; | ||
import {useBaseUrlUtils} from '@docusaurus/useBaseUrl'; | ||
import styles from './styles.module.css'; | ||
import ThemedImage from '@theme/ThemedImage'; | ||
import type {Props} from '@theme/Footer/Logo'; | ||
|
||
function LogoImage({logo}: Props) { | ||
const {withBaseUrl} = useBaseUrlUtils(); | ||
const sources = { | ||
light: withBaseUrl(logo.src), | ||
dark: withBaseUrl(logo.srcDark ?? logo.src), | ||
}; | ||
return ( | ||
<ThemedImage | ||
className="footer__logo" | ||
alt={logo.alt} | ||
sources={sources} | ||
width={logo.width} | ||
height={logo.height} | ||
/> | ||
); | ||
} | ||
|
||
export default function Logo({logo}: Props): JSX.Element { | ||
return ( | ||
<div className="margin-bottom--sm"> | ||
{logo.href ? ( | ||
<Link href={logo.href} className={styles.footerLogoLink}> | ||
<LogoImage logo={logo} /> | ||
</Link> | ||
) : ( | ||
<LogoImage logo={logo} /> | ||
)} | ||
</div> | ||
); | ||
} |
File renamed without changes.
53 changes: 53 additions & 0 deletions
53
packages/docusaurus-theme-classic/src/theme/Footer/MultiColumn/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import React from 'react'; | ||
import type {Props} from '@theme/Footer/MultiColumn'; | ||
import LinkItem from '@theme/Footer/LinkItem'; | ||
|
||
type ColumnType = Props['columns'][number]; | ||
type ColumnItemType = ColumnType['items'][number]; | ||
|
||
function ColumnLinkItem({item}: {item: ColumnItemType}) { | ||
return item.html ? ( | ||
<li | ||
className="footer__item" | ||
// Developer provided the HTML, so assume it's safe. | ||
// eslint-disable-next-line react/no-danger | ||
dangerouslySetInnerHTML={{ | ||
__html: item.html, | ||
}} | ||
/> | ||
) : ( | ||
<li key={item.href || item.to} className="footer__item"> | ||
<LinkItem item={item} /> | ||
</li> | ||
); | ||
} | ||
|
||
function Column({column}: {column: ColumnType}) { | ||
return ( | ||
<div className="col footer__col"> | ||
<div className="footer__title">{column.title}</div> | ||
<ul className="footer__items"> | ||
{column.items.map((item, i) => ( | ||
<ColumnLinkItem key={i} item={item} /> | ||
))} | ||
</ul> | ||
</div> | ||
); | ||
} | ||
|
||
export default function MultiColumn({columns}: Props): JSX.Element { | ||
return ( | ||
<div className="row footer__links"> | ||
{columns.map((column, i) => ( | ||
<Column key={i} column={column} /> | ||
))} | ||
</div> | ||
); | ||
} |
44 changes: 44 additions & 0 deletions
44
packages/docusaurus-theme-classic/src/theme/Footer/Simple/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import React from 'react'; | ||
import type {Props} from '@theme/Footer/Simple'; | ||
import LinkItem from '@theme/Footer/LinkItem'; | ||
|
||
function Separator() { | ||
return <span className="footer__link-separator">·</span>; | ||
} | ||
|
||
function SimpleLinkItem({item}: {item: Props['links'][number]}) { | ||
return item.html ? ( | ||
<span | ||
className="footer__link-item" | ||
// Developer provided the HTML, so assume it's safe. | ||
// eslint-disable-next-line react/no-danger | ||
dangerouslySetInnerHTML={{ | ||
__html: item.html, | ||
}} | ||
/> | ||
) : ( | ||
<LinkItem item={item} /> | ||
); | ||
} | ||
|
||
export default function Simple({links}: Props): JSX.Element { | ||
return ( | ||
<div className="footer__links text--center"> | ||
<div className="footer__links"> | ||
{links.map((item, i) => ( | ||
<React.Fragment key={i}> | ||
<SimpleLinkItem item={item} /> | ||
{links.length !== i + 1 && <Separator />} | ||
</React.Fragment> | ||
))} | ||
</div> | ||
</div> | ||
); | ||
} |
Oops, something went wrong.