From 2bd4a0fb4d485c87bd6c5daea7afb8e3cf64262c Mon Sep 17 00:00:00 2001 From: Cole Bemis Date: Tue, 2 Aug 2022 10:55:01 -0700 Subject: [PATCH 01/25] Add storybook story to test sticky behavior --- src/PageLayout/PageLayout.stories.tsx | 36 ++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/src/PageLayout/PageLayout.stories.tsx b/src/PageLayout/PageLayout.stories.tsx index 0e815fb7987..a9ee637af2c 100644 --- a/src/PageLayout/PageLayout.stories.tsx +++ b/src/PageLayout/PageLayout.stories.tsx @@ -349,6 +349,40 @@ export const SettingsPage = () => ( ) -// TODO: discussions page example +export const StickyPane = () => ( + + + + + + + {Array.from({length: 30}).map((_, i) => ( + + Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam at enim id lorem tempus egestas a non ipsum. + Maecenas imperdiet ante quam, at varius lorem molestie vel. Sed at eros consequat, varius tellus et, auctor + felis. Donec pulvinar lacinia urna nec commodo. Phasellus at imperdiet risus. Donec sit amet massa purus. + Nunc sem lectus, bibendum a sapien nec, tristique tempus felis. Ut porttitor auctor tellus in imperdiet. Ut + blandit tincidunt augue, quis fringilla nunc tincidunt sed. Vestibulum auctor euismod nisi. Nullam tincidunt + est in mi tincidunt dictum. Sed consectetur aliquet velit ut ornare. + + ))} + + + + + {Array.from({length: 10}).map((_, i) => ( + + Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam at enim id lorem tempus egestas a non ipsum. + Maecenas imperdiet ante quam, at varius lorem molestie vel. Sed at eros consequat, varius tellus et, auctor + felis. Donec pulvinar lacinia urna nec commodo. Phasellus at imperdiet risus. Donec sit amet massa purus. + + ))} + + + + + + +) export default meta From 68a8934e97179606ab310795ae2a10d09a6d6afc Mon Sep 17 00:00:00 2001 From: Cole Bemis Date: Tue, 2 Aug 2022 13:48:10 -0700 Subject: [PATCH 02/25] First draft of sticky implementation --- src/PageLayout/PageLayout.stories.tsx | 2 +- src/PageLayout/PageLayout.tsx | 93 ++++++++++++++++++++------- 2 files changed, 70 insertions(+), 25 deletions(-) diff --git a/src/PageLayout/PageLayout.stories.tsx b/src/PageLayout/PageLayout.stories.tsx index a9ee637af2c..8356770da44 100644 --- a/src/PageLayout/PageLayout.stories.tsx +++ b/src/PageLayout/PageLayout.stories.tsx @@ -368,7 +368,7 @@ export const StickyPane = () => ( ))} - + {Array.from({length: 10}).map((_, i) => ( diff --git a/src/PageLayout/PageLayout.tsx b/src/PageLayout/PageLayout.tsx index 5825f0a0510..ff02f02687d 100644 --- a/src/PageLayout/PageLayout.tsx +++ b/src/PageLayout/PageLayout.tsx @@ -21,10 +21,12 @@ const PageLayoutContext = React.createContext<{ padding: keyof typeof SPACING_MAP rowGap: keyof typeof SPACING_MAP columnGap: keyof typeof SPACING_MAP + contentRef: React.RefObject | null }>({ padding: 'normal', rowGap: 'normal', - columnGap: 'normal' + columnGap: 'normal', + contentRef: null }) // ---------------------------------------------------------------------------- @@ -55,8 +57,9 @@ const Root: React.FC> = ({ children, sx = {} }) => { + const contentRef = React.useRef(null) return ( - + ({padding: SPACING_MAP[padding]}, sx)}> > = ({ sx = {} }) => { const isHidden = useResponsiveValue(hidden, false) + const {contentRef} = React.useContext(PageLayoutContext) return (