From 9a186b357b32325cf77fdce39a6c6c9aff76d8a5 Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Tue, 17 May 2022 18:31:21 +0200 Subject: chore: listen scroll to hide/show back to top button --- src/components/organisms/layout/footer.stories.tsx | 21 +++++++++++++-------- src/components/organisms/layout/footer.tsx | 21 ++++++++++++++++++--- 2 files changed, 31 insertions(+), 11 deletions(-) (limited to 'src/components/organisms/layout') diff --git a/src/components/organisms/layout/footer.stories.tsx b/src/components/organisms/layout/footer.stories.tsx index 06819da..bd5a744 100644 --- a/src/components/organisms/layout/footer.stories.tsx +++ b/src/components/organisms/layout/footer.stories.tsx @@ -1,5 +1,4 @@ import { ComponentMeta, ComponentStory } from '@storybook/react'; -import { IntlProvider } from 'react-intl'; import FooterComponent from './footer'; /** @@ -9,6 +8,19 @@ export default { title: 'Organisms/Layout', component: FooterComponent, argTypes: { + backToTopClassName: { + control: { + type: 'text', + }, + description: 'Set additional classnames to the back to top button.', + table: { + category: 'Styles', + }, + type: { + name: 'string', + required: false, + }, + }, className: { control: { type: 'text', @@ -53,13 +65,6 @@ export default { }, }, }, - decorators: [ - (Story) => ( - - - - ), - ], } as ComponentMeta; const Template: ComponentStory = (args) => ( diff --git a/src/components/organisms/layout/footer.tsx b/src/components/organisms/layout/footer.tsx index 1426e96..c60afec 100644 --- a/src/components/organisms/layout/footer.tsx +++ b/src/components/organisms/layout/footer.tsx @@ -1,13 +1,19 @@ import Copyright, { type CopyrightProps, } from '@components/atoms/layout/copyright'; -import BackToTop from '@components/molecules/buttons/back-to-top'; +import BackToTop, { + type BackToTopProps, +} from '@components/molecules/buttons/back-to-top'; import Nav, { type NavItem } from '@components/molecules/nav/nav'; import { FC } from 'react'; import { useIntl } from 'react-intl'; import styles from './footer.module.scss'; export type FooterProps = { + /** + * Set additional classnames to the back to top button. + */ + backToTopClassName?: BackToTopProps['className']; /** * Set additional classnames to the footer element. */ @@ -31,7 +37,13 @@ export type FooterProps = { * * Renders a footer with copyright and nav; */ -const Footer: FC = ({ className, copyright, navItems, topId }) => { +const Footer: FC = ({ + backToTopClassName, + className = '', + copyright, + navItems, + topId, +}) => { const intl = useIntl(); const ariaLabel = intl.formatMessage({ defaultMessage: 'Footer', @@ -54,7 +66,10 @@ const Footer: FC = ({ className, copyright, navItems, topId }) => { className={styles.nav} /> )} - + ); }; -- cgit v1.2.3