diff options
| author | Armand Philippot <git@armandphilippot.com> | 2023-09-27 18:43:25 +0200 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2023-10-24 12:25:00 +0200 |
| commit | d17d894f398650209c0ddd29502308de8c07bd93 (patch) | |
| tree | 858402dfd362e74686d25fec155f247ad3217635 /src/components/organisms/layout/site-footer.tsx | |
| parent | 7255d25f6834a208c0ed44636356cc260f6ab6ba (diff) | |
feat(components): add Article, Aside, Footer, Header, Main & Nav
Some components have been renamed to be able to create Footer, Header
and Nav.
Diffstat (limited to 'src/components/organisms/layout/site-footer.tsx')
| -rw-r--r-- | src/components/organisms/layout/site-footer.tsx | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/src/components/organisms/layout/site-footer.tsx b/src/components/organisms/layout/site-footer.tsx new file mode 100644 index 0000000..c1fe9d0 --- /dev/null +++ b/src/components/organisms/layout/site-footer.tsx @@ -0,0 +1,75 @@ +import type { FC } from 'react'; +import { useIntl } from 'react-intl'; +import { Copyright, Footer, type CopyrightProps } from '../../atoms'; +import { + BackToTop, + type BackToTopProps, + NavList, + type NavItem, +} from '../../molecules'; +import styles from './site-footer.module.scss'; + +export type SiteFooterProps = { + /** + * Set additional classnames to the back to top button. + */ + backToTopClassName?: BackToTopProps['className']; + /** + * Set additional classnames to the footer element. + */ + className?: string; + /** + * Set the copyright information. + */ + copyright: CopyrightProps; + /** + * The footer nav items. + */ + navItems?: NavItem[]; + /** + * An element id (without hashtag) used as anchor for back to top button. + */ + topId: string; +}; + +/** + * SiteFooter component + * + * Renders a footer with copyright and nav; + */ +export const SiteFooter: FC<SiteFooterProps> = ({ + backToTopClassName, + className = '', + copyright, + navItems, + topId, +}) => { + const intl = useIntl(); + const ariaLabel = intl.formatMessage({ + defaultMessage: 'Footer', + description: 'SiteFooter: an accessible name for the footer nav', + id: 'pRzkFR', + }); + const footerClass = `${styles.wrapper} ${className}`; + const btnClass = `${styles['back-to-top']} ${backToTopClassName}`; + + return ( + <Footer className={footerClass}> + <Copyright + dates={copyright.dates} + icon={copyright.icon} + owner={copyright.owner} + /> + {navItems ? ( + <NavList + aria-label={ariaLabel} + className={styles.nav} + items={navItems} + // eslint-disable-next-line react/jsx-no-literals -- Kind allowed + kind="footer" + /> + ) : null} + <BackToTop className={btnClass} to={topId} /> + </Footer> + ); +}; |
