Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
Greenlight
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Arbeitsgruppe Hardwarenahe IT-Systeme
Greenlight
Commits
59763216
Unverified
Commit
59763216
authored
Nov 23, 2022
by
Samuel Couillard
Committed by
GitHub
Nov 23, 2022
Browse files
Options
Downloads
Patches
Plain Diff
Add Placeholder to Avatar (#4166)
* Add timer to avatar * Add suspense * Add loading state with onLoad
parent
33e3859e
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/javascript/components/users/user/Avatar.jsx
+24
-2
24 additions, 2 deletions
app/javascript/components/users/user/Avatar.jsx
with
24 additions
and
2 deletions
app/javascript/components/users/user/Avatar.jsx
+
24
−
2
View file @
59763216
import
React
from
'
react
'
;
/* eslint-disable react/jsx-no-bind */
import
React
,
{
useState
}
from
'
react
'
;
import
Image
from
'
react-bootstrap/Image
'
;
import
PropTypes
from
'
prop-types
'
;
import
{
Placeholder
}
from
'
react-bootstrap
'
;
export
default
function
Avatar
({
avatar
,
radius
,
className
})
{
const
[
isLoading
,
setIsLoading
]
=
useState
(
false
);
function
onLoad
()
{
setIsLoading
(
true
);
}
return
(
<
Image
src
=
{
avatar
}
roundedCircle
=
"true"
width
=
{
radius
}
height
=
{
radius
}
className
=
{
className
}
/>
<>
<
Image
src
=
{
avatar
}
roundedCircle
=
"true"
width
=
{
radius
}
height
=
{
radius
}
className
=
{
className
}
onLoad
=
{
onLoad
}
/>
{
!
isLoading
&&
(
<
Placeholder
animation
=
"glow"
className
=
"mb-3"
>
<
Placeholder
style
=
{
{
height
:
radius
,
width
:
radius
,
'
border-radius
'
:
'
50%
'
}
}
/>
</
Placeholder
>
)
}
</>
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment