Skip to content

Commit

Permalink
fix(home): broken home skeleton (#523)
Browse files Browse the repository at this point in the history
refactor(project): correct loading skeleton in shelf and card

refactor(project): shelf title ternary readability

refactor(project): revert loading state for scheduled start date

Co-authored-by: Roy Schut <roy@videodock.com>
  • Loading branch information
MelissaDTH and royschut authored May 6, 2024
1 parent 1ce7c5b commit 35cd2db
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
6 changes: 3 additions & 3 deletions packages/hooks-react/src/usePlaylists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ const placeholderData = generatePlaylistPlaceholder(30);

type UsePlaylistResult = {
data: Playlist | undefined;
isLoading: boolean;
isSuccess?: boolean;
error?: unknown;
isPlaceholderData?: boolean;
}[];

const usePlaylists = (content: Content[], rowsToLoad: number | undefined = undefined) => {
Expand Down Expand Up @@ -57,13 +57,13 @@ const usePlaylists = (content: Content[], rowsToLoad: number | undefined = undef
if (type === PersonalShelf.Favorites) return { data: favorites, isLoading: false, isSuccess: true };
if (type === PersonalShelf.ContinueWatching) return { data: watchHistory, isLoading: false, isSuccess: true };

const { data, isLoading, isSuccess, error } = playlistQueries[index];
const { data, isSuccess, error, isPlaceholderData } = playlistQueries[index];

return {
data,
isLoading,
isSuccess,
error,
isPlaceholderData,
};
});

Expand Down
10 changes: 10 additions & 0 deletions packages/ui-react/src/components/Shelf/Shelf.module.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@use '@jwp/ott-ui-react/src/styles/theme';

.shelf {
margin: 0 0;
color: var(--primary-color);
Expand All @@ -15,6 +17,14 @@
}
}

.loadingTitle {
width: 35%;
min-height: 28px;
margin-bottom: 12px;
background-color: theme.$card-loading-bg-color;
border-radius: 5px;
};

.title {
width: 100%;
min-height: 28px;
Expand Down
2 changes: 1 addition & 1 deletion packages/ui-react/src/components/Shelf/Shelf.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ const Shelf = ({

return (
<div className={classNames(styles.shelf)}>
{!featured ? <h2 className={classNames(styles.title)}>{title || playlist.title}</h2> : null}
{featured ? null : loading ? <div className={styles.loadingTitle} /> : <h2 className={classNames(styles.title)}>{title || playlist.title}</h2>}
<TileDock<PlaylistItem>
items={playlist.playlist}
tilesToShow={tilesToShow}
Expand Down
4 changes: 2 additions & 2 deletions packages/ui-react/src/containers/ShelfList/ShelfList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const ShelfList = ({ rows }: Props) => {
loader={<InfiniteScrollLoader key="loader" />}
>
{rows.slice(0, rowsToLoad).map(({ type, featured, title }, index) => {
const { data: playlist, isLoading, error } = playlists[index];
const { data: playlist, isPlaceholderData, error } = playlists[index];

if (!playlist?.playlist?.length) return null;

Expand All @@ -76,7 +76,7 @@ const ShelfList = ({ rows }: Props) => {
aria-label={title || playlist?.title}
>
<Shelf
loading={isLoading}
loading={isPlaceholderData}
error={error}
type={type}
playlist={playlist}
Expand Down

0 comments on commit 35cd2db

Please sign in to comment.