1
0
mirror of https://github.com/phuoc-ng/csslayout.git synced 2025-08-15 10:34:05 +02:00

Add corner ribbon

This commit is contained in:
Phuoc Nguyen
2019-12-01 16:29:16 +07:00
parent a37a070ddb
commit b40575e3a5
7 changed files with 255 additions and 1 deletions

View File

@@ -7,6 +7,7 @@ enum Pattern {
Centering = 'Centering',
CircularNavigation = 'Circular navigation',
CookieBanner = 'Cookie banner',
CornerRibbon = 'Corner ribbon',
DockedAtCorner = 'Docked at corner',
DotLeader = 'Dot leader',
DotNavigation = 'Dot navigation',

View File

@@ -91,6 +91,7 @@ const ExplorePage = () => {
<CoverCard pattern={Pattern.Centering} />
<CoverCard pattern={Pattern.CircularNavigation} />
<CoverCard pattern={Pattern.CookieBanner} />
<CoverCard pattern={Pattern.CornerRibbon} />
<CoverCard pattern={Pattern.DockedAtCorner} />
<CoverCard pattern={Pattern.DotLeader} />
<CoverCard pattern={Pattern.DotNavigation} />

View File

@@ -0,0 +1,56 @@
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',
padding: '8px',
}}
>
<div
style={{
border: '1px solid rgba(0, 0, 0, 0.3)',
borderRadius: '4px',
height: '100%',
position: 'relative',
width: '100%',
}}
>
<div
style={{
height: '48px',
left: 0,
overflow: 'hidden',
position: 'absolute',
top: 0,
width: '48px',
}}
>
<div
style={{
backgroundColor: 'rgba(0, 0, 0, 0.3)',
height: '16px',
left: '-16px',
position: 'absolute',
textAlign: 'center',
top: '8px',
transform: 'rotate(-45deg)',
width: '70px',
}}
/>
</div>
</div>
</div>
</Frame>
);
};
export default Cover;

View File

@@ -0,0 +1,189 @@
import React from 'react';
import { Link } from 'react-router-dom';
import Heading from '../../components/Heading';
import RelatedPatterns from '../../components/RelatedPatterns';
import Pattern from '../../constants/Pattern';
import DetailsLayout from '../../layouts/DetailsLayout';
import BrowserFrame from '../../placeholders/BrowserFrame';
const Details: React.FC<{}> = () => {
return (
<DetailsLayout title="Corner ribbon">
<div style={{ padding: '64px 32px' }}>
<BrowserFrame
content={(
<div
style={{
alignItems: 'center',
display: 'flex',
height: '100%',
justifyContent: 'center',
}}
>
<div
style={{
border: '1px solid rgba(0, 0, 0, 0.3)',
borderRadius: '4px',
height: '256px',
position: 'relative',
width: '256px',
}}
>
<div
style={{
height: '100px',
left: 0,
overflow: 'hidden',
position: 'absolute',
top: 0,
width: '100px',
}}
>
<div
style={{
backgroundColor: 'rgba(0, 0, 0, 0.3)',
height: '24px',
left: '-64px',
position: 'absolute',
textAlign: 'center',
top: '32px',
transform: 'rotate(-45deg)',
width: '206px',
}}
/>
</div>
</div>
</div>
)}
source={`
<div style="
position: relative;
">
<!-- The container -->
<div style="
/* Displayed at the top left corner */
left: 0px;
position: absolute;
top: 0px;
/* Size */
height: 100px;
width: 100px;
/* Hide the part of its children which is displayed outside */
overflow: hidden;
">
<!-- The ribbon -->
<div style="
/* Position */
left: -64px;
position: absolute;
top: 32px;
/* Size */
height: 24px;
width: 206px;
/* Displayed diagonally */
transform: rotate(-45deg);
/* Background color */
background-color: rgba(0, 0, 0, 0.3);
/* Centerize the text content */
text-align: center;
">
...
</div>
</div>
</div>
`}
/>
</div>
<section>
<Heading title="Use cases" />
<div style={{ padding: '32px' }}>
<div style={{ lineHeight: 1.5, marginBottom: '16px' }}>
You can add a ribbon to
a <Link to='/patterns/pricing-table' style={{ textDecoration: 'none' }}>
pricing table
</Link> to indicate the most popular option.
</div>
<div
style={{
alignItems: 'center',
display: 'flex',
justifyContent: 'center',
width: '60%',
}}
>
<div
style={{
border: '1px solid rgba(0, 0, 0, 0.3)',
borderRadius: '4px',
flex: 1,
height: '200px',
margin: '0 8px',
}}
/>
<div
style={{
border: '1px solid rgba(0, 0, 0, 0.3)',
borderRadius: '4px',
flex: 1,
height: '300px',
margin: '0 8px',
position: 'relative',
}}
>
<div
style={{
height: '100px',
left: 0,
overflow: 'hidden',
position: 'absolute',
top: 0,
width: '100px',
}}
>
<div
style={{
backgroundColor: '#00449E',
color: '#FFF',
fontWeight: 'bold',
left: '-64px',
padding: '2px 0',
position: 'absolute',
textAlign: 'center',
top: '32px',
transform: 'rotate(-45deg)',
width: '210px',
}}
>
Popular
</div>
</div>
</div>
<div
style={{
border: '1px solid rgba(0, 0, 0, 0.3)',
borderRadius: '4px',
flex: 1,
height: '250px',
margin: '0 8px',
}}
/>
</div>
</div>
</section>
<RelatedPatterns patterns={[Pattern.FixedAtCorner]} />
</DetailsLayout>
);
};
export default Details;

View File

@@ -70,7 +70,7 @@ const Details: React.FC<{}> = () => {
`}
/>
</div>
<RelatedPatterns patterns={[Pattern.CookieBanner]} />
<RelatedPatterns patterns={[Pattern.CookieBanner, Pattern.CornerRibbon]} />
</DetailsLayout>
);
};

View File

@@ -1,4 +1,5 @@
import React from 'react';
import { Link } from 'react-router-dom';
import DetailsLayout from '../../layouts/DetailsLayout';
import Block from '../../placeholders/Block';
@@ -10,6 +11,11 @@ const Details: React.FC<{}> = () => {
return (
<DetailsLayout title="Pricing table">
<div style={{ padding: '64px 32px' }}>
<div style={{ lineHeight: 1.5, marginBottom: '16px' }}>
You can
add <Link to='/patterns/corner-ribbon' style={{ textDecoration: 'none' }}>a ribbon</Link> to
indicate the most popular option.
</div>
<BrowserFrame
content={(
<div

View File

@@ -13,6 +13,7 @@
<url><loc>https://csslayout.io/patterns/centering</loc></url>
<url><loc>https://csslayout.io/patterns/circular-navigation</loc></url>
<url><loc>https://csslayout.io/patterns/cookie-banner</loc></url>
<url><loc>https://csslayout.io/patterns/corner-ribbon</loc></url>
<url><loc>https://csslayout.io/patterns/docked-at-corner</loc></url>
<url><loc>https://csslayout.io/patterns/dot-leader</loc></url>
<url><loc>https://csslayout.io/patterns/dot-navigation</loc></url>