From d0d04047dd00dc928557cbb6e9927a09e7e1cce9 Mon Sep 17 00:00:00 2001 From: Daniil Suvorov Date: Thu, 18 May 2023 12:25:45 +0300 Subject: [PATCH] concept: new ModalPage --- .../ModalPageNew/ModalPageNew.module.css | 73 +++++++ .../ModalPageNew/ModalPageNew.stories.tsx | 130 ++++++++++++ .../components/ModalPageNew/ModalPageNew.tsx | 185 ++++++++++++++++++ .../src/components/ModalPageNew/Readme.md | 103 ++++++++++ packages/vkui/src/index.ts | 3 + styleguide/config.js | 6 + 6 files changed, 500 insertions(+) create mode 100644 packages/vkui/src/components/ModalPageNew/ModalPageNew.module.css create mode 100644 packages/vkui/src/components/ModalPageNew/ModalPageNew.stories.tsx create mode 100644 packages/vkui/src/components/ModalPageNew/ModalPageNew.tsx create mode 100644 packages/vkui/src/components/ModalPageNew/Readme.md diff --git a/packages/vkui/src/components/ModalPageNew/ModalPageNew.module.css b/packages/vkui/src/components/ModalPageNew/ModalPageNew.module.css new file mode 100644 index 0000000000..5c9747b39c --- /dev/null +++ b/packages/vkui/src/components/ModalPageNew/ModalPageNew.module.css @@ -0,0 +1,73 @@ +.ModalPageNew__container { + top: 0; + right: 0; + bottom: 0; + left: 0; + position: fixed; + overflow-x: hidden; + overflow-y: auto; + z-index: var(--vkui--z_index_modal); + -webkit-overflow-scrolling: touch; + + /** + * Для удаление скролла в Firefox. + * В версии ниже 64 будет виден скролл, но это не ломает функциональность. + */ + scrollbar-width: none; + + /** + * В старых браузерах не работает, но это не ломает функциональность. + */ + scroll-snap-type: y mandatory; +} + +/* stylelint-disable-next-line @project-tools/stylelint-atomic */ +.ModalPageNew__container > * { + scroll-snap-align: start; +} + +.ModalPageNew__container::-webkit-scrollbar { + display: none; +} + +.ModalPageNew__contentIn { + background: var(--vkui--color_background_modal); + border-radius: var(--vkui--size_border_radius_paper--regular) + var(--vkui--size_border_radius_paper--regular) 0 0; + margin-left: auto; + margin-right: auto; + max-width: var(--vkui--size_popup_small--regular); +} + +.ModalPageNew__mask { + z-index: var(--vkui--z_index_modal); + position: fixed; + background: var(--vkui--color_overlay_primary); + top: 0; + right: 0; + bottom: 0; + left: 0; + opacity: 0; +} + +/** + * В старых браузерах sticky не работает, но это не ломает функциональность. + */ +.ModalPageNew__header { + z-index: 1; + position: sticky; + top: 0; + border-radius: inherit; + background: var(--vkui--color_background_modal); +} + +.ModalPageNew__headerFixed { + border-radius: 0; +} + +.ModalPageNew__footer { + z-index: 2; + position: sticky; + bottom: 0; + background: var(--vkui--color_background_modal); +} diff --git a/packages/vkui/src/components/ModalPageNew/ModalPageNew.stories.tsx b/packages/vkui/src/components/ModalPageNew/ModalPageNew.stories.tsx new file mode 100644 index 0000000000..f72e197ae0 --- /dev/null +++ b/packages/vkui/src/components/ModalPageNew/ModalPageNew.stories.tsx @@ -0,0 +1,130 @@ +import React from 'react'; +import { Meta, StoryObj } from '@storybook/react'; +import { withSinglePanel, withVKUILayout } from '../../storybook/VKUIDecorators'; +import { CanvasFullLayout, DisableCartesianParam } from '../../storybook/constants'; +import { Avatar } from '../Avatar/Avatar'; +import { Button } from '../Button/Button'; +import { Card } from '../Card/Card'; +import { CardScroll } from '../CardScroll/CardScroll'; +import { Div } from '../Div/Div'; +import { FormItem } from '../FormItem/FormItem'; +import { Group } from '../Group/Group'; +import { Header } from '../Header/Header'; +import { HorizontalCell } from '../HorizontalCell/HorizontalCell'; +import { HorizontalScroll } from '../HorizontalScroll/HorizontalScroll'; +import { Input } from '../Input/Input'; +import { ModalPageHeader } from '../ModalPageHeader/ModalPageHeader'; +import { Panel } from '../Panel/Panel'; +import { PanelHeader } from '../PanelHeader/PanelHeader'; +import { SimpleCell } from '../SimpleCell/SimpleCell'; +import { Textarea } from '../Textarea/Textarea'; +import { ModalPageNew, ModalPageNewProps } from './ModalPageNew'; + +const story: Meta = { + title: 'Modals/ModalPageNew', + component: ModalPageNew, + parameters: { ...CanvasFullLayout, ...DisableCartesianParam }, + decorators: [withSinglePanel, withVKUILayout], +}; + +export default story; + +type Story = StoryObj; + +export const Example: Story = { + render: function Render() { + const [modal, setModal] = React.useState(true); + + const openModal = () => setModal(true); + const closeModal = () => setModal(false); + + return ( + + ANKI + + + + + + open modal + + + + {Array(50) + .fill(undefined) + .map((_, i) => ( + + SimpleCell + + ))} + + + {modal && ( + Заголовок} + footer={ +
+ +
+ } + onClosed={closeModal} + > + +
https://github.com/VKCOM/VKUI/issues/335
+ +
+ {Array(50) + .fill(undefined) + .map((_, i) => ( + + + + ))} +
+
+
+ + +
https://github.com/VKCOM/VKUI/issues/338
+
https://github.com/VKCOM/VKUI/issues/599
+ + + +
+ + +
https://github.com/VKCOM/VKUI/issues/1071
+ +