diff --git a/packages/i18n/strings/en.json b/packages/i18n/strings/en.json index 6ae42d16d..b63495ab6 100644 --- a/packages/i18n/strings/en.json +++ b/packages/i18n/strings/en.json @@ -809,6 +809,7 @@ "login": "Login to use this", "search_bar_hint": "Search tanks...", "recent": "Recently viewed", + "recent_empty": "Tanks you view will show up here", "select_all": "Select all", "count_singular": "1 tank", "count_plural": "{count} tanks", diff --git a/packages/website/src/components/RecentlyViewedTanks/index.module.css b/packages/website/src/components/RecentlyViewedTanks/index.module.css index 2ed68eecc..5b46cc3e0 100644 --- a/packages/website/src/components/RecentlyViewedTanks/index.module.css +++ b/packages/website/src/components/RecentlyViewedTanks/index.module.css @@ -3,20 +3,38 @@ flex-direction: column; gap: var(--space-4); + box-sizing: border-box; padding: var(--space-4); - - background-color: var(--gray-a2); - - border-radius: var(--space-3); - + min-width: 100%; width: fit-content; + background-color: var(--gray-a2); + border-radius: var(--space-3); + .list { + --min-tank-card-size: 7rem; + display: flex; gap: var(--space-4); - width: fit-content; + width: 100%; + min-width: fit-content; - --min-tank-card-size: 7rem; + &[data-empty="true"] { + position: relative; + } + + .placeholder { + visibility: hidden; + } + + .message { + position: absolute; + inset: 0; + + display: flex; + justify-content: center; + align-items: center; + } } } diff --git a/packages/website/src/components/RecentlyViewedTanks/index.tsx b/packages/website/src/components/RecentlyViewedTanks/index.tsx index 41cbf7dd7..4f8be6366 100644 --- a/packages/website/src/components/RecentlyViewedTanks/index.tsx +++ b/packages/website/src/components/RecentlyViewedTanks/index.tsx @@ -2,11 +2,14 @@ import { isEqual } from "lodash-es"; import { useMemo } from "react"; import { api } from "../../api/dynamic"; import { withLocale } from "../../hocs/withLocale"; +import { useMounted } from "../../hooks/useMounted"; import { useStrings } from "../../hooks/useStrings"; import { TankFilters } from "../../stores/tankFilters"; import { TankopediaPersistent } from "../../stores/tankopediaPersistent"; import { TankSort } from "../../stores/tankopediaSort"; import { TankCard } from "../TankCard"; +import { TankCardSkeleton } from "../TankCardSkeleton"; +import { MAX_RECENTLY_VIEWED } from "../TankSearchResults/constants"; import { Text } from "../Text"; import styles from "./index.module.css"; @@ -15,6 +18,7 @@ const tankDefinitions = await api.tanks(); export const RecentlyViewedTanks = withLocale(Content); function Content() { + const mounted = useMounted(); const filters = TankFilters.use(); // non-reactive because it is a little weird that it updates instantly even before the page loads const recentlyViewed = TankopediaPersistent.state.recentlyViewed.filter( @@ -34,7 +38,7 @@ function Content() { const strings = useStrings(); const by = TankSort.use((state) => state.by); - if (recentlyViewed.length === 0 || by !== null || hasFilters) { + if (by !== null || hasFilters) { return null; } @@ -44,10 +48,29 @@ function Content() { {strings.website.common.tank_search.recent} -