Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
frontend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
frontend
Commits
a4e2c610
Unverified
Commit
a4e2c610
authored
Nov 28, 2022
by
Igor Stuev
Committed by
GitHub
Nov 28, 2022
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #375 from blockscout/asterix-in-placeholder
fix asterix in input placeholders
parents
fd915fab
3354ef03
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
35 additions
and
23 deletions
+35
-23
getPlaceholderWithError.ts
lib/getPlaceholderWithError.ts
+0
-3
FormLabel.ts
theme/components/FormLabel.ts
+1
-0
ApiKeyForm.tsx
ui/apiKey/ApiKeyModal/ApiKeyForm.tsx
+2
-2
CustomAbiForm.tsx
ui/customAbi/CustomAbiModal/CustomAbiForm.tsx
+3
-4
PublicTagFormComment.tsx
ui/publicTags/PublicTagsForm/PublicTagFormComment.tsx
+2
-2
PublicTagsFormInput.tsx
ui/publicTags/PublicTagsForm/PublicTagsFormInput.tsx
+3
-3
AddressInput.tsx
ui/shared/AddressInput.tsx
+2
-3
InputPlaceholder.tsx
ui/shared/InputPlaceholder.tsx
+18
-0
TagInput.tsx
ui/shared/TagInput.tsx
+2
-3
TransactionInput.tsx
ui/shared/TransactionInput.tsx
+2
-3
No files found.
lib/getPlaceholderWithError.ts
deleted
100644 → 0
View file @
fd915fab
export
default
function
getPlaceholderWithError
(
text
:
string
,
errorText
?:
string
)
{
return
`
${
text
}${
errorText
?
'
-
'
+
errorText
:
''
}
`
;
}
theme/components/FormLabel.ts
View file @
a4e2c610
...
...
@@ -4,6 +4,7 @@ import { getColor, mode } from '@chakra-ui/theme-tools';
import
getDefaultFormColors
from
'
../utils/getDefaultFormColors
'
;
const
baseStyle
=
defineStyle
({
display
:
'
flex
'
,
fontSize
:
'
md
'
,
marginEnd
:
'
3
'
,
mb
:
'
2
'
,
...
...
ui/apiKey/ApiKeyModal/ApiKeyForm.tsx
View file @
a4e2c610
...
...
@@ -15,9 +15,9 @@ import type { ApiKey, ApiKeys, ApiKeyErrors } from 'types/api/account';
import
{
QueryKeys
}
from
'
types/client/accountQueries
'
;
import
getErrorMessage
from
'
lib/getErrorMessage
'
;
import
getPlaceholderWithError
from
'
lib/getPlaceholderWithError
'
;
import
type
{
ErrorType
}
from
'
lib/hooks/useFetch
'
;
import
useFetch
from
'
lib/hooks/useFetch
'
;
import
InputPlaceholder
from
'
ui/shared/InputPlaceholder
'
;
type
Props
=
{
data
?:
ApiKey
;
...
...
@@ -113,7 +113,7 @@ const ApiKeyForm: React.FC<Props> = ({ data, onClose, setAlertVisible }) => {
maxLength=
{
NAME_MAX_LENGTH
}
/>
<
FormLabel
>
{
getPlaceholderWithError
(
'
Application name for API key (e.g Web3 project)
'
,
errors
.
name
?.
message
)
}
<
InputPlaceholder
text=
"Application name for API key (e.g Web3 project)"
error=
{
errors
.
name
?.
message
}
/>
</
FormLabel
>
</
FormControl
>
);
...
...
ui/customAbi/CustomAbiModal/CustomAbiForm.tsx
View file @
a4e2c610
...
...
@@ -2,7 +2,6 @@ import {
Box
,
Button
,
FormControl
,
FormLabel
,
Input
,
Textarea
,
useColorModeValue
,
...
...
@@ -16,11 +15,11 @@ import type { CustomAbi, CustomAbis, CustomAbiErrors } from 'types/api/account';
import
{
QueryKeys
}
from
'
types/client/accountQueries
'
;
import
getErrorMessage
from
'
lib/getErrorMessage
'
;
import
getPlaceholderWithError
from
'
lib/getPlaceholderWithError
'
;
import
type
{
ErrorType
}
from
'
lib/hooks/useFetch
'
;
import
useFetch
from
'
lib/hooks/useFetch
'
;
import
{
ADDRESS_REGEXP
}
from
'
lib/validations/address
'
;
import
AddressInput
from
'
ui/shared/AddressInput
'
;
import
InputPlaceholder
from
'
ui/shared/InputPlaceholder
'
;
type
Props
=
{
data
?:
CustomAbi
;
...
...
@@ -119,7 +118,7 @@ const CustomAbiForm: React.FC<Props> = ({ data, onClose, setAlertVisible }) => {
isInvalid=
{
Boolean
(
errors
.
name
)
}
maxLength=
{
NAME_MAX_LENGTH
}
/>
<
FormLabel
>
{
getPlaceholderWithError
(
'
Project name
'
,
errors
.
name
?.
message
)
}
</
FormLabel
>
<
InputPlaceholder
text=
"Project name"
error=
{
errors
.
name
?.
message
}
/
>
</
FormControl
>
);
}
, [ errors, formBackgroundColor ]);
...
...
@@ -133,7 +132,7 @@ const CustomAbiForm: React.FC<Props> = ({ data, onClose, setAlertVisible }) => {
minH=
"300px"
isInvalid=
{
Boolean
(
errors
.
abi
)
}
/>
<
FormLabel
>
{
getPlaceholderWithError
(
`Custom ABI [{...}] (JSON format)`
,
errors
.
abi
?.
message
)
}
</
FormLabel
>
<
InputPlaceholder
text=
"Custom ABI [
{
...
}
]
(
JSON
format
)"
error=
{
errors
.
abi
?.
message
}
/
>
</
FormControl
>
);
}
, [ errors, formBackgroundColor ]);
...
...
ui/publicTags/PublicTagsForm/PublicTagFormComment.tsx
View file @
a4e2c610
...
...
@@ -4,7 +4,7 @@ import React, { useCallback } from 'react';
import
type
{
ControllerRenderProps
,
Control
,
FieldError
}
from
'
react-hook-form
'
;
import
{
Controller
}
from
'
react-hook-form
'
;
import
getPlaceholderWithError
from
'
lib/getPlaceholderWithErro
r
'
;
import
InputPlaceholder
from
'
ui/shared/InputPlaceholde
r
'
;
import
type
{
Inputs
}
from
'
./PublicTagsForm
'
;
...
...
@@ -25,7 +25,7 @@ export default function PublicTagFormComment({ control, error, size }: Props) {
isInvalid=
{
Boolean
(
error
)
}
/>
<
FormLabel
>
{
getPlaceholderWithError
(
'
Specify the reason for adding tags and color preference(s)
'
,
error
?.
message
)
}
<
InputPlaceholder
text=
"Specify the reason for adding tags and color preference(s)"
error=
{
error
?.
message
}
/>
</
FormLabel
>
</
FormControl
>
);
...
...
ui/publicTags/PublicTagsForm/PublicTagsFormInput.tsx
View file @
a4e2c610
import
type
{
InputProps
}
from
'
@chakra-ui/react
'
;
import
{
FormControl
,
FormLabel
,
Input
}
from
'
@chakra-ui/react
'
;
import
{
FormControl
,
Input
}
from
'
@chakra-ui/react
'
;
import
React
,
{
useCallback
}
from
'
react
'
;
import
type
{
ControllerRenderProps
,
FieldError
,
FieldValues
,
Path
,
Control
}
from
'
react-hook-form
'
;
import
{
Controller
}
from
'
react-hook-form
'
;
import
getPlaceholderWithError
from
'
lib/getPlaceholderWithErro
r
'
;
import
InputPlaceholder
from
'
ui/shared/InputPlaceholde
r
'
;
const
TEXT_INPUT_MAX_LENGTH
=
255
;
...
...
@@ -36,7 +36,7 @@ export default function PublicTagsFormInput<Inputs extends FieldValues>({
isInvalid=
{
Boolean
(
error
)
}
maxLength=
{
TEXT_INPUT_MAX_LENGTH
}
/>
<
FormLabel
>
{
getPlaceholderWithError
(
label
,
error
?.
message
)
}
</
FormLabel
>
<
InputPlaceholder
text=
{
label
}
error=
{
error
?.
message
}
/
>
</
FormControl
>
);
},
[
label
,
required
,
error
,
size
]);
...
...
ui/shared/AddressInput.tsx
View file @
a4e2c610
...
...
@@ -2,13 +2,12 @@ import type { InputProps } from '@chakra-ui/react';
import
{
Input
,
FormControl
,
FormLabel
,
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
import
type
{
ControllerRenderProps
,
FieldError
,
FieldValues
,
Path
}
from
'
react-hook-form
'
;
import
getPlaceholderWithError
from
'
lib/getPlaceholderWithError
'
;
import
{
ADDRESS_LENGTH
}
from
'
lib/validations/address
'
;
import
InputPlaceholder
from
'
ui/shared/InputPlaceholder
'
;
type
Props
<
TInputs
extends
FieldValues
,
TInputName
extends
Path
<
TInputs
>>
=
{
field
:
ControllerRenderProps
<
TInputs
,
TInputName
>
;
...
...
@@ -33,7 +32,7 @@ export default function AddressInput<Inputs extends FieldValues, Name extends Pa
isInvalid=
{
Boolean
(
error
)
}
maxLength=
{
ADDRESS_LENGTH
}
/>
<
FormLabel
>
{
getPlaceholderWithError
(
placeholder
,
error
?.
message
)
}
</
FormLabel
>
<
InputPlaceholder
text=
{
placeholder
}
error=
{
error
?.
message
}
/
>
</
FormControl
>
);
}
ui/shared/InputPlaceholder.tsx
0 → 100644
View file @
a4e2c610
import
{
FormLabel
,
chakra
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
interface
Props
{
text
:
string
;
error
?:
string
;
}
const
InputPlaceholder
=
({
text
,
error
}:
Props
)
=>
{
return
(
<
FormLabel
>
<
chakra
.
span
>
{
text
}
</
chakra
.
span
>
{
error
&&
<
chakra
.
span
order=
{
3
}
whiteSpace=
"pre"
>
-
{
error
}
</
chakra
.
span
>
}
</
FormLabel
>
);
};
export
default
InputPlaceholder
;
ui/shared/TagInput.tsx
View file @
a4e2c610
import
{
Input
,
FormControl
,
FormLabel
,
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
import
type
{
ControllerRenderProps
,
FieldError
,
FieldValues
,
Path
}
from
'
react-hook-form
'
;
import
getPlaceholderWithError
from
'
lib/getPlaceholderWithErro
r
'
;
import
InputPlaceholder
from
'
ui/shared/InputPlaceholde
r
'
;
const
TAG_MAX_LENGTH
=
35
;
...
...
@@ -24,7 +23,7 @@ function TagInput<Inputs extends FieldValues, Name extends Path<Inputs>>({ field
isInvalid=
{
Boolean
(
error
)
}
maxLength=
{
TAG_MAX_LENGTH
}
/>
<
FormLabel
>
{
getPlaceholderWithError
(
`Private tag (max 35 characters)`
,
error
?.
message
)
}
</
FormLabel
>
<
InputPlaceholder
text=
"Private tag (max 35 characters)"
error=
{
error
?.
message
}
/
>
</
FormControl
>
);
}
...
...
ui/shared/TransactionInput.tsx
View file @
a4e2c610
import
{
Input
,
FormControl
,
FormLabel
,
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
import
type
{
ControllerRenderProps
,
FieldError
,
FieldValues
}
from
'
react-hook-form
'
;
import
getPlaceholderWithError
from
'
lib/getPlaceholderWithError
'
;
import
{
TRANSACTION_HASH_LENGTH
}
from
'
lib/validations/transaction
'
;
import
InputPlaceholder
from
'
ui/shared/InputPlaceholder
'
;
type
Props
<
Field
>
=
{
field
:
Field
;
...
...
@@ -23,7 +22,7 @@ function TransactionInput<Field extends Partial<ControllerRenderProps<FieldValue
isInvalid=
{
Boolean
(
error
)
}
maxLength=
{
TRANSACTION_HASH_LENGTH
}
/>
<
FormLabel
>
{
getPlaceholderWithError
(
'
Transaction hash (0x...)
'
,
error
?.
message
)
}
</
FormLabel
>
<
InputPlaceholder
text=
"Transaction hash (0x...)"
error=
{
error
?.
message
}
/
>
</
FormControl
>
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment