Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F101483636
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
Mon, Feb 10, 21:49
Size
727 B
Mime Type
text/x-java
Expires
Wed, Feb 12, 21:49 (2 d)
Engine
blob
Format
Raw Data
Handle
24162151
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