From 773d039f2472136f582c42923351454fb35e9b86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D1=81=D0=B5=D0=BD=D0=B8=D1=8F?= <31247233+kseniya57@users.noreply.github.com> Date: Tue, 12 Mar 2024 18:35:51 +0300 Subject: [PATCH] feat(Footer): add footer components (#207) Co-authored-by: kseniyakuzina --- README.md | 2 + src/components/Footer/MenuItem/MenuItem.scss | 29 +++++ src/components/Footer/MenuItem/MenuItem.tsx | 21 ++++ src/components/Footer/README.md | 113 ++++++++++++++++++ src/components/Footer/desktop/Footer.scss | 66 ++++++++++ src/components/Footer/desktop/Footer.tsx | 94 +++++++++++++++ .../desktop/__stories__/Footer.stories.tsx | 39 ++++++ .../desktop/__stories__/FooterShowcase.scss | 28 +++++ .../desktop/__stories__/FooterShowcase.tsx | 18 +++ .../Footer/desktop/__stories__/moc.ts | 38 ++++++ .../desktop/constants/moreItemsPopupProps.ts | 5 + src/components/Footer/desktop/index.ts | 1 + src/components/Footer/index.ts | 3 + src/components/Footer/mobile/Footer.scss | 73 +++++++++++ src/components/Footer/mobile/Footer.tsx | 95 +++++++++++++++ .../__stories__/MobileFooter.stories.tsx | 41 +++++++ .../__stories__/MobileFooterShowcase.scss | 28 +++++ .../__stories__/MobileFooterShowcase.tsx | 18 +++ .../Footer/mobile/__stories__/moc.ts | 38 ++++++ src/components/Footer/mobile/index.ts | 1 + src/components/Footer/types.ts | 20 ++++ src/components/index.ts | 1 + .../README.md | 12 ++ .../index.ts | 1 + .../useOverflowingHorizontalListItems.ts | 88 ++++++++++++++ 25 files changed, 873 insertions(+) create mode 100644 src/components/Footer/MenuItem/MenuItem.scss create mode 100644 src/components/Footer/MenuItem/MenuItem.tsx create mode 100644 src/components/Footer/README.md create mode 100644 src/components/Footer/desktop/Footer.scss create mode 100644 src/components/Footer/desktop/Footer.tsx create mode 100644 src/components/Footer/desktop/__stories__/Footer.stories.tsx create mode 100644 src/components/Footer/desktop/__stories__/FooterShowcase.scss create mode 100644 src/components/Footer/desktop/__stories__/FooterShowcase.tsx create mode 100644 src/components/Footer/desktop/__stories__/moc.ts create mode 100644 src/components/Footer/desktop/constants/moreItemsPopupProps.ts create mode 100644 src/components/Footer/desktop/index.ts create mode 100644 src/components/Footer/index.ts create mode 100644 src/components/Footer/mobile/Footer.scss create mode 100644 src/components/Footer/mobile/Footer.tsx create mode 100644 src/components/Footer/mobile/__stories__/MobileFooter.stories.tsx create mode 100644 src/components/Footer/mobile/__stories__/MobileFooterShowcase.scss create mode 100644 src/components/Footer/mobile/__stories__/MobileFooterShowcase.tsx create mode 100644 src/components/Footer/mobile/__stories__/moc.ts create mode 100644 src/components/Footer/mobile/index.ts create mode 100644 src/components/Footer/types.ts create mode 100644 src/hooks/useOverflowingHorizontalListItems/README.md create mode 100644 src/hooks/useOverflowingHorizontalListItems/index.ts create mode 100644 src/hooks/useOverflowingHorizontalListItems/useOverflowingHorizontalListItems.ts diff --git a/README.md b/README.md index 9e457ed..d0d7f91 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,8 @@ npm install --dev @gravity-ui/uikit@^3.0.2 @bem-react/classname@1.6.0 react@^16. - AsideFallback - Logo - MobileLogo +- Footer +- MobileFooter ## Optimization diff --git a/src/components/Footer/MenuItem/MenuItem.scss b/src/components/Footer/MenuItem/MenuItem.scss new file mode 100644 index 0000000..6837488 --- /dev/null +++ b/src/components/Footer/MenuItem/MenuItem.scss @@ -0,0 +1,29 @@ +@use '../../variables'; + +@import '../../../../styles/mixins'; + +$block: '.#{variables.$ns}footer-menu-item'; + +#{$block} { + display: flex; + align-items: center; + justify-content: center; + align-self: stretch; + + height: 100%; + + .g-menu__item-content { + @include overflow-ellipsis(ellipsis); + + @include text-body-1; + color: var(--g-color-text-secondary); + } + + &[class]:hover { + background-color: inherit; + + &[href] .g-menu__item-content { + color: var(--g-color-text-link-hover); + } + } +} diff --git a/src/components/Footer/MenuItem/MenuItem.tsx b/src/components/Footer/MenuItem/MenuItem.tsx new file mode 100644 index 0000000..a163e61 --- /dev/null +++ b/src/components/Footer/MenuItem/MenuItem.tsx @@ -0,0 +1,21 @@ +import React from 'react'; +import type {FC} from 'react'; + +import {Menu} from '@gravity-ui/uikit'; + +import {block} from '../../utils/cn'; +import {FooterMenuItem} from '../types'; + +import './MenuItem.scss'; + +const b = block('footer-menu-item'); + +export type MenuItemProps = FooterMenuItem; + +export const MenuItem: FC = ({text, className, ...menuItemProps}) => { + return ( + + {text} + + ); +}; diff --git a/src/components/Footer/README.md b/src/components/Footer/README.md new file mode 100644 index 0000000..e718ad3 --- /dev/null +++ b/src/components/Footer/README.md @@ -0,0 +1,113 @@ +## Footer and MobileFooter + +The page footer components. Use `Footer` for the desktop version and `MobileFooter` for the mobile version. +Both components have the same properties. + +### PropTypes + +| Property | Type | Required | Default | Description | +| :--------------------------------------------------------------------------------------- | :------------------ | :------: | :------ | :---------------------------- | +| className | `String` | | | Footer class name | +| [menuItems](https://github.com/gravity-ui/uikit/tree/main/src/components/Menu) | `FooterMenuItem[]` | | | List of footer menu items | +| withDivider | `Boolean` | | | Show top border on the footer | +| moreButtonTitle | `String` | | | The more items button title | +| [view](#view) | `normal` or `clear` | | | The footer view | +| [logo](https://preview.gravity-ui.com/navigation/?path=/story/components-logo--showcase) | `LogoProps` | | | The service logo properties | +| logoWrapperClassName | `string` | | | The logo wrapper class name | +| copyright | `string` | | | The copyright | + +### view + +- normal - white background and all the configured elements +- clear - transparent background and only the copyright + +### Usage + +See demos + +- Desktop: `src/components/Footer/desktop/__stories__/FooterShowcase.tsx`, +- Mobile: `src/components/Footer/mobile/__stories__/MobileFooterShowcase.tsx`. + +### Examples + +#### Footer + +```tsx +import { Footer } from '@gravity-ui/navigation'; + +