From 2e5edb5c9329c6a925edc30b5bad5271e9769e4d Mon Sep 17 00:00:00 2001 From: singuerinc Date: Mon, 25 Feb 2019 22:29:17 +0100 Subject: [PATCH] feat(web): demo page --- web/src/index.html | 16 ++++---- web/src/js/App.tsx | 98 +++++++++++++++++++++++++++----------------- web/src/js/Check.tsx | 22 ++++++---- web/src/main.css | 2 +- 4 files changed, 84 insertions(+), 54 deletions(-) diff --git a/web/src/index.html b/web/src/index.html index c2d8a6b..bd4ce33 100644 --- a/web/src/index.html +++ b/web/src/index.html @@ -3,7 +3,7 @@ - Spanish Car Plate + Spanish Car Plate / validator @@ -20,16 +20,18 @@ -
-

- scp +
+

+ Car Plate

-

- Spanish Car Plate validation +

+ Spanish validator

-

Try it

+

Try it!

diff --git a/web/src/js/App.tsx b/web/src/js/App.tsx index 3b7fd83..5a1a318 100644 --- a/web/src/js/App.tsx +++ b/web/src/js/App.tsx @@ -1,44 +1,68 @@ -import { isValid } from "spanish-car-plate"; import * as React from "react"; +import { useState } from "react"; +import { + isValid, + isOld, + isSpecial, + parse, + getCounter, + getNumber, + getProvinceName, + getProvinceCode, + getSpecialName, + getSpecialCode +} from "spanish-car-plate"; import { Check } from "./Check"; -class App extends React.Component { - state = { - value: "" - }; +export function App() { + const [value, setValue] = useState(""); + const parseResult = parse(value); - constructor(props) { - super(props); - this.handleChange = this.handleChange.bind(this); + function handleChange({ target: { value } }: { target: HTMLInputElement }) { + setValue(value); } - handleChange(event) { - const value: string = event.target.value; - this.setState({ value }); - } - - render() { - const { value } = this.state; - const isValidVal = isValid(value); - - return ( -
-
- -
-
- -
-
- ); - } + return ( +
+
+ +
+
+ + + +
+
+
Counter
+
{getCounter(value) || "-"}
+
+
+
Number
+
{getNumber(value) || "-"}
+
+
+
Province name
+
{getProvinceName(value) || "-"}
+
+
+
Province code
+
{getProvinceCode(value) || "-"}
+
+
+
Special name
+
{getSpecialName(value) || "-"}
+
+
+
Special code
+
{getSpecialCode(value) || "-"}
+
+
+ ); } - -export { App }; diff --git a/web/src/js/Check.tsx b/web/src/js/Check.tsx index da0428a..205a71a 100644 --- a/web/src/js/Check.tsx +++ b/web/src/js/Check.tsx @@ -1,18 +1,22 @@ import * as React from "react"; import * as feather from "feather-icons"; -export const Check = ({ check, label }) => ( +interface IProps { + check: boolean; + label: string; +} + +export const Check = ({ check, label }: IProps) => (
- {!check && ( - - )} - {check && ( - - )} +
{label}
diff --git a/web/src/main.css b/web/src/main.css index 79b3230..f748b6d 100644 --- a/web/src/main.css +++ b/web/src/main.css @@ -3,7 +3,7 @@ html, body { - background: #11ffff; + background: orangered; height: 100%; }