Skip to content

Commit

Permalink
feat(ModalCard): add dismissButtonMode
Browse files Browse the repository at this point in the history
  • Loading branch information
BlackySoul committed Nov 1, 2023
1 parent 3a844db commit a4ed0af
Show file tree
Hide file tree
Showing 19 changed files with 207 additions and 136 deletions.
154 changes: 84 additions & 70 deletions packages/vkui/src/components/ModalCard/ModalCard.e2e-playground.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,78 +20,92 @@ const AppWrapper = ({ children, ...restProps }: AppWrapperProps) => (
</AppDefaultWrapper>
);

const propSets = [
{
nav: ['1'],
icon: [<Icon56MoneyTransferOutline key="icon" />],
header: ['Отправляйте деньги друзьям, используя банковскую карту'],
subheader: ['Номер карты получателя не нужен — он сам решит, куда зачислить средства.'],
actions: [
<Button size="l" mode="primary" stretched key="button">
Попробовать
</Button>,
],
},
{
nav: ['2'],
icon: [<Image key="image" size={72} borderRadius="l" />],
header: ['Добавить игру «Загадки детства» в меню?'],
subheader: ['Игра появится под списком разделов на экране меню и будет всегда под рукой.'],
actions: [
<ButtonGroup mode="vertical" gap="m" stretched key="buttons">
<Button size="l" mode="primary" stretched>
Присоединиться
</Button>
<Button size="l" mode="secondary" stretched>
Скопировать приглашение
</Button>
</ButtonGroup>,
],
children: [
<UsersStack
photos={['', '', '', '']}
size="l"
visibleCount={3}
key="usersstack"
layout="vertical"
>
Алексей, Илья, Михаил
<br />и ещё 3 человека
</UsersStack>,
],
},
{
nav: ['3'],
header: ['Расскажите о себе'],
actions: [
<Button size="l" mode="primary" stretched key="button">
Сохранить
</Button>,
],
children: [<Textarea key="textarea" defaultValue="В Грузии" />],
},
{
nav: ['4'],
header: ['Гиппопотомомонстросесквиппедалиофобия'],
subheader: [
'Гиппопотомомонстросесквиппедалиофобия — боязнь длинных слов, таких как метоксихлордиэтиламинометилбутиламиноакридин',
],
actions: [
<ButtonGroup mode="horizontal" gap="s" stretched key="buttons">
<Button size="l" mode="primary" stretched>
Гиппопотомомонстросесквиппедалиофобия
</Button>
<Button size="l" mode="primary" stretched>
Метоксихлордиэтиламинометилбутиламиноакридин
</Button>
</ButtonGroup>,
],
},
];

