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
6d330329
Commit
6d330329
authored
Jul 11, 2024
by
Max Alekseenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update rating component
parent
9a524463
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
67 additions
and
53 deletions
+67
-53
check_circle.svg
icons/check_circle.svg
+0
-4
name.d.ts
public/icons/name.d.ts
+0
-1
MarketplaceAppCard.tsx
ui/marketplace/MarketplaceAppCard.tsx
+3
-3
MarketplaceAppModal.pw.tsx
ui/marketplace/MarketplaceAppModal.pw.tsx
+1
-1
MarketplaceAppModal.tsx
ui/marketplace/MarketplaceAppModal.tsx
+3
-3
MarketplaceAppTopBar.tsx
ui/marketplace/MarketplaceAppTopBar.tsx
+1
-1
MarketplaceList.tsx
ui/marketplace/MarketplaceList.tsx
+1
-1
PopoverContent.tsx
ui/marketplace/Rating/PopoverContent.tsx
+33
-17
Rating.tsx
ui/marketplace/Rating/Rating.tsx
+3
-3
Stars.tsx
ui/marketplace/Rating/Stars.tsx
+21
-18
Marketplace.tsx
ui/pages/Marketplace.tsx
+1
-1
No files found.
icons/check_circle.svg
deleted
100644 → 0
View file @
9a524463
<svg
xmlns=
"http://www.w3.org/2000/svg"
viewBox=
"0 0 32 32"
fill=
"none"
>
<path
d=
"M16 31a15 15 0 1 1 0-30 15 15 0 0 1 0 30Zm0-28a13 13 0 1 0 0 26 13 13 0 0 0 0-26Z"
fill=
"currentColor"
/>
<path
d=
"M13.67 22a1 1 0 0 1-.73-.32l-4.67-5a1 1 0 0 1 1.46-1.36l3.94 4.21 8.6-9.21a1 1 0 1 1 1.46 1.36l-9.33 10a1 1 0 0 1-.73.32Z"
fill=
"currentColor"
/>
</svg>
public/icons/name.d.ts
View file @
6d330329
...
...
@@ -26,7 +26,6 @@
|
"
brands/solidity_scan
"
|
"
burger
"
|
"
certified
"
|
"
check_circle
"
|
"
check
"
|
"
clock-light
"
|
"
clock
"
...
...
ui/marketplace/MarketplaceAppCard.tsx
View file @
6d330329
...
...
@@ -20,7 +20,7 @@ interface Props extends MarketplaceAppWithSecurityReport {
onAppClick
:
(
event
:
MouseEvent
,
id
:
string
)
=>
void
;
className
?:
string
;
showContractList
:
(
id
:
string
,
type
:
ContractListTypes
)
=>
void
;
isRatedByUser
:
boolean
;
userRating
:
number
|
undefined
;
rateApp
:
(
appId
:
string
,
recordId
:
string
|
undefined
,
rating
:
number
)
=>
void
;
isSendingRating
:
boolean
;
isRatingLoading
:
boolean
;
...
...
@@ -47,7 +47,7 @@ const MarketplaceAppCard = ({
showContractList
,
rating
,
ratingRecordId
,
isRatedByUser
,
userRating
,
rateApp
,
isSendingRating
,
isRatingLoading
,
...
...
@@ -175,7 +175,7 @@ const MarketplaceAppCard = ({
appId=
{
id
}
rating=
{
rating
}
recordId=
{
ratingRecordId
}
isRatedByUser=
{
isRatedByUser
}
userRating=
{
userRating
}
rate=
{
rateApp
}
isSending=
{
isSendingRating
}
isLoading=
{
isRatingLoading
}
...
...
ui/marketplace/MarketplaceAppModal.pw.tsx
View file @
6d330329
...
...
@@ -17,7 +17,7 @@ const props = {
securityReport
:
securityReportsMock
[
0
].
chainsData
[
'
1
'
],
}
as
MarketplaceAppWithSecurityReport
,
isFavorite
:
false
,
isRatedByUser
:
false
,
userRating
:
undefined
,
rateApp
:
()
=>
{},
isSendingRating
:
false
,
isRatingLoading
:
false
,
...
...
ui/marketplace/MarketplaceAppModal.tsx
View file @
6d330329
...
...
@@ -23,7 +23,7 @@ type Props = {
onFavoriteClick
:
(
id
:
string
,
isFavorite
:
boolean
,
source
:
'
App modal
'
)
=>
void
;
data
:
MarketplaceAppWithSecurityReport
;
showContractList
:
(
id
:
string
,
type
:
ContractListTypes
,
hasPreviousStep
:
boolean
)
=>
void
;
isRatedByUser
:
boolean
;
userRating
:
number
|
undefined
;
rateApp
:
(
appId
:
string
,
recordId
:
string
|
undefined
,
rating
:
number
)
=>
void
;
isSendingRating
:
boolean
;
isRatingLoading
:
boolean
;
...
...
@@ -36,7 +36,7 @@ const MarketplaceAppModal = ({
onFavoriteClick
,
data
,
showContractList
:
showContractListProp
,
isRatedByUser
,
userRating
,
rateApp
,
isSendingRating
,
isRatingLoading
,
...
...
@@ -170,7 +170,7 @@ const MarketplaceAppModal = ({
appId=
{
id
}
rating=
{
rating
}
recordId=
{
ratingRecordId
}
isRatedByUser=
{
isRatedByUser
}
userRating=
{
userRating
}
rate=
{
rateApp
}
isSending=
{
isSendingRating
}
isLoading=
{
isRatingLoading
}
...
...
ui/marketplace/MarketplaceAppTopBar.tsx
View file @
6d330329
...
...
@@ -91,7 +91,7 @@ const MarketplaceAppTopBar = ({ appId, data, isLoading, securityReport }: Props)
appId=
{
appId
}
rating=
{
ratings
?.[
appId
]?.
rating
}
recordId=
{
ratings
?.[
appId
]?.
recordId
}
isRatedByUser=
{
Boolean
(
userRatings
[
appId
])
}
userRating=
{
userRatings
[
appId
]
}
rate=
{
rateApp
}
isSending=
{
isSendingRating
}
isLoading=
{
isRatingLoading
}
...
...
ui/marketplace/MarketplaceList.tsx
View file @
6d330329
...
...
@@ -68,7 +68,7 @@ const MarketplaceList = ({
showContractList=
{
showContractList
}
rating=
{
app
.
rating
}
ratingRecordId=
{
app
.
ratingRecordId
}
isRatedByUser=
{
Boolean
(
userRatings
[
app
.
id
])
}
userRating=
{
userRatings
[
app
.
id
]
}
rateApp=
{
rateApp
}
isSendingRating=
{
isSendingRating
}
isRatingLoading=
{
isRatingLoading
}
...
...
ui/marketplace/Rating/PopoverContent.tsx
View file @
6d330329
import
{
Text
,
Flex
,
Spinner
}
from
'
@chakra-ui/react
'
;
import
{
Text
,
Flex
,
Spinner
,
Button
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
import
IconSvg
from
'
ui/shared/IconSvg
'
;
import
Stars
from
'
./Stars
'
;
const
ratingDescriptions
=
[
'
Terrible
'
,
'
Poor
'
,
'
Average
'
,
'
Very good
'
,
'
Outstanding
'
];
...
...
@@ -10,32 +8,47 @@ const ratingDescriptions = [ 'Terrible', 'Poor', 'Average', 'Very good', 'Outsta
type
Props
=
{
appId
:
string
;
recordId
?:
string
;
isRatedByUser
?:
boolean
;
userRating
:
number
|
undefined
;
rate
:
(
appId
:
string
,
recordId
:
string
|
undefined
,
rating
:
number
)
=>
void
;
isSending
?:
boolean
;
};
const
PopoverContent
=
({
appId
,
recordId
,
isRatedByUser
,
rate
,
isSending
}:
Props
)
=>
{
const
PopoverContent
=
({
appId
,
recordId
,
userRating
,
rate
,
isSending
}:
Props
)
=>
{
const
[
hovered
,
setHovered
]
=
React
.
useState
(
-
1
);
const
[
selected
,
setSelected
]
=
React
.
useState
(
-
1
);
const
handleMouseOverFactory
=
React
.
useCallback
((
index
:
number
)
=>
()
=>
{
setHovered
(
index
);
},
[]);
const
handleSelectFactory
=
React
.
useCallback
((
index
:
number
)
=>
()
=>
{
setSelected
(
index
);
},
[]);
const
handleMouseOut
=
React
.
useCallback
(()
=>
{
setHovered
(
-
1
);
},
[]);
const
handleRateFactory
=
React
.
useCallback
((
index
:
number
)
=>
()
=>
{
rate
(
appId
,
recordId
,
index
+
1
);
},
[
appId
,
recordId
,
rate
]);
const
handleRate
=
React
.
useCallback
(()
=>
{
if
(
selected
<
0
)
{
return
;
}
rate
(
appId
,
recordId
,
selected
+
1
);
},
[
appId
,
recordId
,
selected
,
rate
]);
if
(
isRatedByUser
)
{
if
(
userRating
)
{
return
(
<
Flex
alignItems=
"center"
>
<
IconSvg
name=
"check_circle"
color=
"green.500"
boxSize=
{
8
}
/>
<
Text
fontSize=
"md"
ml=
{
3
}
>
App is already rated
</
Text
>
</
Flex
>
<>
<
Text
fontWeight=
"500"
fontSize=
"xs"
lineHeight=
"30px"
variant=
"secondary"
>
App is already rated by you
</
Text
>
<
Flex
alignItems=
"center"
h=
"32px"
>
<
Stars
filledIndex=
{
userRating
-
1
}
/>
<
Text
fontSize=
"md"
ml=
{
2
}
>
{
ratingDescriptions
[
userRating
-
1
]
}
</
Text
>
</
Flex
>
</>
);
}
...
...
@@ -55,17 +68,20 @@ const PopoverContent = ({ appId, recordId, isRatedByUser, rate, isSending }: Pro
</
Text
>
<
Flex
alignItems=
"center"
h=
"32px"
>
<
Stars
filledIndex=
{
hovered
}
filledIndex=
{
hovered
>=
0
?
hovered
:
selected
}
onMouseOverFactory=
{
handleMouseOverFactory
}
onMouseOut=
{
handleMouseOut
}
onClickFactory=
{
handle
Rate
Factory
}
onClickFactory=
{
handle
Select
Factory
}
/>
{
hovered
>=
0
&&
(
{
(
hovered
>=
0
||
selected
>=
0
)
&&
(
<
Text
fontSize=
"md"
ml=
{
2
}
>
{
ratingDescriptions
[
hovered
]
}
{
ratingDescriptions
[
hovered
>=
0
?
hovered
:
selected
]
}
</
Text
>
)
}
</
Flex
>
<
Button
size=
"sm"
px=
{
4
}
mt=
{
3
}
onClick=
{
handleRate
}
isDisabled=
{
selected
<
0
}
>
Rate it
</
Button
>
</>
);
};
...
...
ui/marketplace/Rating/Rating.tsx
View file @
6d330329
...
...
@@ -11,7 +11,7 @@ type Props = {
appId
:
string
;
rating
?:
number
;
recordId
?:
string
;
isRatedByUser
?:
boolean
;
userRating
:
number
|
undefined
;
rate
:
(
appId
:
string
,
recordId
:
string
|
undefined
,
rating
:
number
)
=>
void
;
isSending
?:
boolean
;
isLoading
?:
boolean
;
...
...
@@ -20,7 +20,7 @@ type Props = {
};
const
Rating
=
({
appId
,
rating
,
recordId
,
isRatedByUser
,
rate
,
appId
,
rating
,
recordId
,
userRating
,
rate
,
isSending
,
isLoading
,
fullView
,
canRate
,
}:
Props
)
=>
{
const
{
isOpen
,
onToggle
,
onClose
}
=
useDisclosure
();
...
...
@@ -53,7 +53,7 @@ const Rating = ({
<
Content
appId=
{
appId
}
recordId=
{
recordId
}
isRatedByUser=
{
isRatedByUser
}
userRating=
{
userRating
}
rate=
{
rate
}
isSending=
{
isSending
}
/>
...
...
ui/marketplace/Rating/Stars.tsx
View file @
6d330329
...
...
@@ -10,23 +10,26 @@ type Props = {
onClickFactory
?:
(
index
:
number
)
=>
MouseEventHandler
<
HTMLDivElement
>
;
};
const
Stars
=
({
filledIndex
,
onMouseOverFactory
,
onMouseOut
,
onClickFactory
}:
Props
)
=>
(
<>
{
Array
(
5
).
fill
(
null
).
map
((
_
,
index
)
=>
(
<
IconSvg
key=
{
index
}
name=
{
filledIndex
>=
index
?
'
star_filled
'
:
'
star_outline
'
}
color=
{
filledIndex
>=
index
?
'
yellow.400
'
:
'
gray.400
'
}
w=
{
6
}
// 5 + 1 padding
h=
{
5
}
pr=
{
1
}
// use padding intead of margin so that there are no empty spaces between stars without hover effect
cursor=
{
onMouseOverFactory
?
'
pointer
'
:
'
default
'
}
onMouseOver=
{
onMouseOverFactory
?.(
index
)
}
onMouseOut=
{
onMouseOut
}
onClick=
{
onClickFactory
?.(
index
)
}
/>
))
}
</>
);
const
Stars
=
({
filledIndex
,
onMouseOverFactory
,
onMouseOut
,
onClickFactory
}:
Props
)
=>
{
const
outlineStartColor
=
onMouseOverFactory
?
'
gray.400
'
:
'
gray.200
'
;
return
(
<>
{
Array
(
5
).
fill
(
null
).
map
((
_
,
index
)
=>
(
<
IconSvg
key=
{
index
}
name=
{
filledIndex
>=
index
?
'
star_filled
'
:
'
star_outline
'
}
color=
{
filledIndex
>=
index
?
'
yellow.400
'
:
outlineStartColor
}
w=
{
6
}
// 5 + 1 padding
h=
{
5
}
pr=
{
1
}
// use padding intead of margin so that there are no empty spaces between stars without hover effect
cursor=
{
onMouseOverFactory
?
'
pointer
'
:
'
default
'
}
onMouseOver=
{
onMouseOverFactory
?.(
index
)
}
onMouseOut=
{
onMouseOut
}
onClick=
{
onClickFactory
?.(
index
)
}
/>
))
}
</>
);
};
export
default
Stars
;
ui/pages/Marketplace.tsx
View file @
6d330329
...
...
@@ -233,7 +233,7 @@ const Marketplace = () => {
onFavoriteClick=
{
onFavoriteClick
}
data=
{
selectedApp
}
showContractList=
{
showContractList
}
isRatedByUser=
{
Boolean
(
userRatings
[
selectedApp
.
id
])
}
userRating=
{
userRatings
[
selectedApp
.
id
]
}
rateApp=
{
rateApp
}
isSendingRating=
{
isSendingRating
}
isRatingLoading=
{
isRatingLoading
}
...
...
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