Skip to content

Commit 0dd11b1

Browse files
committed
Make the demo look better
1 parent 111c0ed commit 0dd11b1

File tree

4 files changed

+85
-46
lines changed

4 files changed

+85
-46
lines changed

index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
<head>
44
<meta charset="UTF-8" />
55
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6-
<title>react-autonumeric Demo</title>
6+
<title>React-AutoNumeric Demo</title>
77
</head>
8-
<body>
8+
<body style="max-width: 600px; margin: 0 auto">
99
<div id="root"></div>
1010
<script type="module" src="/src/demo/main.tsx"></script>
1111
</body>

package-lock.json

Lines changed: 31 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
"@types/react-dom": "^18.2.25",
5353
"@vitejs/plugin-react": "^4.2.1",
5454
"@vitest/coverage-v8": "^1.5.0",
55+
"bootstrap": "^5.3.3",
5556
"eslint-plugin-react": "^7.34.1",
5657
"eslint-plugin-react-hooks": "^4.6.0",
5758
"eslint-plugin-react-refresh": "^0.4.6",

src/demo/App.tsx

Lines changed: 51 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
* limitations under the License.
1616
*/
1717

18+
import "bootstrap/dist/css/bootstrap.css";
19+
1820
import AutoNumeric from "autonumeric";
1921
import { AutoNumericInput } from "../lib/AutoNumericInput";
2022
import { useState } from "react";
@@ -23,53 +25,58 @@ export default function App(): JSX.Element {
2325
const [controlledInputState, setControlledInputState] = useState("100");
2426
return (
2527
<>
26-
<label>
27-
Most basic usage
28-
<AutoNumericInput />
29-
</label>
30-
31-
<hr />
32-
33-
<label>
34-
Customize the input
35-
<AutoNumericInput
36-
inputProps={{ defaultValue: "99.99" }}
37-
autoNumericOptions={{ suffixText: "%" }}
38-
/>
39-
</label>
40-
41-
<hr />
28+
<h1>React-AutoNumeric Demo</h1>
29+
<div className="form-group mb-3">
30+
<label>
31+
Most basic usage
32+
<AutoNumericInput inputProps={{ className: "form-control" }} />
33+
</label>
34+
</div>
4235

43-
<label>
44-
Use predefined AutoNumeric options
45-
<AutoNumericInput
46-
inputProps={{ defaultValue: "10000" }}
47-
autoNumericOptions={
48-
AutoNumeric.getPredefinedOptions().commaDecimalCharDotSeparator
49-
}
50-
/>
51-
</label>
36+
<div className="form-group mb-3">
37+
<label>
38+
Customize the input
39+
<AutoNumericInput
40+
inputProps={{ defaultValue: "99.99", className: "form-control" }}
41+
autoNumericOptions={{ suffixText: "%" }}
42+
/>
43+
</label>
44+
</div>
5245

53-
<hr />
46+
<div className="form-group mb-3">
47+
<label>
48+
Use predefined AutoNumeric options
49+
<AutoNumericInput
50+
inputProps={{ defaultValue: "10000", className: "form-control" }}
51+
autoNumericOptions={
52+
AutoNumeric.getPredefinedOptions().commaDecimalCharDotSeparator
53+
}
54+
/>
55+
</label>
56+
</div>
5457

55-
<label>
56-
Interact with AutoNumericInput via a React state
57-
<AutoNumericInput
58-
valueState={{
59-
state: controlledInputState,
60-
stateSetter: setControlledInputState,
61-
}}
62-
/>
63-
<button
64-
onClick={() => {
65-
setControlledInputState(
66-
(Number(controlledInputState) + 1).toString(),
67-
);
68-
}}
69-
>
70-
Add one
71-
</button>
72-
</label>
58+
<div className="form-group mb-3">
59+
<label>
60+
Interact with AutoNumericInput via a React state
61+
<AutoNumericInput
62+
inputProps={{ className: "form-control" }}
63+
valueState={{
64+
state: controlledInputState,
65+
stateSetter: setControlledInputState,
66+
}}
67+
/>
68+
<button
69+
className="btn btn-primary"
70+
onClick={() => {
71+
setControlledInputState(
72+
(Number(controlledInputState) + 1).toString(),
73+
);
74+
}}
75+
>
76+
Add one
77+
</button>
78+
</label>
79+
</div>
7380
</>
7481
);
7582
}

0 commit comments

Comments
 (0)