mirror of
https://github.com/phuoc-ng/csslayout.git
synced 2025-08-09 15:46:55 +02:00
Add color swatch pattern
This commit is contained in:
@@ -17,6 +17,7 @@ enum Pattern {
|
|||||||
Chip = 'Chip',
|
Chip = 'Chip',
|
||||||
CircularNavigation = 'Circular navigation',
|
CircularNavigation = 'Circular navigation',
|
||||||
CloseButton = 'Close button',
|
CloseButton = 'Close button',
|
||||||
|
ColorSwatch = 'Color swatch',
|
||||||
CookieBanner = 'Cookie banner',
|
CookieBanner = 'Cookie banner',
|
||||||
CornerRibbon = 'Corner ribbon',
|
CornerRibbon = 'Corner ribbon',
|
||||||
CurvedBackground = 'Curved background',
|
CurvedBackground = 'Curved background',
|
||||||
|
@@ -119,6 +119,7 @@ const ExplorePage = () => {
|
|||||||
<CoverCard pattern={Pattern.Card} />
|
<CoverCard pattern={Pattern.Card} />
|
||||||
<CoverCard pattern={Pattern.Centering} />
|
<CoverCard pattern={Pattern.Centering} />
|
||||||
<CoverCard pattern={Pattern.CloseButton} />
|
<CoverCard pattern={Pattern.CloseButton} />
|
||||||
|
<CoverCard pattern={Pattern.ColorSwatch} />
|
||||||
<CoverCard pattern={Pattern.CookieBanner} />
|
<CoverCard pattern={Pattern.CookieBanner} />
|
||||||
<CoverCard pattern={Pattern.CornerRibbon} />
|
<CoverCard pattern={Pattern.CornerRibbon} />
|
||||||
<CoverCard pattern={Pattern.CurvedBackground} />
|
<CoverCard pattern={Pattern.CurvedBackground} />
|
||||||
|
@@ -20,7 +20,6 @@ const Details: React.FC<{}> = () => {
|
|||||||
<meta name="twitter:description" content="Create an avatar component with CSS flexbox" />
|
<meta name="twitter:description" content="Create an avatar component with CSS flexbox" />
|
||||||
<meta name="keywords" content="css avatar, css flexbox" />
|
<meta name="keywords" content="css avatar, css flexbox" />
|
||||||
</Helmet>
|
</Helmet>
|
||||||
<div className='p-8 pb-20'>
|
|
||||||
<BrowserFrame
|
<BrowserFrame
|
||||||
html={`
|
html={`
|
||||||
<div class="avatar">
|
<div class="avatar">
|
||||||
@@ -86,7 +85,6 @@ css={`
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</BrowserFrame>
|
</BrowserFrame>
|
||||||
</div>
|
|
||||||
|
|
||||||
<RelatedPatterns patterns={[Pattern.AvatarList, Pattern.InitialAvatar, Pattern.PresenceIndicator]} />
|
<RelatedPatterns patterns={[Pattern.AvatarList, Pattern.InitialAvatar, Pattern.PresenceIndicator]} />
|
||||||
</DetailsLayout>
|
</DetailsLayout>
|
||||||
|
42
client/patterns/color-swatch/Cover.tsx
Normal file
42
client/patterns/color-swatch/Cover.tsx
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
/**
|
||||||
|
* A collection of popular layouts and patterns made with CSS (https://csslayout.io)
|
||||||
|
* (c) 2019 - 2021 Nguyen Huu Phuoc <https://twitter.com/nghuuphuoc>
|
||||||
|
*/
|
||||||
|
|
||||||
|
import * as React from 'react';
|
||||||
|
|
||||||
|
import Frame from '../../placeholders/Frame';
|
||||||
|
|
||||||
|
const Cover: React.FC<{}> = () => {
|
||||||
|
return (
|
||||||
|
<Frame>
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
alignItems: 'center',
|
||||||
|
display: 'flex',
|
||||||
|
flexWrap: 'wrap',
|
||||||
|
height: '100%',
|
||||||
|
justifyContent: 'center',
|
||||||
|
padding: '8px',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{
|
||||||
|
Array(4).fill(0).map((_, index) => (
|
||||||
|
<div
|
||||||
|
key={index}
|
||||||
|
style={{
|
||||||
|
backgroundColor: `rgba(0, 0, 0, 0.${index * 2 + 1})`,
|
||||||
|
borderRadius: '9999px',
|
||||||
|
height: '1.5rem',
|
||||||
|
margin: '0.5rem',
|
||||||
|
width: '1.5rem',
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
))
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</Frame>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Cover;
|
84
client/patterns/color-swatch/Details.tsx
Normal file
84
client/patterns/color-swatch/Details.tsx
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
/**
|
||||||
|
* A collection of popular layouts and patterns made with CSS (https://csslayout.io)
|
||||||
|
* (c) 2019 - 2021 Nguyen Huu Phuoc <https://twitter.com/nghuuphuoc>
|
||||||
|
*/
|
||||||
|
|
||||||
|
import * as React from 'react';
|
||||||
|
import { Helmet } from 'react-helmet';
|
||||||
|
|
||||||
|
import Pattern from '../../constants/Pattern';
|
||||||
|
import DetailsLayout from '../../layouts/DetailsLayout';
|
||||||
|
import BrowserFrame from '../../placeholders/BrowserFrame';
|
||||||
|
|
||||||
|
const Details: React.FC<{}> = () => {
|
||||||
|
return (
|
||||||
|
<DetailsLayout pattern={Pattern.ColorSwatch}>
|
||||||
|
<Helmet>
|
||||||
|
<meta name="description" content="Create a color swatch with CSS flexbox" />
|
||||||
|
<meta name="og:description" content="Create a color swatch with CSS flexbox" />
|
||||||
|
<meta name="twitter:description" content="Create a color swatch with CSS flexbox" />
|
||||||
|
<meta name="keywords" content="css color swatch, css flexbox" />
|
||||||
|
</Helmet>
|
||||||
|
<BrowserFrame
|
||||||
|
html={`
|
||||||
|
<div class="swatch">
|
||||||
|
<div class="swatch__item" style="background-color: ..."></div>
|
||||||
|
|
||||||
|
<!-- Repeat other items -->
|
||||||
|
...
|
||||||
|
</div>
|
||||||
|
`}
|
||||||
|
css={`
|
||||||
|
.swatch {
|
||||||
|
/* Wrap the items */
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
.swatch__item {
|
||||||
|
/* Rounded border */
|
||||||
|
border-radius: 9999px;
|
||||||
|
height: 1.5rem;
|
||||||
|
width: 1.5rem;
|
||||||
|
|
||||||
|
/* Space between items */
|
||||||
|
margin: 0.5rem;
|
||||||
|
}
|
||||||
|
`}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
alignItems: 'center',
|
||||||
|
display: 'flex',
|
||||||
|
height: '100%',
|
||||||
|
justifyContent: 'center',
|
||||||
|
padding: '0.5rem',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
display: 'flex',
|
||||||
|
flexWrap: 'wrap',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{
|
||||||
|
Array(9).fill(0).map((_, index) => (
|
||||||
|
<div
|
||||||
|
key={index}
|
||||||
|
style={{
|
||||||
|
backgroundColor: `rgba(0, 0, 0, 0.${index + 1})`,
|
||||||
|
borderRadius: '9999px',
|
||||||
|
height: '1.5rem',
|
||||||
|
margin: '0.5rem',
|
||||||
|
width: '1.5rem',
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
))
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</BrowserFrame>
|
||||||
|
</DetailsLayout>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Details;
|
Reference in New Issue
Block a user