Skip to content

feat(client): show loading skeleton #1218

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 63 additions & 35 deletions packages/client/src/pages/HomePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
Typography,
Button,
styled,
Skeleton,
ToggleTabsGroup,
TextField,
InputAdornment,
Expand Down Expand Up @@ -66,6 +67,14 @@ const StyledToggleTabsGroupItem = styled(ToggleTabsGroup.Item)(({ theme }) => ({
},
}));

const AppTileSkeleton = styled('div')(({ theme }) => ({
display: 'flex',
flexDirection: 'column',
margin: theme.spacing(1),
marginRight: theme.spacing(0.5),
marginTop: theme.spacing(5),
marginBottom: theme.spacing(5),
}));
type MODE = 'Mine' | 'Discoverable' | 'System';

const initialState = {
Expand Down Expand Up @@ -400,41 +409,60 @@ export const HomePage = observer((): JSX.Element => {
</StyledSectionLabel>
) : null}

{mode != 'System' && favoritedApps.length > 0 ? (
<StyledSection>
{favoritedApps.map((app, i) => {
return (
<AppTileCard
key={i}
app={app}
systemApp={false}
href={
mode === 'Discoverable'
? `#/app/${app.project_id}/detail`
: `#/app/${app.project_id}`
}
onAction={() => {
if (mode === 'Discoverable') {
navigate(
`/app/${app.project_id}/detail`,
);
} else {
navigate(
`/app/${app.project_id}`,
);
}
}}
appType={app.project_type}
isFavorite={isFavorited(app.project_id)}
favorite={() => {
favoriteApp(app);
}}
isDiscoverable={mode !== 'Mine'}
/>
);
})}
</StyledSection>
) : null}
{mode !== 'System' &&
(getFavoritedApps.status === 'LOADING' ||
favoritedApps.length > 0) && (
<StyledSection>
{getFavoritedApps.status === 'LOADING'
? Array.from({ length: 3 }).map((_, i) => (
<AppTileSkeleton key={i}>
<Skeleton
variant="rectangular"
width={250}
height={118}
/>
<Skeleton
width="100%"
height={25}
/>
<Skeleton
width="60%"
height={25}
/>
</AppTileSkeleton>
))
: favoritedApps.map((app) => (
<AppTileCard
key={app.project_id}
app={app}
systemApp={false}
href={
mode === 'Discoverable'
? `#/app/${app.project_id}/detail`
: `#/app/${app.project_id}`
}
onAction={() => {
if (mode === 'Discoverable') {
navigate(
`/app/${app.project_id}/detail`,
);
} else {
navigate(
`/app/${app.project_id}`,
);
}
}}
appType={app.project_type}
isFavorite={isFavorited(
app.project_id,
)}
favorite={() => {
favoriteApp(app);
}}
/>
))}
</StyledSection>
)}

{mode == 'System' && (
<StyledSectionLabel variant="subtitle1">
Expand Down