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
814b8333
Commit
814b8333
authored
May 16, 2024
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add # before tag hex
parent
ccb1d227
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
10 deletions
+26
-10
color.ts
lib/validations/color.ts
+2
-2
PublicTagsSubmitFieldTag.tsx
ui/publicTags/submit/fields/PublicTagsSubmitFieldTag.tsx
+2
-2
PublicTagsSubmitFieldTagColor.tsx
...ublicTags/submit/fields/PublicTagsSubmitFieldTagColor.tsx
+20
-4
utils.ts
ui/publicTags/submit/utils.ts
+2
-2
No files found.
lib/validations/color.ts
View file @
814b8333
export
const
COLOR_HEX_REGEXP
=
/^
[
A-Fa-f
\d]{3,6}
$/
;
export
const
COLOR_HEX_REGEXP
=
/^
#
[
A-Fa-f
\d]{3,6}
$/
;
export
const
validator
=
(
value
:
string
|
undefined
)
=>
{
export
const
validator
=
(
value
:
string
|
undefined
)
=>
{
if
(
!
value
||
value
.
length
===
0
)
{
if
(
!
value
||
value
.
length
===
0
)
{
return
true
;
return
true
;
}
}
if
(
value
.
length
!==
3
&&
value
.
length
!==
6
)
{
if
(
value
.
length
!==
4
&&
value
.
length
!==
7
)
{
return
'
Invalid length
'
;
return
'
Invalid length
'
;
}
}
...
...
ui/publicTags/submit/fields/PublicTagsSubmitFieldTag.tsx
View file @
814b8333
...
@@ -144,8 +144,8 @@ const PublicTagsSubmitFieldTag = ({ index, isDisabled, register, errors, onAddCl
...
@@ -144,8 +144,8 @@ const PublicTagsSubmitFieldTag = ({ index, isDisabled, register, errors, onAddCl
tagType
:
field
.
type
.
value
,
tagType
:
field
.
type
.
value
,
meta
:
{
meta
:
{
tagUrl
:
field
.
url
,
tagUrl
:
field
.
url
,
bgColor
:
field
.
bgColor
&&
colorValidator
(
field
.
bgColor
)
===
true
?
`#${ field.bgColor }`
:
undefined
,
bgColor
:
field
.
bgColor
&&
colorValidator
(
field
.
bgColor
)
===
true
?
field
.
bgColor
:
undefined
,
textColor
:
field
.
textColor
&&
colorValidator
(
field
.
textColor
)
===
true
?
`#${ field.textColor }`
:
undefined
,
textColor
:
field
.
textColor
&&
colorValidator
(
field
.
textColor
)
===
true
?
field
.
textColor
:
undefined
,
tooltipDescription
:
field
.
tooltipDescription
,
tooltipDescription
:
field
.
tooltipDescription
,
},
},
slug
:
'
new
'
,
slug
:
'
new
'
,
...
...
ui/publicTags/submit/fields/PublicTagsSubmitFieldTagColor.tsx
View file @
814b8333
...
@@ -21,7 +21,7 @@ interface Props<Type extends ColorFieldTypes> {
...
@@ -21,7 +21,7 @@ interface Props<Type extends ColorFieldTypes> {
}
}
const
PublicTagsSubmitFieldTagColor
=
<
Type
extends
ColorFieldTypes
>
(
{
isDisabled
,
error
,
fieldName
,
placeholder
,
fieldType
}
: Props
<
Type
>
) =
>
{
const
PublicTagsSubmitFieldTagColor
=
<
Type
extends
ColorFieldTypes
>
(
{
isDisabled
,
error
,
fieldName
,
placeholder
,
fieldType
}
: Props
<
Type
>
) =
>
{
const
{
getValues
,
register
}
=
useFormContext
<
FormFields
>
();
const
{
register
}
=
useFormContext
<
FormFields
>
();
const
circleBgColorDefault
=
{
const
circleBgColorDefault
=
{
bgColor
:
useColorModeValue
(
'
gray.100
'
,
'
gray.700
'
),
bgColor
:
useColorModeValue
(
'
gray.100
'
,
'
gray.700
'
),
...
@@ -29,23 +29,39 @@ const PublicTagsSubmitFieldTagColor = <Type extends ColorFieldTypes>({ isDisable
...
@@ -29,23 +29,39 @@ const PublicTagsSubmitFieldTagColor = <Type extends ColorFieldTypes>({ isDisable
};
};
const
isMobile
=
useIsMobile
();
const
isMobile
=
useIsMobile
();
const
field
=
register
(
fieldName
,
{
validate
:
colorValidator
,
maxLength
:
6
});
const
field
=
register
(
fieldName
,
{
validate
:
colorValidator
,
maxLength
:
6
});
const
value
=
getValues
(
fieldName
);
const
[
value
,
setValue
]
=
React
.
useState
(
''
);
const
handleChange
=
React
.
useCallback
((
event
:
React
.
ChangeEvent
<
HTMLInputElement
>
)
=>
{
const
nextValue
=
(()
=>
{
const
value
=
event
.
target
.
value
;
if
(
value
)
{
if
(
value
.
length
===
1
&&
value
[
0
]
!==
'
#
'
)
{
return
`#${ value }`
;
}
}
return
value
;
})();
setValue
(
nextValue
);
field
.
onChange
(
event
);
},
[
field
]);
return
(
return
(
<
FormControl
variant=
"floating"
size=
{
{
base
:
'
md
'
,
lg
:
'
lg
'
}
}
>
<
FormControl
variant=
"floating"
size=
{
{
base
:
'
md
'
,
lg
:
'
lg
'
}
}
>
<
InputGroup
size=
{
isMobile
?
'
md
'
:
'
lg
'
}
>
<
InputGroup
size=
{
isMobile
?
'
md
'
:
'
lg
'
}
>
<
Input
<
Input
{
...
field
}
{
...
field
}
onChange=
{
handleChange
}
value=
{
value
}
isInvalid=
{
Boolean
(
error
)
}
isInvalid=
{
Boolean
(
error
)
}
isDisabled=
{
isDisabled
}
isDisabled=
{
isDisabled
}
autoComplete=
"off"
autoComplete=
"off"
maxLength=
{
6
}
maxLength=
{
7
}
/>
/>
<
InputPlaceholder
text=
{
placeholder
}
error=
{
error
}
/>
<
InputPlaceholder
text=
{
placeholder
}
error=
{
error
}
/>
<
InputRightElement
w=
"30px"
h=
"auto"
right=
{
4
}
top=
"50%"
transform=
"translateY(-50%)"
zIndex=
{
10
}
>
<
InputRightElement
w=
"30px"
h=
"auto"
right=
{
4
}
top=
"50%"
transform=
"translateY(-50%)"
zIndex=
{
10
}
>
<
Circle
<
Circle
size=
"30px"
size=
"30px"
bgColor=
{
value
&&
colorValidator
(
value
)
===
true
?
`#${ value }`
:
circleBgColorDefault
[
fieldType
]
}
bgColor=
{
value
&&
colorValidator
(
value
)
===
true
?
value
:
circleBgColorDefault
[
fieldType
]
}
borderColor=
"gray.300"
borderColor=
"gray.300"
borderWidth=
"1px"
borderWidth=
"1px"
/>
/>
...
...
ui/publicTags/submit/utils.ts
View file @
814b8333
...
@@ -23,8 +23,8 @@ export function convertFormDataToRequestsBody(data: FormFields): Array<SubmitReq
...
@@ -23,8 +23,8 @@ export function convertFormDataToRequestsBody(data: FormFields): Array<SubmitReq
tagType
:
tag
.
type
.
value
,
tagType
:
tag
.
type
.
value
,
description
:
data
.
description
,
description
:
data
.
description
,
meta
:
_pickBy
({
meta
:
_pickBy
({
bgColor
:
tag
.
bgColor
?
`#
${
tag
.
bgColor
}
`
:
undefined
,
bgColor
:
tag
.
bgColor
,
textColor
:
tag
.
textColor
?
`#
${
tag
.
textColor
}
`
:
undefined
,
textColor
:
tag
.
textColor
,
tagUrl
:
tag
.
url
,
tagUrl
:
tag
.
url
,
tooltipDescription
:
tag
.
tooltipDescription
,
tooltipDescription
:
tag
.
tooltipDescription
,
},
Boolean
),
},
Boolean
),
...
...
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