-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(MobileHeader): add OverlapPanel (#309)
- Loading branch information
Showing
17 changed files
with
401 additions
and
4 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
70 changes: 70 additions & 0 deletions
70
src/components/MobileHeader/OverlapPanel/OverlapPanel.scss
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,70 @@ | ||
@use '../../variables'; | ||
|
||
$block: '.#{variables.$ns}mobile-overlap-panel'; | ||
|
||
#{$block} { | ||
$action-width: 40px; | ||
|
||
position: fixed; | ||
inset: 0; | ||
|
||
&__drawer-item { | ||
width: 100%; | ||
max-width: 100%; | ||
flex-direction: column; | ||
height: 100%; | ||
display: flex; | ||
|
||
box-sizing: border-box; | ||
max-height: 100%; | ||
} | ||
|
||
&_action { | ||
#{$block}__title { | ||
padding-right: 0; | ||
} | ||
} | ||
|
||
&__close { | ||
margin-right: var(--g-spacing-1); | ||
} | ||
|
||
&__action { | ||
margin-left: var(--g-spacing-1); | ||
} | ||
|
||
&__close.g-button:hover::before, | ||
&__action.g-button:hover::before { | ||
background-color: transparent; | ||
} | ||
|
||
&__title { | ||
display: inline-block; | ||
flex: 1; | ||
justify-content: center; | ||
|
||
padding-right: #{$action-width}; | ||
|
||
text-align: center; | ||
margin: 0; | ||
} | ||
|
||
&__content { | ||
display: flex; | ||
overflow-y: auto; | ||
flex-direction: column; | ||
|
||
box-sizing: border-box; | ||
height: 100%; | ||
padding: 0px var(--g-spacing-5); | ||
} | ||
|
||
&__header { | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
|
||
margin-bottom: var(--g-spacing-3); | ||
padding: var(--g-spacing-1) var(--g-spacing-3); | ||
} | ||
} |
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,98 @@ | ||
import React from 'react'; | ||
|
||
import {ArrowLeft as CloseIcon} from '@gravity-ui/icons'; | ||
import {Button, Icon, IconProps, Text} from '@gravity-ui/uikit'; | ||
|
||
import {Drawer, DrawerItem} from '../../Drawer/Drawer'; | ||
import {block} from '../../utils/cn'; | ||
import {MOBILE_HEADER_ICON_SIZE} from '../constants'; | ||
import i18n from '../i18n'; | ||
|
||
import './OverlapPanel.scss'; | ||
|
||
const b = block('mobile-overlap-panel'); | ||
|
||
interface OverlapPanelActionProps { | ||
icon: IconProps['data']; | ||
className?: string; | ||
onClick: (event: React.MouseEvent<HTMLElement, MouseEvent>) => void; | ||
title: string; | ||
} | ||
|
||
export interface OverlapPanelProps { | ||
className?: string; | ||
title?: string; | ||
onClose: () => void; | ||
action?: OverlapPanelActionProps; | ||
renderContent: () => React.ReactNode; | ||
closeTitle?: string; | ||
visible: boolean; | ||
topOffset?: number | string; | ||
} | ||
|
||
export const OverlapPanel = ({ | ||
title, | ||
renderContent, | ||
className, | ||
onClose, | ||
action, | ||
closeTitle = i18n('overlap_button_close'), | ||
visible, | ||
topOffset, | ||
}: OverlapPanelProps) => { | ||
return ( | ||
<Drawer | ||
className={b('', {action: Boolean(action)}, className)} | ||
onVeilClick={onClose} | ||
onEscape={onClose} | ||
preventScrollBody | ||
style={{ | ||
top: topOffset, | ||
}} | ||
> | ||
<DrawerItem id="overlap" visible={visible} className={b('drawer-item')}> | ||
<div className={b('header')}> | ||
<Button | ||
size="l" | ||
view="flat" | ||
className={b('close')} | ||
onClick={onClose} | ||
extraProps={{ | ||
'aria-label': closeTitle, | ||
}} | ||
> | ||
<Icon | ||
className={b('icon')} | ||
data={CloseIcon} | ||
size={MOBILE_HEADER_ICON_SIZE} | ||
/> | ||
</Button> | ||
<Text | ||
whiteSpace="nowrap" | ||
ellipsis | ||
variant={'subheader-2'} | ||
className={b('title')} | ||
as={title ? ('h2' as const) : undefined} | ||
> | ||
{title} | ||
</Text> | ||
{action && ( | ||
<Button | ||
size="l" | ||
type="button" | ||
view="flat" | ||
onClick={action.onClick} | ||
className={b('action')} | ||
extraProps={{ | ||
'aria-label': action.title, | ||
}} | ||
> | ||
<Icon data={action.icon} size={MOBILE_HEADER_ICON_SIZE} /> | ||
</Button> | ||
)} | ||
</div> | ||
<div className={b('content')}>{renderContent()}</div> | ||
</DrawerItem> | ||
</Drawer> | ||
); | ||
}; |
Binary file added
BIN
+78.9 KB
...l.test.tsx-snapshots/OverlapPanel-render-story-Showcase-dark-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+77.4 KB
...ual.test.tsx-snapshots/OverlapPanel-render-story-Showcase-dark-webkit-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+77.4 KB
....test.tsx-snapshots/OverlapPanel-render-story-Showcase-light-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+75.4 KB
...al.test.tsx-snapshots/OverlapPanel-render-story-Showcase-light-webkit-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions
20
src/components/MobileHeader/OverlapPanel/__stories__/OverlapPanel.scss
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,20 @@ | ||
.overlap-panel-showcase { | ||
display: flex; | ||
flex-direction: column; | ||
position: relative; | ||
box-sizing: border-box; | ||
width: 100dvw; | ||
height: 100dvh; | ||
|
||
*, | ||
*::before, | ||
*::after { | ||
box-sizing: border-box; | ||
} | ||
|
||
&__header { | ||
width: 100%; | ||
padding: 20px; | ||
border-bottom: 1px solid var(--g-color-line-generic); | ||
} | ||
} |
Oops, something went wrong.