Skip to content

Commit 16a9026

Browse files
committed
Move private functions down
1 parent a791c0e commit 16a9026

File tree

1 file changed

+47
-42
lines changed

1 file changed

+47
-42
lines changed

src/lib/ui/device/EditableDeviceName.tsx

Lines changed: 47 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -12,48 +12,6 @@ import { CheckIcon } from 'lib/icons/Check.js'
1212
import { CloseIcon } from 'lib/icons/Close.js'
1313
import { EditIcon } from 'lib/icons/Edit.js'
1414

15-
function IconButton(
16-
props: PropsWithChildren<HTMLAttributes<HTMLButtonElement>>
17-
): JSX.Element {
18-
return (
19-
<button
20-
{...props}
21-
className={classNames(
22-
'seam-editable-device-name-icon-button',
23-
props.className
24-
)}
25-
>
26-
{props.children}
27-
</button>
28-
)
29-
}
30-
31-
const fixName = (name: string): string => {
32-
return name.replace(/\s+/g, ' ').trim()
33-
}
34-
35-
type Result = { type: 'success' } | { type: 'error'; message: string }
36-
37-
const isValidName = (name: string): Result => {
38-
if (name.length < 2) {
39-
return {
40-
type: 'error',
41-
message: 'Name must be at least 2 characters long',
42-
}
43-
}
44-
45-
if (name.length > 64) {
46-
return {
47-
type: 'error',
48-
message: 'Name must be at most 64 characters long',
49-
}
50-
}
51-
52-
return {
53-
type: 'success',
54-
} as const
55-
}
56-
5715
type EditableDeviceNameProps = {
5816
onEdit?: (newName: string) => void
5917
editable?: boolean
@@ -206,3 +164,50 @@ function ActionButtons(props: ActionButtonsProps): JSX.Element {
206164
</IconButton>
207165
)
208166
}
167+
168+
function IconButton(
169+
props: PropsWithChildren<HTMLAttributes<HTMLButtonElement>>
170+
): JSX.Element {
171+
return (
172+
<button
173+
{...props}
174+
className={classNames(
175+
'seam-editable-device-name-icon-button',
176+
props.className
177+
)}
178+
>
179+
{props.children}
180+
</button>
181+
)
182+
}
183+
184+
const fixName = (name: string): string => {
185+
return name.replace(/\s+/g, ' ').trim()
186+
}
187+
188+
type Result =
189+
| { type: 'success' }
190+
| {
191+
type: 'error'
192+
message: string
193+
}
194+
195+
const isValidName = (name: string): Result => {
196+
if (name.length < 2) {
197+
return {
198+
type: 'error',
199+
message: 'Name must be at least 2 characters long',
200+
}
201+
}
202+
203+
if (name.length > 64) {
204+
return {
205+
type: 'error',
206+
message: 'Name must be at most 64 characters long',
207+
}
208+
}
209+
210+
return {
211+
type: 'success',
212+
} as const
213+
}

0 commit comments

Comments
 (0)