-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6ac4be7
commit 2e5edb5
Showing
4 changed files
with
84 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<form className="black-80 w-100 w-50-l center"> | ||
<div> | ||
<input | ||
className="input-reset f2 f1-ns ba bw2 br3 b--silver-80 bg-white pa2 mb2 db w-100 black fw6 tc" | ||
maxLength="8" | ||
type="text" | ||
placeholder="1234 BCD" | ||
value={value} | ||
onChange={this.handleChange} | ||
/> | ||
</div> | ||
<div className="flex flex-wrap justify-between mt4 mb2 pb4"> | ||
<Check label="isValid" check={isValidVal} /> | ||
</div> | ||
</form> | ||
); | ||
} | ||
return ( | ||
<form className="black-80 w-100 w-50-l center"> | ||
<div> | ||
<input | ||
className="input-reset f2 f1-ns ba bw2 br3 b--silver-80 bg-white pa2 mb2 db w-100 black fw6 tc" | ||
maxLength={10} | ||
type="text" | ||
placeholder="1234 BCD" | ||
value={value} | ||
onChange={handleChange} | ||
/> | ||
</div> | ||
<div className="flex flex-wrap flex-column justify-between mt4 mb2 pb4"> | ||
<Check label="isValid" check={isValid(value)} /> | ||
<Check label="isOld" check={isOld(value)} /> | ||
<Check label="isSpecial" check={isSpecial(value)} /> | ||
</div> | ||
<dl className="f6 lh-title mv2"> | ||
<dt className="dib b">Counter</dt> | ||
<dd className="dib ml2 white">{getCounter(value) || "-"}</dd> | ||
</dl> | ||
<dl className="f6 lh-title mv2"> | ||
<dt className="dib b">Number</dt> | ||
<dd className="dib ml2 white">{getNumber(value) || "-"}</dd> | ||
</dl> | ||
<dl className="f6 lh-title mv2"> | ||
<dt className="dib b">Province name</dt> | ||
<dd className="dib ml2 white">{getProvinceName(value) || "-"}</dd> | ||
</dl> | ||
<dl className="f6 lh-title mv2"> | ||
<dt className="dib b">Province code</dt> | ||
<dd className="dib ml2 white">{getProvinceCode(value) || "-"}</dd> | ||
</dl> | ||
<dl className="f6 lh-title mv2"> | ||
<dt className="dib b">Special name</dt> | ||
<dd className="dib ml2 white">{getSpecialName(value) || "-"}</dd> | ||
</dl> | ||
<dl className="f6 lh-title mv2"> | ||
<dt className="dib b">Special code</dt> | ||
<dd className="dib ml2 white">{getSpecialCode(value) || "-"}</dd> | ||
</dl> | ||
</form> | ||
); | ||
} | ||
|
||
export { App }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
|
||
html, | ||
body { | ||
background: #11ffff; | ||
background: orangered; | ||
height: 100%; | ||
} | ||
|
||
|