scrolling variant

This commit is contained in:
Nate Kelley 2025-03-11 14:02:29 -06:00
parent 2a0dedfe2e
commit e849d95a77
No known key found for this signature in database
GPG Key ID: FD90372AB8D98B4F
4 changed files with 39 additions and 2 deletions

View File

@ -1,5 +1,6 @@
import type { Meta, StoryObj } from '@storybook/react';
import { AppPageLayout } from './AppPageLayout';
import React from 'react';
const meta: Meta<typeof AppPageLayout> = {
title: 'UI/Layouts/AppPageLayout',
@ -53,6 +54,7 @@ export const LongContent: Story = {
args: {
header: <div className="bg-gray-100">Header Content</div>,
scrollable: true,
headerBorderVariant: 'ghost',
children: (
<>
{Array.from({ length: 100 }, (_, i) => (

View File

@ -39,7 +39,14 @@ export const AppPageLayout: React.FC<
{header}
</AppPageLayoutHeader>
)}
<AppPageLayoutContent scrollable={scrollable}>{children}</AppPageLayoutContent>
<AppPageLayoutContent className="scroll-shadow-container" scrollable={scrollable}>
{header && scrollable && headerBorderVariant === 'ghost' && (
<div className="scroll-header"></div>
)}
{children}
</AppPageLayoutContent>
</div>
);
};

View File

@ -3,7 +3,7 @@ import React from 'react';
import { cva, type VariantProps } from 'class-variance-authority';
const headerVariants = cva(
'bg-page-background flex max-h-[38px] min-h-[38px] items-center justify-between gap-x-2.5 ',
'bg-page-background flex max-h-[38px] min-h-[38px] items-center justify-between gap-x-2.5 relative z-10',
{
variants: {
sizeVariant: {

View File

@ -5,3 +5,31 @@
display: none;
}
}
// This approach has very limited browser support
:root {
--globalScrollTimeline: none; // Define the timeline globally
}
.scroll-shadow-container {
position: relative;
scroll-timeline-name: --globalScrollTimeline;
@apply relative;
.scroll-header {
@apply fixed top-[30px] right-0 left-0 h-2 w-full;
animation: shadowAnimation linear;
animation-range: 0px 125px;
animation-timeline: --globalScrollTimeline;
animation-fill-mode: forwards;
}
@keyframes shadowAnimation {
from {
box-shadow: 0 0 0 rgba(0, 0, 0, 0);
}
to {
box-shadow: 0px 1px 8px 0px #00000029;
}
}
}