Skip to content

Commit

Permalink
feat: fixed animation; fixed readme file; added scss vars
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisVershkov committed Jan 17, 2024
1 parent 3ea9996 commit a4779d2
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 22 deletions.
6 changes: 4 additions & 2 deletions src/components/Dialog/Dialog.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ $block: '.#{variables.$ns}dialog';
display: flex;
flex-direction: column;

&_with-scroll {
&_has-scroll {
overflow-y: auto;
max-height: calc(100vh - var(--yc-modal-margin) * 2);
max-height: calc(
100vh - calc(var(--g-modal-margin, #{variables.$modal-default-margin})) * 2
);
}

&_size {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Dialog/Dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export class Dialog extends React.Component<DialogInnerProps> {
{
size,
'has-close': hasCloseButton,
'with-scroll': contentOverflow === 'auto',
'has-scroll': contentOverflow === 'auto',
},
className,
)}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Dialog/DialogBody/DialogBody.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ $block: '.#{variables.$ns}dialog-body';
flex: 1 1 auto;
overflow-y: auto;

&_with-dividers {
&_has-dividers {
border-block-start: 1px solid var(--g-color-line-generic);
border-block-end: 1px solid var(--g-color-line-generic);
}
Expand Down
6 changes: 3 additions & 3 deletions src/components/Dialog/DialogBody/DialogBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ const b = block('dialog-body');
export interface DialogBodyProps {
children: React.ReactNode;
className?: string;
withDividers?: boolean;
hasDividers?: boolean;
}

export function DialogBody(props: DialogBodyProps) {
const {className, withDividers = false} = props;
const {className, hasDividers = false} = props;

return <div className={b({'with-dividers': withDividers}, className)}>{props.children}</div>;
return <div className={b({'has-dividers': hasDividers}, className)}>{props.children}</div>;
}
21 changes: 9 additions & 12 deletions src/components/Modal/Modal.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ $block: '.#{variables.$ns}modal';
-webkit-overflow-scrolling: touch;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);

&__content-aligner-wrapper {
&__content-aligner {
min-width: 100%;
min-height: 100%;

Expand All @@ -25,17 +25,19 @@ $block: '.#{variables.$ns}modal';
justify-content: center;
}

&__content-container {
margin: var(--yc-modal-margin);
background-color: var(--g-color-base-modal);
border-radius: var(--yc-modal-border-radius);
&__content-wrapper {
margin: var(--g-modal-margin, #{variables.$modal-default-margin});
border-radius: var(--g-modal-border-radius, #{variables.$modal-default-border-radius});
overflow-x: hidden;
}

&__content {
&_with-scroll {
background-color: var(--g-color-base-modal);
&_has-scroll {
overflow-y: auto;
max-height: calc(100vh - (var(--yc-modal-margin) * 2));
max-height: calc(
100vh - calc(var(--g-modal-margin, #{variables.$modal-default-margin})) * 2
);
}
}

Expand Down Expand Up @@ -98,8 +100,3 @@ $block: '.#{variables.$ns}modal';
transform: scale(1);
}
}

:root {
--yc-modal-border-radius: 5px;
--yc-modal-margin: 20px;
}
6 changes: 3 additions & 3 deletions src/components/Modal/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ export function Modal({
}}
>
<div ref={containerRef} style={style} className={b({open}, className)} data-qa={qa}>
<div className={b('content-aligner-wrapper')}>
<div className={b('content-container')}>
<div className={b('content-aligner')}>
<div className={b('content-wrapper')}>
<FocusTrap
enabled={!disableFocusTrap && focusTrap && open && !inTransition}
autoFocus={!disableAutoFocus && autoFocus}
Expand All @@ -146,7 +146,7 @@ export function Modal({
aria-labelledby={ariaLabelledBy}
className={b(
'content',
{'with-scroll': contentOverflow === 'auto'},
{'has-scroll': contentOverflow === 'auto'},
contentClassName,
)}
{...containerProps}
Expand Down
7 changes: 7 additions & 0 deletions src/components/Modal/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,10 @@ const [open, setOpen] = React.useState(false);
| aria-label | HTML `aria-label` attribute to describe the `Modal` | `string` | |
| aria-labelledby | Id of the visible `Modal` caption element | `string` | |
| contentOverflow | Define whether `Modal` has a scroll indicator inside or grows with the content | `visible` `auto` | `visible` |

## CSS API

| Name | Description |
| :------------------------ | :---------------------------- |
| `--g-modal-margin` | Margin around Modal's content |
| `--g-modal-border-radius` | Modal's content border radius |
2 changes: 2 additions & 0 deletions src/components/variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ $s-height: 24px;
$m-height: 28px;
$l-height: 36px;
$xl-height: 44px;
$modal-default-border-radius: 5px;
$modal-default-margin: 20px;

0 comments on commit a4779d2

Please sign in to comment.