Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(Modal): use mask-image for overflow indicator #15734

Merged
merged 2 commits into from Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 7 additions & 12 deletions packages/react/src/components/ComposedModal/ComposedModal.tsx
Expand Up @@ -62,18 +62,13 @@ export const ModalBody = React.forwardRef<HTMLDivElement, ModalBodyProps>(
: {};

return (
<>
<div
className={contentClass}
{...hasScrollingContentProps}
{...rest}
ref={ref}>
{children}
</div>
{hasScrollingContent && (
<div className={`${prefix}--modal-content--overflow-indicator`} />
)}
</>
<div
className={contentClass}
{...hasScrollingContentProps}
{...rest}
ref={ref}>
{children}
</div>
);
}
);
Expand Down
3 changes: 0 additions & 3 deletions packages/react/src/components/Modal/Modal.tsx
Expand Up @@ -488,9 +488,6 @@ const Modal = React.forwardRef(function Modal(
{...hasScrollingContentProps}>
{children}
</div>
{hasScrollingContent && (
<div className={`${prefix}--modal-content--overflow-indicator`} />
)}
{!passiveModal && (
<ButtonSet className={footerClasses} aria-busy={loadingActive}>
{Array.isArray(secondaryButtons) && secondaryButtons.length <= 2
Expand Down
58 changes: 10 additions & 48 deletions packages/styles/scss/components/modal/_modal.scss
Expand Up @@ -350,60 +350,22 @@
.#{$prefix}--modal-scroll-content {
// Required to accommodate focus outline's negative offset when scrolling in Chrome
border-block-end: 2px solid transparent;
mask-image: linear-gradient(
to bottom,
$layer calc(100% - 80px),
transparent calc(100% - 48px),
transparent 100%
),
linear-gradient(to left, $layer 0, 16px, transparent 16px),
linear-gradient(to right, $layer 0, 2px, transparent 2px),
linear-gradient(to top, $layer 0, 2px, transparent 2px);
}

// Required so overflow-indicator disappears at end of content
.#{$prefix}--modal-scroll-content > *:last-child {
padding-block-end: $spacing-06;
}

.#{$prefix}--modal-content--overflow-indicator {
position: absolute;
background: $layer;
block-size: convert.to-rem(48px);
grid-column: 1/-1;
grid-row: 2/-2;
inline-size: calc(100% - $spacing-05);
inset-block-end: 0;
inset-inline-start: 0;
pointer-events: none;

&::before {
position: absolute;
background-image: linear-gradient(to bottom, transparent, $layer);
block-size: convert.to-rem(32px);
content: '';
inline-size: 100%;
inset-block-start: -32px;
pointer-events: none;
}
}

// Safari-only media query
// won't appear correctly with CSS custom properties
// see: code snippet and tabs overflow indicators
@media not all and (min-resolution >= 0.001dpcm) {
@supports (-webkit-appearance: none) and (stroke-color: transparent) {
.#{$prefix}--modal-content--overflow-indicator {
background-image: linear-gradient(to bottom, rgba($layer, 0), $layer);
}
}
}

.#{$prefix}--modal-content:focus
~ .#{$prefix}--modal-content--overflow-indicator {
margin: 0 2px 2px;
}

@media screen and (-ms-high-contrast: active) {
.#{$prefix}--modal-scroll-content > *:last-child {
padding-block-end: 0;
}

.#{$prefix}--modal-content--overflow-indicator {
display: none;
}
}

// -----------------------------
// Modal footer
// -----------------------------
Expand Down