Skip to content

Commit

Permalink
Merge pull request #2528 from epam/improvement/2469-modal-improve-mob…
Browse files Browse the repository at this point in the history
…ile-view

[Modals]: mobile view improvements
  • Loading branch information
AlekseyManetov authored Oct 2, 2024
2 parents 62993b2 + 01ff4d4 commit 541ff4d
Show file tree
Hide file tree
Showing 13 changed files with 68 additions and 27 deletions.
7 changes: 3 additions & 4 deletions app/src/docs/_examples/modals/Basic.example.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import React from 'react';
import { IModal, useUuiContext } from '@epam/uui-core';
import { demoData } from '@epam/uui-docs';
import {
ModalBlocker, ModalFooter, ModalHeader, ModalWindow, FlexRow, FlexSpacer, Panel, ScrollBars, Text, Button,
SuccessNotification, WarningNotification,
ModalBlocker, ModalFooter, ModalHeader, ModalWindow, FlexRow, Panel, ScrollBars, Text, Button, SuccessNotification, WarningNotification,
} from '@epam/uui';
import css from './styles.module.scss';

export default function BasicModalExampleToggler() {
const { uuiModals, uuiNotifications } = useUuiContext();
Expand Down Expand Up @@ -55,8 +55,7 @@ export function BasicModalExample(modalProps: IModal<string>) {
</Text>
</FlexRow>
</ScrollBars>
<ModalFooter>
<FlexSpacer />
<ModalFooter cx={ css.footer }>
<Button color="secondary" fill="outline" caption="Cancel" onClick={ () => modalProps.abort() } />
<Button color="primary" caption="Ok" onClick={ () => modalProps.success('Success action') } />
</ModalFooter>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React from 'react';
import { IModal, useUuiContext } from '@epam/uui-core';
import { demoData } from '@epam/uui-docs';
import { ModalBlocker, ModalFooter, ModalHeader, ModalWindow, FlexRow, FlexSpacer, Panel, ScrollBars, Text, Button } from '@epam/uui';
import { ModalBlocker, ModalFooter, ModalHeader, ModalWindow, FlexRow, Panel, ScrollBars, Text, Button } from '@epam/uui';
import css from './styles.module.scss';

function ModalWithDisabledClickOutsideAndCross(props: IModal<string>) {
return (
Expand All @@ -18,8 +19,7 @@ function ModalWithDisabledClickOutsideAndCross(props: IModal<string>) {
</Text>
</FlexRow>
</ScrollBars>
<ModalFooter>
<FlexSpacer />
<ModalFooter cx={ css.footer }>
<Button color="secondary" fill="outline" caption="Cancel" onClick={ () => props.abort() } />
<Button color="primary" caption="Ok" onClick={ () => props.success('Success action') } />
</ModalFooter>
Expand Down
4 changes: 2 additions & 2 deletions app/src/docs/_examples/modals/ModalWithForm.example.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { IModal, useUuiContext, useAsyncDataSource, LazyDataSourceApiResponse }
import { Country } from '@epam/uui-docs';
import { ModalBlocker, ModalWindow, FlexSpacer, ModalHeader, FlexRow, LabeledInput, TextInput, Button, ScrollBars, ModalFooter, SuccessNotification, useForm, Text,
Panel, FlexCell, RadioGroup, PickerInput } from '@epam/uui';
import css from './styles.module.scss';

interface Person {
firstName?: string;
Expand Down Expand Up @@ -77,8 +78,7 @@ function ModalWithFormExample(modalProps: IModal<Person>) {
</FlexCell>
</FlexRow>
</Panel>
<ModalFooter borderTop>
<FlexSpacer />
<ModalFooter borderTop cx={ css.footer }>
<Button color="secondary" fill="outline" onClick={ () => close().then(modalProps.abort) } caption="Cancel" />
<Button color="primary" caption="Confirm" onClick={ save } />
</ModalFooter>
Expand Down
9 changes: 9 additions & 0 deletions app/src/docs/_examples/modals/styles.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.footer {
justify-content: flex-end;

@media (max-width: 720px) {
:global(.uui-button) {
flex-basis: 50%;
}
}
}
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
**What's New**
* Sass updated to the last version, warnings 'Mixed Declarations' fixed https://sass-lang.com/documentation/breaking-changes/mixed-decls/
* [DataTable]: - `ColumnsConfigurationModal` - updated modal width from 420px to 560px according design, 'disabled' state for locked columns is changed to 'readonly', added vertical paddings to multiline column names.
* [Modals]: for mobile view (width is up to 720px) by default the modal position is fixed at the bottom edge of the screen

**What's Fixed**
*[VirtualList]: fixed offsets counting if rows have different height
Expand Down
5 changes: 2 additions & 3 deletions uui-editor/src/plugins/linkPlugin/AddLinkModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useState } from 'react';
import { ELEMENT_LINK, TLinkElement, unwrapLink, upsertLink } from '@udecode/plate-link';
import { PlateEditor, getPluginType, findNode, getAboveNode } from '@udecode/plate-common';
import { IModal } from '@epam/uui-core';
import { FlexRow, FlexSpacer, ModalWindow, ModalBlocker, ModalFooter, ModalHeader, Button, LabeledInput, TextInput } from '@epam/uui';
import { FlexRow, ModalWindow, ModalBlocker, ModalFooter, ModalHeader, Button, LabeledInput, TextInput } from '@epam/uui';

import css from './link.module.scss';

Expand Down Expand Up @@ -51,8 +51,7 @@ export function AddLinkModal({ editor, ...modalProps }: AddLinkModalProps) {
/>
</LabeledInput>
</FlexRow>
<ModalFooter borderTop>
<FlexSpacer />
<ModalFooter borderTop cx={ css.footer }>
<Button
color="secondary"
fill="outline"
Expand Down
10 changes: 10 additions & 0 deletions uui-editor/src/plugins/linkPlugin/link.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,13 @@
.input-wrapper {
padding: 9px 24px;
}

.footer {
justify-content: flex-end;

@media (max-width: 720px) {
:global(.uui-button) {
flex-basis: 50%;
}
}
}
10 changes: 10 additions & 0 deletions uui-editor/src/plugins/videoPlugin/AddVideoModal.module.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
.input-wrapper {
padding: 9px 24px;
}

.footer {
justify-content: flex-end;

@media (max-width: 720px) {
:global(.uui-button) {
flex-basis: 50%;
}
}
}
5 changes: 2 additions & 3 deletions uui-editor/src/plugins/videoPlugin/AddVideoModal.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import { IModal, prependHttp } from '@epam/uui-core';
import { FlexSpacer, FlexRow, ModalBlocker, ModalHeader, ModalWindow, ModalFooter, LabeledInput, Button, TextInput } from '@epam/uui';
import { FlexRow, ModalBlocker, ModalHeader, ModalWindow, ModalFooter, LabeledInput, Button, TextInput } from '@epam/uui';
import css from './AddVideoModal.module.scss';
import getVideoId from 'get-video-id';
import { useState } from 'react';
Expand Down Expand Up @@ -75,8 +75,7 @@ export function AddVideoModal({ editor, success, abort, ...props }: AddVideoModa
/>
</LabeledInput>
</FlexRow>
<ModalFooter borderTop>
<FlexSpacer />
<ModalFooter borderTop cx={ css.footer }>
<Button color="secondary" fill="outline" caption="Cancel" onClick={ () => abort() } />
<Button
color="primary"
Expand Down
9 changes: 9 additions & 0 deletions uui/components/overlays/ConfirmationModal.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.footer {
justify-content: flex-end;

@media (max-width: 720px) {
:global(.uui-button) {
flex-basis: 50%;
}
}
}
7 changes: 4 additions & 3 deletions uui/components/overlays/ConfirmationModal.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import * as React from 'react';
import { IModal } from '@epam/uui-core';
import { Button } from '../buttons';
import { FlexSpacer, Panel, ScrollBars } from '../layout';
import { Panel, ScrollBars } from '../layout';
import { ModalBlocker, ModalWindow, ModalHeader, ModalFooter } from './Modals';
import { i18n } from '../../i18n';

import css from './ConfirmationModal.module.scss';

export interface ConfirmationModalWindowProps extends IModal<any> {
/** Confirmation modal title */
caption: any;
Expand All @@ -27,8 +29,7 @@ export class ConfirmationModal extends React.Component<ConfirmationModalWindowPr
<ModalWindow width={ 420 }>
<ModalHeader borderBottom title={ this.props.caption } onClose={ () => this.props.abort() } />
<ScrollBars>{bodyContent}</ScrollBars>
<ModalFooter>
<FlexSpacer />
<ModalFooter cx={ css.footer }>
{this.props.hideCancelButton || (
<Button caption={ i18n.form.modals.discardButton } onClick={ () => this.props.success(false) } fill="outline" color="secondary" />
)}
Expand Down
12 changes: 11 additions & 1 deletion uui/components/overlays/Modals.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,12 @@
box-shadow: var(--uui-modals-shadow);

@media (max-width: 720px) {
position: fixed;
inset-inline-start: 0;
inset-block-end: 0;
min-width: 100vw;
border-radius: 0;
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
}

:global(.uui-shadow-top)::before {
Expand All @@ -48,6 +52,12 @@
.modal-footer {
border-bottom-left-radius: var(--uui-modals-border-radius);
border-bottom-right-radius: var(--uui-modals-border-radius);

@media (max-width: 720px) {
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;

}
}

.modal-header {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,17 +145,14 @@ exports[`ConfirmationModal should be rendered correctly 1`] = `
</div>
</div>
<div
className="uui-flex-row root uui-size-36 padding-24 vPadding-24 root modalFooter container align-items-center"
className="uui-flex-row root uui-size-36 padding-24 vPadding-24 root modalFooter footer container align-items-center"
style={
Object {
"columnGap": "12px",
"rowGap": undefined,
}
}
>
<div
className="flexSpacer"
/>
<button
className="uui-button-box uui-enabled -clickable container root uui-button uui-fill-outline uui-color-secondary uui-size-36"
onClick={[Function]}
Expand Down Expand Up @@ -322,17 +319,14 @@ exports[`ConfirmationModal should be rendered correctly without body 1`] = `
</div>
</div>
<div
className="uui-flex-row root uui-size-36 padding-24 vPadding-24 root modalFooter container align-items-center"
className="uui-flex-row root uui-size-36 padding-24 vPadding-24 root modalFooter footer container align-items-center"
style={
Object {
"columnGap": "12px",
"rowGap": undefined,
}
}
>
<div
className="flexSpacer"
/>
<button
className="uui-button-box uui-enabled -clickable container root uui-button uui-fill-outline uui-color-secondary uui-size-36"
onClick={[Function]}
Expand Down

0 comments on commit 541ff4d

Please sign in to comment.