From 9062636d38c33b8f25d658cf932155d6e52c77ec Mon Sep 17 00:00:00 2001 From: Phuoc Nguyen Date: Thu, 28 Nov 2019 09:30:01 +0700 Subject: [PATCH] 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; +}