Skip to content

Commit e42b6ad

Browse files
authored
15: code cleanup (#16)
1 parent 1391d2d commit e42b6ad

File tree

3 files changed

+6
-22
lines changed

3 files changed

+6
-22
lines changed

demo/index.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<!DOCTYPE html>
22
<html lang="en">
3+
34
<head>
45
<meta charset="UTF-8">
56
<title>Smart Time Input</title>
@@ -34,9 +35,11 @@
3435
</style>
3536

3637
</head>
38+
3739
<body>
3840
<h1>Smart Time Input</h1>
3941
<div id="myApp"></div>
4042
<script src="demo.js" type="text/javascript"></script>
4143
</body>
42-
</html>
44+
45+
</html>

demo/index.jsx

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,15 @@ import React from 'react'
33
import { StrictMode } from 'react';
44
import { createRoot } from 'react-dom/client';
55

6-
// import { SmartTimeInput } from './../src/smart-time-input.tsx'
76
import { SmartTimeInput } from './../dist/smart-time-input.js'
87

98
const InputWrapper = (props) => {
10-
console.log("hello: " + props.helpText);
11-
// const onTimeChangeHandler = (val) => {
12-
// if (val.length === 5) {
13-
// }
14-
// }
159

1610
return (
1711
<SmartTimeInput
1812
initTime={props.init}
1913
placeholder={props.helpText}
2014
className='input'
21-
// onTimeChange={onTimeChangeHandler}
2215
/>
2316
);
2417

@@ -27,8 +20,8 @@ const InputWrapper = (props) => {
2720
function App() {
2821
return (
2922
<div>
30-
<InputWrapper init="12:34"/>
31-
<InputWrapper helpText="HH:mm"/>
23+
<InputWrapper init="12:34" />
24+
<InputWrapper helpText="HH:mm" />
3225
<InputWrapper />
3326
</div>
3427
);

src/smart-time-input.tsx

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,18 @@ import React, { useState } from 'react'
22
import { is24hTime, addColonToTime, completeTime } from './utils';
33

44
interface SmartTimeInputProps extends React.PropsWithChildren {
5-
id?: string;
65
initTime?: string;
7-
disabled?: boolean;
8-
placeholder?: string;
96
className?: string;
107
divClassName?: string;
11-
name?: string;
128
ref?: React.Ref<HTMLInputElement>;
139
onFocusHandler?: (e: React.FocusEvent<HTMLInputElement>) => void;
1410
onTimeChange?: (val: string) => void;
1511
onBlurHandlerSuper?: (e: React.FocusEvent<HTMLInputElement>) => void;
1612
}
1713
const SmartTimeInput: React.FC<SmartTimeInputProps> = ({
18-
id,
1914
initTime,
20-
disabled,
21-
placeholder,
2215
className,
2316
divClassName,
24-
name,
2517
ref,
2618
onFocusHandler,
2719
onTimeChange,
@@ -57,12 +49,8 @@ const SmartTimeInput: React.FC<SmartTimeInputProps> = ({
5749
return (
5850
<div className={divClassName}>
5951
<input
60-
id={id}
61-
name={name}
6252
className={className}
6353
type={'text'}
64-
disabled={disabled}
65-
placeholder={placeholder}
6654
value={time}
6755
onChange={(e) => handleTimeChange(e.target.value)}
6856
onBlur={(e) => autoExtendTime(e)}

0 commit comments

Comments
 (0)