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
a2263142
Commit
a2263142
authored
May 08, 2024
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tag type, bg and text color fields
parent
efbff6e4
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
131 additions
and
23 deletions
+131
-23
PublicTagsSubmitForm.tsx
ui/publicTags/submit/PublicTagsSubmitForm.tsx
+1
-1
PublicTagsSubmitFieldTag.tsx
ui/publicTags/submit/fields/PublicTagsSubmitFieldTag.tsx
+22
-20
PublicTagsSubmitFieldTagColor.tsx
...ublicTags/submit/fields/PublicTagsSubmitFieldTagColor.tsx
+35
-0
PublicTagsSubmitFieldTagType.tsx
ui/publicTags/submit/fields/PublicTagsSubmitFieldTagType.tsx
+58
-0
PublicTagsSubmitFieldTags.tsx
ui/publicTags/submit/fields/PublicTagsSubmitFieldTags.tsx
+8
-1
types.ts
ui/publicTags/submit/types.ts
+4
-1
FancySelect.tsx
ui/shared/FancySelect/FancySelect.tsx
+3
-0
No files found.
ui/publicTags/submit/PublicTagsSubmitForm.tsx
View file @
a2263142
...
@@ -23,7 +23,7 @@ const PublicTagsSubmitForm = ({ config }: Props) => {
...
@@ -23,7 +23,7 @@ const PublicTagsSubmitForm = ({ config }: Props) => {
mode
:
'
onBlur
'
,
mode
:
'
onBlur
'
,
defaultValues
:
{
defaultValues
:
{
addresses
:
[
{
hash
:
''
}
],
addresses
:
[
{
hash
:
''
}
],
tags
:
[
{
name
:
''
,
type
:
'
name
'
,
url
:
undefined
,
bgColor
:
undefined
,
textColor
:
undefined
}
],
tags
:
[
{
name
:
''
,
type
:
{
label
:
'
name
'
,
value
:
'
name
'
}
,
url
:
undefined
,
bgColor
:
undefined
,
textColor
:
undefined
}
],
},
},
});
});
...
...
ui/publicTags/submit/fields/PublicTagsSubmitFieldTag.tsx
View file @
a2263142
import
{
chakra
,
Flex
,
FormControl
,
Grid
,
GridItem
,
IconButton
,
Input
,
Textarea
,
useColorModeValue
}
from
'
@chakra-ui/react
'
;
import
{
chakra
,
Flex
,
FormControl
,
Grid
,
GridItem
,
IconButton
,
Input
,
Textarea
,
useColorModeValue
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
type
{
FieldError
,
FieldErrorsImpl
,
Merge
,
UseFormRegister
}
from
'
react-hook-form
'
;
import
{
type
FieldError
,
type
FieldErrorsImpl
,
type
Merge
,
type
UseFormRegister
}
from
'
react-hook-form
'
;
import
type
{
FormFields
,
FormFieldTag
}
from
'
../types
'
;
import
type
{
FormFields
,
FormFieldTag
}
from
'
../types
'
;
import
type
{
PublicTagType
}
from
'
types/api/addressMetadata
'
;
import
type
{
PublicTagType
}
from
'
types/api/addressMetadata
'
;
import
useIsMobile
from
'
lib/hooks/useIsMobile
'
;
import
useIsMobile
from
'
lib/hooks/useIsMobile
'
;
import
{
validator
as
urlValidator
}
from
'
lib/validations/url
'
;
import
{
validator
as
urlValidator
}
from
'
lib/validations/url
'
;
import
FancySelect
from
'
ui/shared/FancySelect/FancySelect
'
;
import
IconSvg
from
'
ui/shared/IconSvg
'
;
import
IconSvg
from
'
ui/shared/IconSvg
'
;
import
InputPlaceholder
from
'
ui/shared/InputPlaceholder
'
;
import
InputPlaceholder
from
'
ui/shared/InputPlaceholder
'
;
import
PublicTagsSubmitFieldTagColor
from
'
./PublicTagsSubmitFieldTagColor
'
;
import
PublicTagsSubmitFieldTagType
from
'
./PublicTagsSubmitFieldTagType
'
;
interface
Props
{
interface
Props
{
index
:
number
;
index
:
number
;
tagTypes
:
Array
<
PublicTagType
>
|
undefined
;
tagTypes
:
Array
<
PublicTagType
>
|
undefined
;
...
@@ -24,7 +26,7 @@ interface Props {
...
@@ -24,7 +26,7 @@ interface Props {
const
PublicTagsSubmitFieldTag
=
({
index
,
isDisabled
,
register
,
errors
,
onAddClick
,
onRemoveClick
,
tagTypes
}:
Props
)
=>
{
const
PublicTagsSubmitFieldTag
=
({
index
,
isDisabled
,
register
,
errors
,
onAddClick
,
onRemoveClick
,
tagTypes
}:
Props
)
=>
{
const
isMobile
=
useIsMobile
();
const
isMobile
=
useIsMobile
();
const
bgColorDefault
=
useColorModeValue
(
'
blackAlpha.50
'
,
'
whiteAlpha.100
'
);
const
bgColorDefault
=
useColorModeValue
(
'
blackAlpha.50
'
,
'
whiteAlpha.100
'
);
const
inputBgColor
=
useColorModeValue
(
'
white
'
,
'
gray.900
'
);
const
inputBgColor
=
useColorModeValue
(
'
white
'
,
'
black
'
);
const
handleAddClick
=
React
.
useCallback
(()
=>
{
const
handleAddClick
=
React
.
useCallback
(()
=>
{
onAddClick
?.(
index
);
onAddClick
?.(
index
);
...
@@ -34,11 +36,6 @@ const PublicTagsSubmitFieldTag = ({ index, isDisabled, register, errors, onAddCl
...
@@ -34,11 +36,6 @@ const PublicTagsSubmitFieldTag = ({ index, isDisabled, register, errors, onAddCl
onRemoveClick
?.(
index
);
onRemoveClick
?.(
index
);
},
[
index
,
onRemoveClick
]);
},
[
index
,
onRemoveClick
]);
const
typeOptions
=
React
.
useMemo
(()
=>
tagTypes
?.
map
((
type
)
=>
({
value
:
type
.
type
,
label
:
type
.
type
,
})),
[
tagTypes
]);
return
(
return
(
<>
<>
<
GridItem
colSpan=
{
{
base
:
1
,
lg
:
2
}
}
p=
"10px"
borderRadius=
"base"
bgColor=
{
bgColorDefault
}
>
<
GridItem
colSpan=
{
{
base
:
1
,
lg
:
2
}
}
p=
"10px"
borderRadius=
"base"
bgColor=
{
bgColorDefault
}
>
...
@@ -60,16 +57,7 @@ const PublicTagsSubmitFieldTag = ({ index, isDisabled, register, errors, onAddCl
...
@@ -60,16 +57,7 @@ const PublicTagsSubmitFieldTag = ({ index, isDisabled, register, errors, onAddCl
</
FormControl
>
</
FormControl
>
</
GridItem
>
</
GridItem
>
<
GridItem
colSpan=
{
{
base
:
1
,
lg
:
2
}
}
>
<
GridItem
colSpan=
{
{
base
:
1
,
lg
:
2
}
}
>
<
FancySelect
<
PublicTagsSubmitFieldTagType
index=
{
index
}
tagTypes=
{
tagTypes
}
isDisabled=
{
isDisabled
}
/>
{
...
register
(`
tags
.
$
{
index
}
.
type
`)
}
options=
{
typeOptions
}
size=
{
isMobile
?
'
md
'
:
'
lg
'
}
placeholder=
"Tag type"
isDisabled=
{
isDisabled
}
isRequired
isAsync=
{
false
}
bgColor=
{
inputBgColor
}
/>
</
GridItem
>
</
GridItem
>
<
GridItem
colSpan=
{
{
base
:
1
,
lg
:
2
}
}
>
<
GridItem
colSpan=
{
{
base
:
1
,
lg
:
2
}
}
>
<
FormControl
variant=
"floating"
size=
{
{
base
:
'
md
'
,
lg
:
'
lg
'
}
}
>
<
FormControl
variant=
"floating"
size=
{
{
base
:
'
md
'
,
lg
:
'
lg
'
}
}
>
...
@@ -83,8 +71,22 @@ const PublicTagsSubmitFieldTag = ({ index, isDisabled, register, errors, onAddCl
...
@@ -83,8 +71,22 @@ const PublicTagsSubmitFieldTag = ({ index, isDisabled, register, errors, onAddCl
<
InputPlaceholder
text=
"Label URL"
error=
{
errors
?.
url
}
/>
<
InputPlaceholder
text=
"Label URL"
error=
{
errors
?.
url
}
/>
</
FormControl
>
</
FormControl
>
</
GridItem
>
</
GridItem
>
<
chakra
.
div
bgColor=
"blue.100"
h=
{
20
}
/>
<
PublicTagsSubmitFieldTagColor
<
chakra
.
div
bgColor=
"blue.100"
h=
{
20
}
/>
fieldName=
"bgColor"
placeholder=
"Background color"
index=
{
index
}
register=
{
register
}
errors=
{
errors
}
isDisabled=
{
isDisabled
}
/>
<
PublicTagsSubmitFieldTagColor
fieldName=
"textColor"
placeholder=
"Text color"
index=
{
index
}
register=
{
register
}
errors=
{
errors
}
isDisabled=
{
isDisabled
}
/>
<
GridItem
colSpan=
{
{
base
:
1
,
lg
:
4
}
}
>
<
GridItem
colSpan=
{
{
base
:
1
,
lg
:
4
}
}
>
<
FormControl
variant=
"floating"
size=
{
{
base
:
'
md
'
,
lg
:
'
lg
'
}
}
>
<
FormControl
variant=
"floating"
size=
{
{
base
:
'
md
'
,
lg
:
'
lg
'
}
}
>
<
Textarea
<
Textarea
...
...
ui/publicTags/submit/fields/PublicTagsSubmitFieldTagColor.tsx
0 → 100644
View file @
a2263142
import
{
FormControl
,
Input
,
useColorModeValue
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
import
type
{
FieldError
,
FieldErrorsImpl
,
Merge
,
UseFormRegister
}
from
'
react-hook-form
'
;
import
type
{
FormFieldTag
,
FormFields
}
from
'
../types
'
;
import
InputPlaceholder
from
'
ui/shared/InputPlaceholder
'
;
interface
Props
{
fieldName
:
'
textColor
'
|
'
bgColor
'
;
index
:
number
;
isDisabled
:
boolean
;
register
:
UseFormRegister
<
FormFields
>
;
errors
:
Merge
<
FieldError
,
FieldErrorsImpl
<
FormFieldTag
>>
|
undefined
;
placeholder
:
string
;
}
const
PublicTagsSubmitFieldTagColor
=
({
index
,
isDisabled
,
register
,
errors
,
fieldName
,
placeholder
}:
Props
)
=>
{
const
inputBgColor
=
useColorModeValue
(
'
white
'
,
'
black
'
);
return
(
<
FormControl
variant=
"floating"
size=
{
{
base
:
'
md
'
,
lg
:
'
lg
'
}
}
>
<
Input
{
...
register
(`
tags
.
$
{
index
}
.
$
{
fieldName
}`)
}
isInvalid=
{
Boolean
(
errors
?.[
fieldName
])
}
isDisabled=
{
isDisabled
}
autoComplete=
"off"
bgColor=
{
inputBgColor
}
/>
<
InputPlaceholder
text=
{
placeholder
}
error=
{
errors
?.[
fieldName
]
}
/>
</
FormControl
>
);
};
export
default
React
.
memo
(
PublicTagsSubmitFieldTagColor
);
ui/publicTags/submit/fields/PublicTagsSubmitFieldTagType.tsx
0 → 100644
View file @
a2263142
import
{
FormControl
,
useColorModeValue
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
import
type
{
ControllerRenderProps
}
from
'
react-hook-form
'
;
import
{
Controller
,
useFormContext
}
from
'
react-hook-form
'
;
import
type
{
FormFields
}
from
'
../types
'
;
import
type
{
PublicTagType
}
from
'
types/api/addressMetadata
'
;
import
useIsMobile
from
'
lib/hooks/useIsMobile
'
;
import
FancySelect
from
'
ui/shared/FancySelect/FancySelect
'
;
interface
Props
{
index
:
number
;
tagTypes
:
Array
<
PublicTagType
>
|
undefined
;
isDisabled
:
boolean
;
}
const
PublicTagsSubmitFieldTagType
=
({
index
,
tagTypes
,
isDisabled
}:
Props
)
=>
{
const
isMobile
=
useIsMobile
();
const
{
control
}
=
useFormContext
<
FormFields
>
();
const
inputBgColor
=
useColorModeValue
(
'
white
'
,
'
black
'
);
const
typeOptions
=
React
.
useMemo
(()
=>
tagTypes
?.
map
((
type
)
=>
({
value
:
type
.
type
,
label
:
type
.
type
,
})),
[
tagTypes
]);
const
renderControl
=
React
.
useCallback
(({
field
}:
{
field
:
ControllerRenderProps
<
FormFields
,
`tags.
${
number
}
.type`
>
})
=>
{
return
(
<
FormControl
variant=
"floating"
id=
{
field
.
name
}
isRequired
size=
{
{
base
:
'
md
'
,
lg
:
'
lg
'
}
}
>
<
FancySelect
{
...
field
}
options=
{
typeOptions
}
size=
{
isMobile
?
'
md
'
:
'
lg
'
}
placeholder=
"Tag type"
isDisabled=
{
isDisabled
}
isRequired
isAsync=
{
false
}
formControlStyles=
{
{
bgColor
:
inputBgColor
,
borderRadius
:
'
base
'
,
}
}
/>
</
FormControl
>
);
},
[
inputBgColor
,
isDisabled
,
isMobile
,
typeOptions
]);
return
(
<
Controller
name=
{
`tags.${ index }.type`
}
control=
{
control
}
render=
{
renderControl
}
rules=
{
{
required
:
true
}
}
/>
);
};
export
default
React
.
memo
(
PublicTagsSubmitFieldTagType
);
ui/publicTags/submit/fields/PublicTagsSubmitFieldTags.tsx
View file @
a2263142
...
@@ -22,7 +22,14 @@ const PublicTagsSubmitFieldTags = ({ tagTypes }: Props) => {
...
@@ -22,7 +22,14 @@ const PublicTagsSubmitFieldTags = ({ tagTypes }: Props) => {
const
isDisabled
=
formState
.
isSubmitting
;
const
isDisabled
=
formState
.
isSubmitting
;
const
handleAddFieldClick
=
React
.
useCallback
((
index
:
number
)
=>
{
const
handleAddFieldClick
=
React
.
useCallback
((
index
:
number
)
=>
{
insert
(
index
+
1
,
{
name
:
''
,
type
:
'
name
'
,
url
:
undefined
,
bgColor
:
undefined
,
textColor
:
undefined
,
tooltipDescription
:
undefined
});
insert
(
index
+
1
,
{
name
:
''
,
type
:
{
label
:
'
name
'
,
value
:
'
name
'
},
url
:
undefined
,
bgColor
:
undefined
,
textColor
:
undefined
,
tooltipDescription
:
undefined
,
});
},
[
insert
]);
},
[
insert
]);
const
handleRemoveFieldClick
=
React
.
useCallback
((
index
:
number
)
=>
{
const
handleRemoveFieldClick
=
React
.
useCallback
((
index
:
number
)
=>
{
...
...
ui/publicTags/submit/types.ts
View file @
a2263142
...
@@ -10,7 +10,10 @@ export interface FormFields {
...
@@ -10,7 +10,10 @@ export interface FormFields {
export
interface
FormFieldTag
{
export
interface
FormFieldTag
{
name
:
string
;
name
:
string
;
type
:
AddressMetadataTagType
;
type
:
{
label
:
string
;
value
:
AddressMetadataTagType
;
};
url
:
string
|
undefined
;
url
:
string
|
undefined
;
bgColor
:
string
|
undefined
;
bgColor
:
string
|
undefined
;
textColor
:
string
|
undefined
;
textColor
:
string
|
undefined
;
...
...
ui/shared/FancySelect/FancySelect.tsx
View file @
a2263142
import
type
{
ChakraProps
}
from
'
@chakra-ui/react
'
;
import
{
FormControl
,
useToken
,
useColorMode
}
from
'
@chakra-ui/react
'
;
import
{
FormControl
,
useToken
,
useColorMode
}
from
'
@chakra-ui/react
'
;
import
type
{
CSSObjectWithLabel
,
GroupBase
,
SingleValue
,
MultiValue
,
AsyncProps
,
Props
as
SelectProps
}
from
'
chakra-react-select
'
;
import
type
{
CSSObjectWithLabel
,
GroupBase
,
SingleValue
,
MultiValue
,
AsyncProps
,
Props
as
SelectProps
}
from
'
chakra-react-select
'
;
import
{
Select
,
AsyncSelect
}
from
'
chakra-react-select
'
;
import
{
Select
,
AsyncSelect
}
from
'
chakra-react-select
'
;
...
@@ -12,6 +13,7 @@ import InputPlaceholder from 'ui/shared/InputPlaceholder';
...
@@ -12,6 +13,7 @@ import InputPlaceholder from 'ui/shared/InputPlaceholder';
interface
CommonProps
{
interface
CommonProps
{
error
?:
Merge
<
FieldError
,
FieldErrorsImpl
<
Option
>>
|
undefined
;
error
?:
Merge
<
FieldError
,
FieldErrorsImpl
<
Option
>>
|
undefined
;
placeholderIcon
?:
React
.
ReactNode
;
placeholderIcon
?:
React
.
ReactNode
;
formControlStyles
?:
ChakraProps
;
}
}
interface
RegularSelectProps
extends
SelectProps
<
Option
,
boolean
,
GroupBase
<
Option
>>
,
CommonProps
{
interface
RegularSelectProps
extends
SelectProps
<
Option
,
boolean
,
GroupBase
<
Option
>>
,
CommonProps
{
...
@@ -47,6 +49,7 @@ const FancySelect = (props: Props, ref: React.LegacyRef<HTMLDivElement>) => {
...
@@ -47,6 +49,7 @@ const FancySelect = (props: Props, ref: React.LegacyRef<HTMLDivElement>) => {
{
...
(
props
.
error
?
{
'
aria
-
invalid
':
true
}
:
{})
}
{
...
(
props
.
error
?
{
'
aria
-
invalid
':
true
}
:
{})
}
{
...
(
props
.
isDisabled
?
{
'
aria
-
disabled
':
true
}
:
{})
}
{
...
(
props
.
isDisabled
?
{
'
aria
-
disabled
':
true
}
:
{})
}
{
...
(
props
.
value
?
{
'
data
-
active
':
true
}
:
{})
}
{
...
(
props
.
value
?
{
'
data
-
active
':
true
}
:
{})
}
{
...
props
.
formControlStyles
}
>
>
<
SelectComponent
<
SelectComponent
{
...
props
}
{
...
props
}
...
...
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