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
9fc9d175
Commit
9fc9d175
authored
Jul 09, 2024
by
Max Alekseenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move trigger button to separate file and rework
parent
c6293a41
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
46 deletions
+55
-46
Rating.tsx
ui/marketplace/Rating/Rating.tsx
+8
-46
TriggerButton.tsx
ui/marketplace/Rating/TriggerButton.tsx
+47
-0
No files found.
ui/marketplace/Rating/Rating.tsx
View file @
9fc9d175
import
{
import
{
Text
,
Popover
,
PopoverTrigger
,
PopoverBody
,
PopoverContent
,
useDisclosure
,
Skeleton
}
from
'
@chakra-ui/react
'
;
Text
,
Popover
,
PopoverTrigger
,
PopoverBody
,
PopoverContent
,
useDisclosure
,
Button
,
Skeleton
,
chakra
,
useColorModeValue
,
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
IconSvg
from
'
ui/shared/IconSvg
'
;
import
Content
from
'
./PopoverContent
'
;
import
Content
from
'
./PopoverContent
'
;
import
Stars
from
'
./Stars
'
;
import
Stars
from
'
./Stars
'
;
import
TriggerButton
from
'
./TriggerButton
'
;
type
Props
=
{
type
Props
=
{
appId
:
string
;
appId
:
string
;
...
@@ -23,8 +19,6 @@ type Props = {
...
@@ -23,8 +19,6 @@ type Props = {
const
Rating
=
({
appId
,
rating
,
recordId
,
isRatedByUser
,
rate
,
isSending
,
isLoading
,
fullView
}:
Props
)
=>
{
const
Rating
=
({
appId
,
rating
,
recordId
,
isRatedByUser
,
rate
,
isSending
,
isLoading
,
fullView
}:
Props
)
=>
{
const
{
isOpen
,
onToggle
,
onClose
}
=
useDisclosure
();
const
{
isOpen
,
onToggle
,
onClose
}
=
useDisclosure
();
const
textColor
=
useColorModeValue
(
'
blackAlpha.800
'
,
'
whiteAlpha.800
'
);
return
(
return
(
<
Skeleton
display=
"flex"
alignItems=
"center"
isLoaded=
{
!
isLoading
}
minW=
{
isLoading
?
'
40px
'
:
'
auto
'
}
>
<
Skeleton
display=
"flex"
alignItems=
"center"
isLoaded=
{
!
isLoading
}
minW=
{
isLoading
?
'
40px
'
:
'
auto
'
}
>
{
fullView
&&
(
{
fullView
&&
(
...
@@ -35,44 +29,12 @@ const Rating = ({ appId, rating, recordId, isRatedByUser, rate, isSending, isLoa
...
@@ -35,44 +29,12 @@ const Rating = ({ appId, rating, recordId, isRatedByUser, rate, isSending, isLoa
)
}
)
}
<
Popover
isOpen=
{
isOpen
}
onClose=
{
onClose
}
placement=
"bottom"
isLazy
>
<
Popover
isOpen=
{
isOpen
}
onClose=
{
onClose
}
placement=
"bottom"
isLazy
>
<
PopoverTrigger
>
<
PopoverTrigger
>
{
fullView
?
(
<
TriggerButton
<
Button
rating=
{
rating
}
size=
"sx"
fullView=
{
fullView
}
variant=
"outline"
isActive=
{
isOpen
}
border=
{
0
}
onClick=
{
onToggle
}
p=
{
0
}
/>
onClick=
{
onToggle
}
fontSize=
"md"
fontWeight=
"400"
ml=
{
3
}
>
Rate it!
</
Button
>
)
:
(
<
Button
size=
"xs"
variant=
"outline"
border=
{
0
}
p=
{
0
}
onClick=
{
onToggle
}
fontSize=
"sm"
fontWeight=
"500"
lineHeight=
"21px"
isActive=
{
isOpen
}
>
<
IconSvg
name=
{
rating
?
'
star_filled
'
:
'
star_outline
'
}
color=
{
rating
?
'
yellow.400
'
:
'
gray.400
'
}
boxSize=
{
5
}
mr=
{
1
}
/>
{
rating
?
(
<
chakra
.
span
color=
{
textColor
}
transition=
"inherit"
>
{
rating
}
</
chakra
.
span
>
)
:
(
'
Rate it!
'
)
}
</
Button
>
)
}
</
PopoverTrigger
>
</
PopoverTrigger
>
<
PopoverContent
w=
"274px"
>
<
PopoverContent
w=
"274px"
>
<
PopoverBody
p=
{
4
}
>
<
PopoverBody
p=
{
4
}
>
...
...
ui/marketplace/Rating/TriggerButton.tsx
0 → 100644
View file @
9fc9d175
import
{
Button
,
chakra
,
useColorModeValue
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
import
IconSvg
from
'
ui/shared/IconSvg
'
;
type
Props
=
{
rating
?:
number
;
fullView
?:
boolean
;
isActive
:
boolean
;
onClick
:
()
=>
void
;
};
const
TriggerButton
=
({
rating
,
fullView
,
isActive
,
onClick
}:
Props
,
ref
:
React
.
ForwardedRef
<
HTMLButtonElement
>
)
=>
{
const
textColor
=
useColorModeValue
(
'
blackAlpha.800
'
,
'
whiteAlpha.800
'
);
return
(
<
Button
ref=
{
ref
}
size=
"xs"
variant=
"outline"
border=
{
0
}
p=
{
0
}
onClick=
{
onClick
}
fontSize=
{
fullView
?
'
md
'
:
'
sm
'
}
fontWeight=
{
fullView
?
'
400
'
:
'
500
'
}
lineHeight=
"21px"
ml=
{
fullView
?
3
:
0
}
isActive=
{
isActive
}
>
{
!
fullView
&&
(
<
IconSvg
name=
{
rating
?
'
star_filled
'
:
'
star_outline
'
}
color=
{
rating
?
'
yellow.400
'
:
'
gray.400
'
}
boxSize=
{
5
}
mr=
{
1
}
/>
)
}
{
(
rating
&&
!
fullView
)
?
(
<
chakra
.
span
color=
{
textColor
}
transition=
"inherit"
>
{
rating
}
</
chakra
.
span
>
)
:
(
'
Rate it!
'
)
}
</
Button
>
);
};
export
default
React
.
forwardRef
(
TriggerButton
);
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