export const ModalCardPlayground = (props: ComponentPlaygroundProps) => {
return (
<ComponentPlayground {...props} propSets={propSets} AppWrapper={AppWrapper}>
<ComponentPlayground
{...props}
propSets={[
{
nav: ['1'],
icon: [<Icon56MoneyTransferOutline key="icon" />],
header: ['Отправляйте деньги друзьям, используя банковскую карту'],
subheader: ['Номер карты получателя не нужен — он сам решит, куда зачислить средства.'],
actions: [
<Button size="l" mode="primary" stretched key="button">
Попробовать
</Button>,
],
},
{
nav: ['2'],
icon: [<Image key="image" size={72} borderRadius="l" />],
header: ['Добавить игру «Загадки детства» в меню?'],
subheader: [
'Игра появится под списком разделов на экране меню и будет всегда под рукой.',
],
actions: [
<ButtonGroup mode="vertical" gap="m" stretched key="buttons">
<Button size="l" mode="primary" stretched>
Присоединиться
</Button>
<Button size="l" mode="secondary" stretched>
Скопировать приглашение
</Button>
</ButtonGroup>,
],
children: [
<UsersStack
photos={['', '', '', '']}
size="l"
visibleCount={3}
key="usersstack"
layout="vertical"
>
Алексей, Илья, Михаил
<br />и ещё 3 человека
</UsersStack>,
],
},
{
nav: ['3'],
header: ['Расскажите о себе'],
actions: [
<Button size="l" mode="primary" stretched key="button">
Сохранить
</Button>,
],
children: [<Textarea key="textarea" defaultValue="В Грузии" />],
},
{
nav: ['4'],
header: ['Гиппопотомомонстросесквиппедалиофобия'],
subheader: [
'Гиппопотомомонстросесквиппедалиофобия — боязнь длинных слов, таких как метоксихлордиэтиламинометилбутиламиноакридин',
],
actions: [
<ButtonGroup mode="horizontal" gap="s" stretched key="buttons">
<Button size="l" mode="primary" stretched>
Гиппопотомомонстросесквиппедалиофобия
</Button>
<Button size="l" mode="primary" stretched>
Метоксихлордиэтиламинометилбутиламиноакридин
</Button>
</ButtonGroup>,
],
},
{
nav: ['4'],
header: ['Расскажите о себе'],
actions: [
<Button size="l" mode="primary" stretched key="button">
Сохранить
</Button>,
],
dismissButtonMode: ['inside', 'outside'],
},
]}
AppWrapper={AppWrapper}
>
{(props: ModalCardProps) => (
<div style={{ height: 500, transform: 'translateZ(0)' }}>
<ModalRoot activeModal={props.nav}>
Expand Down
4 changes: 4 additions & 0 deletions packages/vkui/src/components/ModalCard/ModalCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ export const ModalCard = ({
id,
size,
modalDismissButtonTestId,
dismissButtonMode,
dismissLabel,
...restProps
}: ModalCardProps) => {
const { isDesktop } = useAdaptivityWithJSMediaQueries();
Expand Down Expand Up @@ -64,6 +66,8 @@ export const ModalCard = ({
onClose={onClose || modalContext.onClose}
size={size}
modalDismissButtonTestId={modalDismissButtonTestId}
dismissButtonMode={dismissButtonMode}
dismissLabel={dismissLabel}
>
{children}
</ModalCardBase>
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 29 additions & 21 deletions packages/vkui/src/components/ModalCardBase/ModalCardBase.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@
box-shadow: var(--vkui--elevation3);

--vkui_internal--background: var(--vkui--color_background_modal);
--vkui_internal--dismiss_icon_height: 20px;
--vkui_internal--dismiss_icon_padding: 12px;
--vkui_internal--dismiss_icon_safe_offset: 8px;
--vkui_internal--dismiss_icon_desktop_offset: 4px;
}

.ModalCardBase--withSafeZone .ModalCardBase__container {
padding-top: calc(
var(--vkui_internal--dismiss_icon_height) + var(--vkui_internal--dismiss_icon_padding) +
var(--vkui_internal--dismiss_icon_safe_offset)
);
}

.ModalCardBase__container--softwareKeyboardOpened {
Expand Down Expand Up @@ -57,43 +68,40 @@
margin-top: 32px;
}

/**
* iOS
*/

.ModalCardBase__dismiss {
position: absolute;
top: 4px;
right: 4px;
width: 48px;
height: 48px;
top: 0;
right: 0;
color: var(--vkui--color_icon_secondary);
justify-content: center;
padding: var(--vkui_internal--dismiss_icon_padding);
}

/**
* iOS
*/
/*
* TODO [>=6]: зачем этот стиль? Удалить?
*/
.ModalCardBase--ios .ModalCardBase__header:first-child {
padding-left: 36px;
padding-right: 36px;
}

/**
* Android + vkcom
*/

.ModalCardBase--ios .ModalCardBase__container {
border-radius: 14px;

--vkui_internal--dismiss_icon_height: 24px;
--vkui_internal--dismiss_icon_padding: 10px;
}

/**
* Desktop
*/
.ModalCardBase--desktop .ModalCardBase__dismiss {
top: var(--vkui_internal--dismiss_icon_desktop_offset);
right: var(--vkui_internal--dismiss_icon_desktop_offset);
}

.ModalCardBase--desktop .ModalCardBase__container {
padding: 24px;
}

.ModalCardBase--withSafeZone.ModalCardBase--desktop .ModalCardBase__container {
padding-top: calc(
var(--vkui_internal--dismiss_icon_height) + var(--vkui_internal--dismiss_icon_padding) +
var(--vkui_internal--dismiss_icon_safe_offset) +
var(--vkui_internal--dismiss_icon_desktop_offset)
);
}
Loading

0 comments on commit a4ed0af

Please sign in to comment.