From ede365f6e2495d903ec9f4638cef47b804d8b51f Mon Sep 17 00:00:00 2001 From: Phuoc Nguyen Date: Thu, 28 Nov 2019 08:38:55 +0700 Subject: [PATCH 1/4] Prefix url with /pattern --- client/App.tsx | 86 ++++++++++++++++---------------- client/Explore.tsx | 1 + client/Home.tsx | 3 +- client/components/CoverCard.tsx | 2 +- client/layouts/DetailsLayout.tsx | 2 +- public/sitemap.xml | 81 +++++++++++++++--------------- 6 files changed, 90 insertions(+), 85 deletions(-) diff --git a/client/App.tsx b/client/App.tsx index bb5912c..355f648 100644 --- a/client/App.tsx +++ b/client/App.tsx @@ -13,56 +13,58 @@ const App = () => { - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + - - - + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + - + ); diff --git a/client/Explore.tsx b/client/Explore.tsx index 51a6ace..99bc5b5 100644 --- a/client/Explore.tsx +++ b/client/Explore.tsx @@ -96,6 +96,7 @@ const Home = () => { + diff --git a/client/Home.tsx b/client/Home.tsx index f7abc74..8cddd17 100644 --- a/client/Home.tsx +++ b/client/Home.tsx @@ -169,7 +169,7 @@ const Home = () => { 50+ patterns { + diff --git a/client/components/CoverCard.tsx b/client/components/CoverCard.tsx index aa3a81c..bacd873 100644 --- a/client/components/CoverCard.tsx +++ b/client/components/CoverCard.tsx @@ -12,7 +12,7 @@ interface CoverCardProps { const CoverCard: React.FC = ({ pattern }) => { return ( = ({ title, children }) => {
~
- https://csslayout.io/holy-grail - https://csslayout.io/sidebar - https://csslayout.io/split-screen - https://csslayout.io/sticky-footer - https://csslayout.io/sticky-header - https://csslayout.io/badge - https://csslayout.io/breadcrumb - https://csslayout.io/button-with-icon - https://csslayout.io/card - https://csslayout.io/centering - https://csslayout.io/docked-at-corner - https://csslayout.io/dot-navigation - https://csslayout.io/drop-area - https://csslayout.io/feature-list - https://csslayout.io/fixed-at-corner - https://csslayout.io/input-addon - https://csslayout.io/media-object - https://csslayout.io/menu - https://csslayout.io/modal - https://csslayout.io/notification - https://csslayout.io/pagination - https://csslayout.io/previous-next-buttons - https://csslayout.io/pricing-table - https://csslayout.io/progress-bar - https://csslayout.io/property-list - https://csslayout.io/questions-and-answers - https://csslayout.io/radio-switch - https://csslayout.io/rating - https://csslayout.io/same-height-columns - https://csslayout.io/search-box - https://csslayout.io/separator - https://csslayout.io/simple-grid - https://csslayout.io/slider - https://csslayout.io/spin-button - https://csslayout.io/split-navigation - https://csslayout.io/stepper-input - https://csslayout.io/switch - https://csslayout.io/tab - https://csslayout.io/toggle-password-visibility - https://csslayout.io/wizard + https://csslayout.io/patterns + https://csslayout.io/patterns/holy-grail + https://csslayout.io/patterns/sidebar + https://csslayout.io/patterns/split-screen + https://csslayout.io/patterns/sticky-footer + https://csslayout.io/patterns/sticky-header + https://csslayout.io/patterns/badge + https://csslayout.io/patterns/breadcrumb + https://csslayout.io/patterns/button-with-icon + https://csslayout.io/patterns/card + https://csslayout.io/patterns/centering + https://csslayout.io/patterns/docked-at-corner + https://csslayout.io/patterns/dot-navigation + https://csslayout.io/patterns/drop-area + https://csslayout.io/patterns/feature-list + https://csslayout.io/patterns/fixed-at-corner + https://csslayout.io/patterns/input-addon + https://csslayout.io/patterns/media-object + https://csslayout.io/patterns/menu + https://csslayout.io/patterns/modal + https://csslayout.io/patterns/notification + https://csslayout.io/patterns/pagination + https://csslayout.io/patterns/previous-next-buttons + https://csslayout.io/patterns/pricing-table + https://csslayout.io/patterns/progress-bar + https://csslayout.io/patterns/property-list + https://csslayout.io/patterns/questions-and-answers + https://csslayout.io/patterns/radio-switch + https://csslayout.io/patterns/rating + https://csslayout.io/patterns/same-height-columns + https://csslayout.io/patterns/search-box + https://csslayout.io/patterns/separator + https://csslayout.io/patterns/simple-grid + https://csslayout.io/patterns/slider + https://csslayout.io/patterns/spin-button + https://csslayout.io/patterns/split-navigation + https://csslayout.io/patterns/stepper-input + https://csslayout.io/patterns/switch + https://csslayout.io/patterns/tab + https://csslayout.io/patterns/toggle-password-visibility + https://csslayout.io/patterns/wizard \ No newline at end of file From 9062636d38c33b8f25d658cf932155d6e52c77ec Mon Sep 17 00:00:00 2001 From: Phuoc Nguyen Date: Thu, 28 Nov 2019 09:30:01 +0700 Subject: [PATCH 2/4] Add floating label --- client/App.tsx | 36 +++++-- client/constants/Pattern.ts | 1 + client/patterns/floating-label/Cover.tsx | 46 +++++++++ client/patterns/floating-label/Details.tsx | 99 +++++++++++++++++++ .../floating-label/floating-label.css | 9 ++ 5 files changed, 182 insertions(+), 9 deletions(-) create mode 100644 client/patterns/floating-label/Cover.tsx create mode 100644 client/patterns/floating-label/Details.tsx create mode 100644 client/patterns/floating-label/floating-label.css diff --git a/client/App.tsx b/client/App.tsx index 355f648..31087dd 100644 --- a/client/App.tsx +++ b/client/App.tsx @@ -15,15 +15,33 @@ const App = () => { - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/client/constants/Pattern.ts b/client/constants/Pattern.ts index 921e78e..9d18a8b 100644 --- a/client/constants/Pattern.ts +++ b/client/constants/Pattern.ts @@ -10,6 +10,7 @@ enum Pattern { DropArea = 'Drop area', FeatureList = 'Feature list', FixedAtCorner = 'Fixed at corner', + FloatingLabel = 'Floating label', HolyGrail = 'Holy grail', InputAddOn = 'Input add-on', MediaObject = 'Media object', diff --git a/client/patterns/floating-label/Cover.tsx b/client/patterns/floating-label/Cover.tsx new file mode 100644 index 0000000..4fbb19d --- /dev/null +++ b/client/patterns/floating-label/Cover.tsx @@ -0,0 +1,46 @@ +import React from 'react'; + +import Frame from '../../placeholders/Frame'; +import Rectangle from '../../placeholders/Rectangle'; + +const Cover: React.FC<{}> = () => { + return ( + +
+
+
+
+
+ + ); +}; + +export default Cover; diff --git a/client/patterns/floating-label/Details.tsx b/client/patterns/floating-label/Details.tsx new file mode 100644 index 0000000..683f53d --- /dev/null +++ b/client/patterns/floating-label/Details.tsx @@ -0,0 +1,99 @@ +import React from 'react'; + +import './floating-label.css'; + +import DetailsLayout from '../../layouts/DetailsLayout'; +import BrowserFrame from '../../placeholders/BrowserFrame'; + +const Details: React.FC<{}> = () => { + return ( + +
+
+ Type something in the input to see how the label is shown up. +
+ +
+ + +
+
+ )} + source={` + + +
+ + + + + +
+`} + /> +
+ + ); +}; + +export default Details; diff --git a/client/patterns/floating-label/floating-label.css b/client/patterns/floating-label/floating-label.css new file mode 100644 index 0000000..c07ed08 --- /dev/null +++ b/client/patterns/floating-label/floating-label.css @@ -0,0 +1,9 @@ +.floating-container label { + opacity: 0; +} + +.floating-container input:not(:placeholder-shown) + label { + background: #FFF; + transform: translate(0, -50%); + opacity: 1; +} From fbed770a2970bc03ca48b90fae79c81ca4254902 Mon Sep 17 00:00:00 2001 From: Phuoc Nguyen Date: Thu, 28 Nov 2019 12:14:36 +0700 Subject: [PATCH 3/4] Load the pattern page from hash --- client/App.tsx | 75 ++----------------- client/PatternPage.tsx | 24 ++++++ client/constants/Pattern.ts | 2 +- client/loaders/DetailsLoader.tsx | 4 +- .../{input-add-on => input-addon}/Cover.tsx | 0 .../{input-add-on => input-addon}/Details.tsx | 0 6 files changed, 31 insertions(+), 74 deletions(-) create mode 100644 client/PatternPage.tsx rename client/patterns/{input-add-on => input-addon}/Cover.tsx (100%) rename client/patterns/{input-add-on => input-addon}/Details.tsx (100%) diff --git a/client/App.tsx b/client/App.tsx index 31087dd..d540590 100644 --- a/client/App.tsx +++ b/client/App.tsx @@ -3,10 +3,9 @@ import { BrowserRouter as Router, Route, Switch as RouteSwitch } from 'react-rou import './index.css'; -import Pattern from './constants/Pattern'; import Explore from './Explore'; import Home from './Home'; -import DetailsLoader from './loaders/DetailsLoader'; +import PatternPage from './PatternPage'; const App = () => { return ( @@ -15,74 +14,10 @@ const App = () => { - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + } // tslint:disable-line + /> ); diff --git a/client/PatternPage.tsx b/client/PatternPage.tsx new file mode 100644 index 0000000..0ecda90 --- /dev/null +++ b/client/PatternPage.tsx @@ -0,0 +1,24 @@ +import React from 'react'; + +import Pattern from './constants/Pattern'; +import DetailsLoader from './loaders/DetailsLoader'; + +interface PatternPageProps { + pattern: string; +} + +const capitalizeFirstLetter = (s: string) => `${s.charAt(0).toUpperCase()}${s.slice(1)}`; + +const PatternPage: React.FC = ({ pattern }) => { + const name = pattern.split('-').map((s) => capitalizeFirstLetter(s)).join(''); + const patterns = Object.keys(Pattern); + + return ( + patterns.indexOf(name) === -1 + // TODO: Render 404 + ?
404
+ : + ); +}; + +export default PatternPage; diff --git a/client/constants/Pattern.ts b/client/constants/Pattern.ts index 9d18a8b..bc567e3 100644 --- a/client/constants/Pattern.ts +++ b/client/constants/Pattern.ts @@ -12,7 +12,7 @@ enum Pattern { FixedAtCorner = 'Fixed at corner', FloatingLabel = 'Floating label', HolyGrail = 'Holy grail', - InputAddOn = 'Input add-on', + InputAddOn = 'Input addon', MediaObject = 'Media object', Menu = 'Menu', Modal = 'Modal', diff --git a/client/loaders/DetailsLoader.tsx b/client/loaders/DetailsLoader.tsx index be36636..2ad34c6 100644 --- a/client/loaders/DetailsLoader.tsx +++ b/client/loaders/DetailsLoader.tsx @@ -3,10 +3,8 @@ import React from 'react'; import './spinner.css'; -import Pattern from '../constants/Pattern'; - interface DetailsLoaderProps { - pattern: Pattern; + pattern: string; } const slug = (item: string) => item.toLowerCase().split(' ').join('-'); diff --git a/client/patterns/input-add-on/Cover.tsx b/client/patterns/input-addon/Cover.tsx similarity index 100% rename from client/patterns/input-add-on/Cover.tsx rename to client/patterns/input-addon/Cover.tsx diff --git a/client/patterns/input-add-on/Details.tsx b/client/patterns/input-addon/Details.tsx similarity index 100% rename from client/patterns/input-add-on/Details.tsx rename to client/patterns/input-addon/Details.tsx From 97acac4e45da94a992537933745067df1a6efe82 Mon Sep 17 00:00:00 2001 From: Phuoc Nguyen Date: Thu, 28 Nov 2019 12:17:41 +0700 Subject: [PATCH 4/4] Move pages to /pages --- client/App.tsx | 11 +++++------ client/{Explore.tsx => pages/ExplorePage.tsx} | 14 +++++++------- client/{Home.tsx => pages/HomePage.tsx} | 12 ++++++------ client/{ => pages}/PatternPage.tsx | 4 ++-- client/{ => pages}/home.css | 0 5 files changed, 20 insertions(+), 21 deletions(-) rename client/{Explore.tsx => pages/ExplorePage.tsx} (94%) rename client/{Home.tsx => pages/HomePage.tsx} (98%) rename client/{ => pages}/PatternPage.tsx (85%) rename client/{ => pages}/home.css (100%) diff --git a/client/App.tsx b/client/App.tsx index d540590..0353de5 100644 --- a/client/App.tsx +++ b/client/App.tsx @@ -3,17 +3,16 @@ import { BrowserRouter as Router, Route, Switch as RouteSwitch } from 'react-rou import './index.css'; -import Explore from './Explore'; -import Home from './Home'; -import PatternPage from './PatternPage'; +import ExplorePage from './pages/ExplorePage'; +import HomePage from './pages/HomePage'; +import PatternPage from './pages/PatternPage'; const App = () => { return ( - - - + + } // tslint:disable-line diff --git a/client/Explore.tsx b/client/pages/ExplorePage.tsx similarity index 94% rename from client/Explore.tsx rename to client/pages/ExplorePage.tsx index 99bc5b5..57bb5cf 100644 --- a/client/Explore.tsx +++ b/client/pages/ExplorePage.tsx @@ -1,13 +1,13 @@ import React from 'react'; import { Link } from 'react-router-dom'; -import CoverCard from './components/CoverCard'; -import Heading from './components/Heading'; -import Pattern from './constants/Pattern'; -import useDocumentTitle from './hooks/useDocumentTitle'; -import Layout from './layouts/Layout'; +import CoverCard from '../components/CoverCard'; +import Heading from '../components/Heading'; +import Pattern from '../constants/Pattern'; +import useDocumentTitle from '../hooks/useDocumentTitle'; +import Layout from '../layouts/Layout'; -const Home = () => { +const ExplorePage = () => { useDocumentTitle('CSS Layout ∙ Explore'); return ( @@ -129,4 +129,4 @@ const Home = () => { ); }; -export default Home; +export default ExplorePage; diff --git a/client/Home.tsx b/client/pages/HomePage.tsx similarity index 98% rename from client/Home.tsx rename to client/pages/HomePage.tsx index 8cddd17..3ffb173 100644 --- a/client/Home.tsx +++ b/client/pages/HomePage.tsx @@ -3,12 +3,12 @@ import { Link } from 'react-router-dom'; import './home.css'; -import CoverCard from './components/CoverCard'; -import Pattern from './constants/Pattern'; -import useDocumentTitle from './hooks/useDocumentTitle'; -import Layout from './layouts/Layout'; +import CoverCard from '../components/CoverCard'; +import Pattern from '../constants/Pattern'; +import useDocumentTitle from '../hooks/useDocumentTitle'; +import Layout from '../layouts/Layout'; -const Home = () => { +const HomePage = () => { useDocumentTitle('CSS Layout'); return ( @@ -241,4 +241,4 @@ const Home = () => { ); }; -export default Home; +export default HomePage; diff --git a/client/PatternPage.tsx b/client/pages/PatternPage.tsx similarity index 85% rename from client/PatternPage.tsx rename to client/pages/PatternPage.tsx index 0ecda90..42d999f 100644 --- a/client/PatternPage.tsx +++ b/client/pages/PatternPage.tsx @@ -1,7 +1,7 @@ import React from 'react'; -import Pattern from './constants/Pattern'; -import DetailsLoader from './loaders/DetailsLoader'; +import Pattern from '../constants/Pattern'; +import DetailsLoader from '../loaders/DetailsLoader'; interface PatternPageProps { pattern: string; diff --git a/client/home.css b/client/pages/home.css similarity index 100% rename from client/home.css rename to client/pages/home.css