From 10b00cf135a2ebedc9631df53a030b4557c9956c Mon Sep 17 00:00:00 2001 From: Phuoc Nguyen Date: Sat, 23 Nov 2019 21:00:03 +0700 Subject: [PATCH] Add questions and answers --- client/App.jsx | 1 + client/Home.jsx | 1 + .../patterns/questions-and-answers/Cover.jsx | 33 +++++++ .../questions-and-answers/Details.jsx | 94 +++++++++++++++++++ client/placeholders/Block.jsx | 4 +- client/placeholders/Triangle.jsx | 10 ++ 6 files changed, 141 insertions(+), 2 deletions(-) create mode 100644 client/patterns/questions-and-answers/Cover.jsx create mode 100644 client/patterns/questions-and-answers/Details.jsx diff --git a/client/App.jsx b/client/App.jsx index ac33b71..4d506d6 100644 --- a/client/App.jsx +++ b/client/App.jsx @@ -29,6 +29,7 @@ const App = () => { + diff --git a/client/Home.jsx b/client/Home.jsx index d711204..716ee20 100644 --- a/client/Home.jsx +++ b/client/Home.jsx @@ -74,6 +74,7 @@ const Home = () => { + diff --git a/client/patterns/questions-and-answers/Cover.jsx b/client/patterns/questions-and-answers/Cover.jsx new file mode 100644 index 0000000..de4f8ab --- /dev/null +++ b/client/patterns/questions-and-answers/Cover.jsx @@ -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 ( + +
+
+
+
+ +
+
+
+
+ +
+
+
+
+
+
+
+
+ + ); +}; + +export default Cover; diff --git a/client/patterns/questions-and-answers/Details.jsx b/client/patterns/questions-and-answers/Details.jsx new file mode 100644 index 0000000..e4fc8ec --- /dev/null +++ b/client/patterns/questions-and-answers/Details.jsx @@ -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 ( +
+
+ {title} + +
+ {isOpened && children} +
+ ); + }; + + return ( + + +
+
+
} + > +
+ +
+
+
} + > +
+ + +
+
} + > +
+ + + + + } + source={ + +
+ +
+ + ... + + + ... +
+ + +
+`} +/> + } + /> +
+ ); +}; + +export default Details; diff --git a/client/placeholders/Block.jsx b/client/placeholders/Block.jsx index d113436..7cdb6ba 100644 --- a/client/placeholders/Block.jsx +++ b/client/placeholders/Block.jsx @@ -2,7 +2,7 @@ import React from 'react'; import random from '../helpers/random'; -const Block = ({ justify = 'start', numberOfBlocks }) => { +const Block = ({ justify = 'start', numberOfBlocks = 1, blockHeight = 4 }) => { return (
{ @@ -10,7 +10,7 @@ const Block = ({ justify = 'start', numberOfBlocks }) => { const s = random(1, 5); return (
-
+
); }) diff --git a/client/placeholders/Triangle.jsx b/client/placeholders/Triangle.jsx index 2ec78aa..1cb1d09 100644 --- a/client/placeholders/Triangle.jsx +++ b/client/placeholders/Triangle.jsx @@ -4,6 +4,16 @@ const Triangle = ({ size = 16, corner = 'tl' }) => { let bw = ''; let bc = ''; 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': bw = `0 ${size}px ${size}px 0`; bc = 'transparent rgba(0, 0, 0, .3) transparent transparent';