mirror of
https://github.com/phuoc-ng/csslayout.git
synced 2025-08-06 06:07:33 +02:00
Add sticky sections
This commit is contained in:
@@ -60,6 +60,7 @@ enum Pattern {
|
|||||||
StepperInput = 'Stepper input',
|
StepperInput = 'Stepper input',
|
||||||
StickyFooter = 'Sticky footer',
|
StickyFooter = 'Sticky footer',
|
||||||
StickyHeader = 'Sticky header',
|
StickyHeader = 'Sticky header',
|
||||||
|
StickySections = 'Sticky sections',
|
||||||
Switch = 'Switch',
|
Switch = 'Switch',
|
||||||
Tab = 'Tab',
|
Tab = 'Tab',
|
||||||
Timeline = 'Timeline',
|
Timeline = 'Timeline',
|
||||||
|
@@ -84,6 +84,7 @@ const ExplorePage = () => {
|
|||||||
<CoverCard pattern={Pattern.SplitScreen} />
|
<CoverCard pattern={Pattern.SplitScreen} />
|
||||||
<CoverCard pattern={Pattern.StickyFooter} />
|
<CoverCard pattern={Pattern.StickyFooter} />
|
||||||
<CoverCard pattern={Pattern.StickyHeader} />
|
<CoverCard pattern={Pattern.StickyHeader} />
|
||||||
|
<CoverCard pattern={Pattern.StickySections} />
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
43
client/patterns/sticky-sections/Cover.tsx
Normal file
43
client/patterns/sticky-sections/Cover.tsx
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
import Frame from '../../placeholders/Frame';
|
||||||
|
|
||||||
|
const Cover: React.FC<{}> = () => {
|
||||||
|
return (
|
||||||
|
<Frame>
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
alignItems: 'center',
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
|
height: '100%',
|
||||||
|
justifyContent: 'center',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
backgroundColor: 'rgba(0, 0, 0, 0.1)',
|
||||||
|
flex: 1,
|
||||||
|
width: '100%',
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
backgroundColor: 'rgba(0, 0, 0, 0.2)',
|
||||||
|
flex: 1,
|
||||||
|
width: '100%',
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
backgroundColor: 'rgba(0, 0, 0, 0.3)',
|
||||||
|
flex: 1,
|
||||||
|
width: '100%',
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</Frame>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Cover;
|
77
client/patterns/sticky-sections/Details.tsx
Normal file
77
client/patterns/sticky-sections/Details.tsx
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
import DetailsLayout from '../../layouts/DetailsLayout';
|
||||||
|
import BrowserFrame from '../../placeholders/BrowserFrame';
|
||||||
|
|
||||||
|
const Details: React.FC<{}> = () => {
|
||||||
|
return (
|
||||||
|
<DetailsLayout title="Sticky sections">
|
||||||
|
<div style={{ padding: '64px 32px' }}>
|
||||||
|
<div style={{ lineHeight: 1.5, marginBottom: '16px' }}>
|
||||||
|
Try to scroll the main content to see each section sticks to the top of page.
|
||||||
|
</div>
|
||||||
|
<BrowserFrame
|
||||||
|
content={(
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
height: '100%',
|
||||||
|
overflow: 'scroll',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<section
|
||||||
|
style={{
|
||||||
|
backgroundColor: 'rgba(0, 0, 0, 0.1)',
|
||||||
|
height: '100%',
|
||||||
|
position: 'sticky',
|
||||||
|
top: 0,
|
||||||
|
width: '100%',
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<section
|
||||||
|
style={{
|
||||||
|
backgroundColor: 'rgba(0, 0, 0, 0.3)',
|
||||||
|
height: '100%',
|
||||||
|
position: 'sticky',
|
||||||
|
top: 0,
|
||||||
|
width: '100%',
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<section
|
||||||
|
style={{
|
||||||
|
backgroundColor: 'rgba(0, 0, 0, 0.5)',
|
||||||
|
height: '100%',
|
||||||
|
position: 'sticky',
|
||||||
|
top: 0,
|
||||||
|
width: '100%',
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
source={`
|
||||||
|
<div style="
|
||||||
|
height: 100%;
|
||||||
|
overflow: scroll;
|
||||||
|
">
|
||||||
|
<section style="
|
||||||
|
/* Take full size */
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
|
/* Stick at the top */
|
||||||
|
position: sticky;
|
||||||
|
top: 0;
|
||||||
|
">
|
||||||
|
...
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<!-- Repeat other sections -->
|
||||||
|
...
|
||||||
|
</div>
|
||||||
|
`}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</DetailsLayout>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Details;
|
@@ -61,6 +61,7 @@
|
|||||||
<url><loc>https://csslayout.io/patterns/stepper-input</loc></url>
|
<url><loc>https://csslayout.io/patterns/stepper-input</loc></url>
|
||||||
<url><loc>https://csslayout.io/patterns/sticky-footer</loc></url>
|
<url><loc>https://csslayout.io/patterns/sticky-footer</loc></url>
|
||||||
<url><loc>https://csslayout.io/patterns/sticky-header</loc></url>
|
<url><loc>https://csslayout.io/patterns/sticky-header</loc></url>
|
||||||
|
<url><loc>https://csslayout.io/patterns/sticky-sections</loc></url>
|
||||||
<url><loc>https://csslayout.io/patterns/switch</loc></url>
|
<url><loc>https://csslayout.io/patterns/switch</loc></url>
|
||||||
<url><loc>https://csslayout.io/patterns/tab</loc></url>
|
<url><loc>https://csslayout.io/patterns/tab</loc></url>
|
||||||
<url><loc>https://csslayout.io/patterns/timeline</loc></url>
|
<url><loc>https://csslayout.io/patterns/timeline</loc></url>
|
||||||
|
Reference in New Issue
Block a user