Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F100963923
useBadge.js
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Tue, Feb 4, 08:55
Size
727 B
Mime Type
text/x-java
Expires
Thu, Feb 6, 08:55 (2 d)
Engine
blob
Format
Raw Data
Handle
24062812
Attached To
rOACCT Open Access Compliance Check Tool (OACCT)
useBadge.js
View Options
import
{
usePreviousProps
}
from
'@mui/utils'
;
export
default
function
useBadge
(
parameters
)
{
const
{
badgeContent
:
badgeContentProp
,
invisible
:
invisibleProp
=
false
,
max
:
maxProp
=
99
,
showZero
=
false
}
=
parameters
;
const
prevProps
=
usePreviousProps
({
badgeContent
:
badgeContentProp
,
max
:
maxProp
});
let
invisible
=
invisibleProp
;
if
(
invisibleProp
===
false
&&
badgeContentProp
===
0
&&
!
showZero
)
{
invisible
=
true
;
}
const
{
badgeContent
,
max
=
maxProp
}
=
invisible
?
prevProps
:
parameters
;
const
displayValue
=
badgeContent
&&
Number
(
badgeContent
)
>
max
?
`
$
{
max
}
+
`
:
badgeContent
;
return
{
badgeContent
,
invisible
,
max
,
displayValue
};
}
Event Timeline
Log In to Comment