Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F99720851
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
Sun, Jan 26, 07:55
Size
727 B
Mime Type
text/x-java
Expires
Tue, Jan 28, 07:55 (2 d)
Engine
blob
Format
Raw Data
Handle
23813939
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