From 65eec005cb1c9153b9c2451f2528300634fab176 Mon Sep 17 00:00:00 2001 From: Phuoc Nguyen Date: Tue, 30 Mar 2021 15:39:49 +0700 Subject: [PATCH] Tweak the pattern page --- client/helpers/randomFromArray.ts | 4 ++- client/index.css | 9 ++++--- client/layouts/DetailsLayout.tsx | 45 +++++++++++++++---------------- client/pages/ExplorePage.tsx | 4 +-- 4 files changed, 31 insertions(+), 31 deletions(-) diff --git a/client/helpers/randomFromArray.ts b/client/helpers/randomFromArray.ts index 6b162fd..97a484e 100644 --- a/client/helpers/randomFromArray.ts +++ b/client/helpers/randomFromArray.ts @@ -3,6 +3,8 @@ * (c) 2019 - 2020 Nguyen Huu Phuoc */ -const randomFromArray = (array: number[]) => array[Math.floor(Math.random() * array.length)]; +function randomFromArray(array: T[]): T { + return array[Math.floor(Math.random() * array.length)]; +}; export default randomFromArray; diff --git a/client/index.css b/client/index.css index 47f2f2d..ccfe438 100644 --- a/client/index.css +++ b/client/index.css @@ -30,6 +30,7 @@ code { } .content { display: flex; + margin: 1rem 0; } .main { flex: 1; @@ -60,7 +61,7 @@ code { object-fit: cover; width: 24rem; } -.hreo__heading { +.hero__heading { color: var(--text-color); font-size: 3rem; margin: 2rem 0; @@ -78,18 +79,18 @@ code { @media (min-width: 640px) { .sidebar { display: block; - flex: 0 0 10rem; + flex: 0 0 8rem; margin-left: 0.5rem; } } @media (min-width: 768px) { .sidebar { - flex-basis: 12rem; + flex-basis: 10rem; } } @media (min-width: 1024px) { .sidebar { - flex-basis: 16rem; + flex-basis: 12rem; margin-left: 1rem; } } \ No newline at end of file diff --git a/client/layouts/DetailsLayout.tsx b/client/layouts/DetailsLayout.tsx index db44e5b..0075205 100644 --- a/client/layouts/DetailsLayout.tsx +++ b/client/layouts/DetailsLayout.tsx @@ -4,11 +4,13 @@ */ import React from 'react'; -import { Link } from 'react-router-dom'; import Ad from '../components/Ad'; import useDocumentTitle from '../hooks/useDocumentTitle'; import Layout from './Layout'; +import Product from '../components/Product'; +import { ProductList } from '../constants/ProductList'; +import randomFromArray from '../helpers/randomFromArray'; interface DetailsLayoutProps { title: string; @@ -17,32 +19,27 @@ interface DetailsLayoutProps { const DetailsLayout: React.FC = ({ title, children }) => { useDocumentTitle(`CSS Layout ∙ ${title}`); + const product = randomFromArray(ProductList); + return ( -
- - Home - - / - - Explore - - / -

{title}

+
+
+

{title}

+
-
- {children} - +
+
+
+ {children} +
+
+
+ + +
+
+
); diff --git a/client/pages/ExplorePage.tsx b/client/pages/ExplorePage.tsx index d84296a..318b0c8 100644 --- a/client/pages/ExplorePage.tsx +++ b/client/pages/ExplorePage.tsx @@ -28,14 +28,14 @@ const ExplorePage = () => {
-

Collection of {numPatterns} patterns

+

Collection of {numPatterns} patterns

Covers are made with CSS only. Inspect them!

-
+