mirror of
https://github.com/phuoc-ng/csslayout.git
synced 2025-08-21 13:21:59 +02:00
Tweak the pattern page
This commit is contained in:
@@ -3,6 +3,8 @@
|
|||||||
* (c) 2019 - 2020 Nguyen Huu Phuoc <https://twitter.com/nghuuphuoc>
|
* (c) 2019 - 2020 Nguyen Huu Phuoc <https://twitter.com/nghuuphuoc>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const randomFromArray = (array: number[]) => array[Math.floor(Math.random() * array.length)];
|
function randomFromArray<T>(array: T[]): T {
|
||||||
|
return array[Math.floor(Math.random() * array.length)];
|
||||||
|
};
|
||||||
|
|
||||||
export default randomFromArray;
|
export default randomFromArray;
|
||||||
|
@@ -30,6 +30,7 @@ code {
|
|||||||
}
|
}
|
||||||
.content {
|
.content {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
margin: 1rem 0;
|
||||||
}
|
}
|
||||||
.main {
|
.main {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
@@ -60,7 +61,7 @@ code {
|
|||||||
object-fit: cover;
|
object-fit: cover;
|
||||||
width: 24rem;
|
width: 24rem;
|
||||||
}
|
}
|
||||||
.hreo__heading {
|
.hero__heading {
|
||||||
color: var(--text-color);
|
color: var(--text-color);
|
||||||
font-size: 3rem;
|
font-size: 3rem;
|
||||||
margin: 2rem 0;
|
margin: 2rem 0;
|
||||||
@@ -78,18 +79,18 @@ code {
|
|||||||
@media (min-width: 640px) {
|
@media (min-width: 640px) {
|
||||||
.sidebar {
|
.sidebar {
|
||||||
display: block;
|
display: block;
|
||||||
flex: 0 0 10rem;
|
flex: 0 0 8rem;
|
||||||
margin-left: 0.5rem;
|
margin-left: 0.5rem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@media (min-width: 768px) {
|
@media (min-width: 768px) {
|
||||||
.sidebar {
|
.sidebar {
|
||||||
flex-basis: 12rem;
|
flex-basis: 10rem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@media (min-width: 1024px) {
|
@media (min-width: 1024px) {
|
||||||
.sidebar {
|
.sidebar {
|
||||||
flex-basis: 16rem;
|
flex-basis: 12rem;
|
||||||
margin-left: 1rem;
|
margin-left: 1rem;
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -4,11 +4,13 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Link } from 'react-router-dom';
|
|
||||||
|
|
||||||
import Ad from '../components/Ad';
|
import Ad from '../components/Ad';
|
||||||
import useDocumentTitle from '../hooks/useDocumentTitle';
|
import useDocumentTitle from '../hooks/useDocumentTitle';
|
||||||
import Layout from './Layout';
|
import Layout from './Layout';
|
||||||
|
import Product from '../components/Product';
|
||||||
|
import { ProductList } from '../constants/ProductList';
|
||||||
|
import randomFromArray from '../helpers/randomFromArray';
|
||||||
|
|
||||||
interface DetailsLayoutProps {
|
interface DetailsLayoutProps {
|
||||||
title: string;
|
title: string;
|
||||||
@@ -17,32 +19,27 @@ interface DetailsLayoutProps {
|
|||||||
const DetailsLayout: React.FC<DetailsLayoutProps> = ({ title, children }) => {
|
const DetailsLayout: React.FC<DetailsLayoutProps> = ({ title, children }) => {
|
||||||
useDocumentTitle(`CSS Layout ∙ ${title}`);
|
useDocumentTitle(`CSS Layout ∙ ${title}`);
|
||||||
|
|
||||||
|
const product = randomFromArray(ProductList);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Layout>
|
<Layout>
|
||||||
<div className='flex sm:text-2xl p-4 xl:pl-0'>
|
<div className="hero">
|
||||||
<Link
|
<div className="container">
|
||||||
to="/"
|
<h1 className="hero__heading">{title}</h1>
|
||||||
style={{
|
|
||||||
textDecoration: 'none',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Home
|
|
||||||
</Link>
|
|
||||||
<span className='mx-2'>/</span>
|
|
||||||
<Link
|
|
||||||
to="/patterns"
|
|
||||||
style={{
|
|
||||||
textDecoration: 'none',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Explore
|
|
||||||
</Link>
|
|
||||||
<span className='mx-2'>/</span>
|
|
||||||
<h1>{title}</h1>
|
|
||||||
</div>
|
</div>
|
||||||
<div className='xl:border xl:border-gray-400'>
|
</div>
|
||||||
|
<div className="container">
|
||||||
|
<div className="content">
|
||||||
|
<main className="main">
|
||||||
{children}
|
{children}
|
||||||
|
</main>
|
||||||
|
<div className="sidebar">
|
||||||
|
<div className="sidebar__inner">
|
||||||
<Ad />
|
<Ad />
|
||||||
|
<Product product={product} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Layout>
|
</Layout>
|
||||||
);
|
);
|
||||||
|
@@ -28,14 +28,14 @@ const ExplorePage = () => {
|
|||||||
</Helmet>
|
</Helmet>
|
||||||
<div className="hero">
|
<div className="hero">
|
||||||
<div className="container">
|
<div className="container">
|
||||||
<h1 className="hreo__heading">Collection of {numPatterns} patterns</h1>
|
<h1 className="hero__heading">Collection of {numPatterns} patterns</h1>
|
||||||
<h2 className="hero__subheading">Covers are made with CSS only. Inspect them!</h2>
|
<h2 className="hero__subheading">Covers are made with CSS only. Inspect them!</h2>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="container">
|
<div className="container">
|
||||||
<div className="content">
|
<div className="content">
|
||||||
<main class="main">
|
<main className="main">
|
||||||
<section>
|
<section>
|
||||||
<Heading title="Layout" />
|
<Heading title="Layout" />
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user