mirror of
https://github.com/phuoc-ng/csslayout.git
synced 2025-08-07 06:37:01 +02:00
@@ -29,6 +29,7 @@ const App = () => {
|
|||||||
<Route exact={true} path='/previous-next-buttons'><DetailsLoader pattern="Previous next buttons" /></Route>
|
<Route exact={true} path='/previous-next-buttons'><DetailsLoader pattern="Previous next buttons" /></Route>
|
||||||
<Route exact={true} path='/pricing-table'><DetailsLoader pattern="Pricing table" /></Route>
|
<Route exact={true} path='/pricing-table'><DetailsLoader pattern="Pricing table" /></Route>
|
||||||
<Route exact={true} path='/progress-bar'><DetailsLoader pattern="Progress bar" /></Route>
|
<Route exact={true} path='/progress-bar'><DetailsLoader pattern="Progress bar" /></Route>
|
||||||
|
<Route exact={true} path='/questions-and-answers'><DetailsLoader pattern="Questions and answers" /></Route>
|
||||||
<Route exact={true} path='/same-height-columns'><DetailsLoader pattern="Same height columns" /></Route>
|
<Route exact={true} path='/same-height-columns'><DetailsLoader pattern="Same height columns" /></Route>
|
||||||
<Route exact={true} path='/search-box'><DetailsLoader pattern="Search box" /></Route>
|
<Route exact={true} path='/search-box'><DetailsLoader pattern="Search box" /></Route>
|
||||||
<Route exact={true} path='/separator'><DetailsLoader pattern="Separator" /></Route>
|
<Route exact={true} path='/separator'><DetailsLoader pattern="Separator" /></Route>
|
||||||
|
@@ -74,6 +74,7 @@ const Home = () => {
|
|||||||
<CoverCard pattern="Previous next buttons" />
|
<CoverCard pattern="Previous next buttons" />
|
||||||
<CoverCard pattern="Pricing table" />
|
<CoverCard pattern="Pricing table" />
|
||||||
<CoverCard pattern="Progress bar" />
|
<CoverCard pattern="Progress bar" />
|
||||||
|
<CoverCard pattern="Questions and answers" />
|
||||||
<CoverCard pattern="Same height columns" />
|
<CoverCard pattern="Same height columns" />
|
||||||
<CoverCard pattern="Search box" />
|
<CoverCard pattern="Search box" />
|
||||||
<CoverCard pattern="Separator" />
|
<CoverCard pattern="Separator" />
|
||||||
|
33
client/patterns/questions-and-answers/Cover.jsx
Normal file
33
client/patterns/questions-and-answers/Cover.jsx
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
import Frame from '../../placeholders/Frame';
|
||||||
|
import Line from '../../placeholders/Line';
|
||||||
|
import Rectangle from '../../placeholders/Rectangle';
|
||||||
|
import Triangle from '../../placeholders/Triangle';
|
||||||
|
|
||||||
|
const Cover = () => {
|
||||||
|
return (
|
||||||
|
<Frame>
|
||||||
|
<div className="h-100 flex flex-column items-center justify-center pa2">
|
||||||
|
<div className="w-80">
|
||||||
|
<div className="flex items-center justify-between mb2">
|
||||||
|
<div className="w-60"><Rectangle height={4} /></div>
|
||||||
|
<Triangle size={6} corner="b" />
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<div className="flex items-center justify-between mb1">
|
||||||
|
<div className="w-40"><Rectangle height={4} /></div>
|
||||||
|
<Triangle size={6} corner="t" />
|
||||||
|
</div>
|
||||||
|
<div className="w-100 mb1"><Line /></div>
|
||||||
|
<div className="w-80 mb1"><Line /></div>
|
||||||
|
<div className="w-60 mb1"><Line /></div>
|
||||||
|
<div className="w-40"><Line /></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Frame>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Cover;
|
94
client/patterns/questions-and-answers/Details.jsx
Normal file
94
client/patterns/questions-and-answers/Details.jsx
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
import React, { useState } from 'react';
|
||||||
|
|
||||||
|
import DetailsLayout from '../../layouts/DetailsLayout';
|
||||||
|
import Block from '../../placeholders/Block';
|
||||||
|
import BrowserFrame from '../../placeholders/BrowserFrame';
|
||||||
|
import Rectangle from '../../placeholders/Rectangle';
|
||||||
|
import Triangle from '../../placeholders/Triangle';
|
||||||
|
import SampleCode from '../../SampleCode';
|
||||||
|
|
||||||
|
const Details = () => {
|
||||||
|
const [activeItem, setActiveItem] = useState(-1);
|
||||||
|
|
||||||
|
const Item = ({ index, title, children }) => {
|
||||||
|
const isOpened = (index === activeItem);
|
||||||
|
const click = () => setActiveItem(isOpened ? -1 : index);
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<div
|
||||||
|
className="flex items-center justify-between pointer mv3"
|
||||||
|
onClick={click}
|
||||||
|
>
|
||||||
|
{title}
|
||||||
|
<Triangle size={8} corner={isOpened ? 't' : 'b'} />
|
||||||
|
</div>
|
||||||
|
{isOpened && children}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<DetailsLayout title="Questions and answers">
|
||||||
|
<BrowserFrame
|
||||||
|
content={
|
||||||
|
<div className="h-100 flex flex-column items-center justify-center">
|
||||||
|
<div className="w-60">
|
||||||
|
<div className="mb3 bt bb b--black-30">
|
||||||
|
<Item
|
||||||
|
index={0}
|
||||||
|
title={<div className="w-40"><Rectangle /></div>}
|
||||||
|
>
|
||||||
|
<div className="mb3"><Block numberOfBlocks={10} /></div>
|
||||||
|
</Item>
|
||||||
|
</div>
|
||||||
|
<div className="mb3 bb b--black-30">
|
||||||
|
<Item
|
||||||
|
index={1}
|
||||||
|
title={<div className="w-80"><Rectangle /></div>}
|
||||||
|
>
|
||||||
|
<div className="mb3"><Block numberOfBlocks={15} /></div>
|
||||||
|
</Item>
|
||||||
|
</div>
|
||||||
|
<div className="bb b--black-30">
|
||||||
|
<Item
|
||||||
|
index={2}
|
||||||
|
title={<div className="w-60"><Rectangle /></div>}
|
||||||
|
>
|
||||||
|
<div className="mb3"><Block numberOfBlocks={10} /></div>
|
||||||
|
</Item>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
source={
|
||||||
|
<SampleCode
|
||||||
|
lang="html"
|
||||||
|
code={`
|
||||||
|
<!-- Each question and answer item -->
|
||||||
|
<div style="
|
||||||
|
border-bottom: 1px solid rgba(0, 0, 0, 0.3);
|
||||||
|
">
|
||||||
|
<!-- Heading -->
|
||||||
|
<div style="
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
">
|
||||||
|
<!-- Question -->
|
||||||
|
...
|
||||||
|
|
||||||
|
<!-- The toggle icon sticks to the right -->
|
||||||
|
...
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Answer -->
|
||||||
|
</div>
|
||||||
|
`}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</DetailsLayout>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Details;
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|||||||
|
|
||||||
import random from '../helpers/random';
|
import random from '../helpers/random';
|
||||||
|
|
||||||
const Block = ({ justify = 'start', numberOfBlocks }) => {
|
const Block = ({ justify = 'start', numberOfBlocks = 1, blockHeight = 4 }) => {
|
||||||
return (
|
return (
|
||||||
<div className={`flex flex-wrap w-100 justify-${justify}`}>
|
<div className={`flex flex-wrap w-100 justify-${justify}`}>
|
||||||
{
|
{
|
||||||
@@ -10,7 +10,7 @@ const Block = ({ justify = 'start', numberOfBlocks }) => {
|
|||||||
const s = random(1, 5);
|
const s = random(1, 5);
|
||||||
return (
|
return (
|
||||||
<div key={i} className={`mr2 mb2 w-${s * 10}`}>
|
<div key={i} className={`mr2 mb2 w-${s * 10}`}>
|
||||||
<div className="w-100 bg-black-30 br-pill" style={{ height: '8px' }} />
|
<div className="w-100 bg-black-30 br-pill" style={{ height: `${blockHeight}px` }} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
|
@@ -4,6 +4,16 @@ const Triangle = ({ size = 16, corner = 'tl' }) => {
|
|||||||
let bw = '';
|
let bw = '';
|
||||||
let bc = '';
|
let bc = '';
|
||||||
switch (corner) {
|
switch (corner) {
|
||||||
|
case 't':
|
||||||
|
bw = `0 ${size}px ${size}px ${size}px`;
|
||||||
|
bc = 'transparent transparent rgba(0, 0, 0, .3) transparent';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'b':
|
||||||
|
bw = `${size}px ${size}px 0 ${size}px`;
|
||||||
|
bc = 'rgba(0, 0, 0, .3) transparent transparent transparent';
|
||||||
|
break;
|
||||||
|
|
||||||
case 'tr':
|
case 'tr':
|
||||||
bw = `0 ${size}px ${size}px 0`;
|
bw = `0 ${size}px ${size}px 0`;
|
||||||
bc = 'transparent rgba(0, 0, 0, .3) transparent transparent';
|
bc = 'transparent rgba(0, 0, 0, .3) transparent transparent';
|
||||||
|
Reference in New Issue
Block a user