diff --git a/packages/common/src/index.ts b/packages/common/src/index.ts index f2e2587e7..2865f1756 100644 --- a/packages/common/src/index.ts +++ b/packages/common/src/index.ts @@ -20,6 +20,7 @@ export { default as filterCookiesByFrame } from './utils/filterCookiesByFrame'; export { default as prepareCookiesCount } from './utils/prepareCookiesCount'; export { default as prepareCookieStatsComponents } from './utils/prepareCookieStatsComponents'; export { default as getCookieKey } from './utils/getCookieKey'; +export { default as fetchLocalData } from './utils/fetchLocalData'; export { default as noop } from './utils/noop'; export * from './cookies.types'; export const UNKNOWN_FRAME_KEY = 'Unknown frame(s)'; diff --git a/packages/extension/src/utils/fetchLocalData.ts b/packages/common/src/utils/fetchLocalData.ts similarity index 100% rename from packages/extension/src/utils/fetchLocalData.ts rename to packages/common/src/utils/fetchLocalData.ts diff --git a/packages/design-system/src/components/index.ts b/packages/design-system/src/components/index.ts index 414e0a028..ad5cef50c 100644 --- a/packages/design-system/src/components/index.ts +++ b/packages/design-system/src/components/index.ts @@ -30,6 +30,8 @@ export { default as CookieDetails } from './cookieDetails'; export { default as Details } from './cookieDetails/details'; export { default as CookieTable } from './cookieTable'; export { default as LandingPage } from './landingPage'; +export { default as InfoCard } from './landingPage/infoCard'; +export * from './landingPage/infoCard/fetchPSInfo'; export { default as ErrorFallback } from './errorFallback'; export { default as ExtensionReloadNotification } from './errorFallback/extensionReloadNotification'; export * from './table'; diff --git a/packages/design-system/src/components/landingPage/index.tsx b/packages/design-system/src/components/landingPage/index.tsx index 4efd906f3..82404f8de 100644 --- a/packages/design-system/src/components/landingPage/index.tsx +++ b/packages/design-system/src/components/landingPage/index.tsx @@ -17,116 +17,99 @@ /** * External dependencies. */ -import React, { ReactNode, useEffect, useState } from 'react'; +import React, { ReactNode, useState } from 'react'; import classNames from 'classnames'; -import { XMLParser } from 'fast-xml-parser'; /** * Internal dependencies. */ -import { ArrowUp, ChevronRight } from '../../icons'; +import { ArrowUp } from '../../icons'; import ProgressBar from '../progressBar'; -import BulletList from '../bulletList'; -import { QUICK_LINKS } from './constants'; +import QuickLinksList from './quickLinksList'; +import { PSInfoKeyType } from './infoCard/fetchPSInfo'; +import InfoCard from './infoCard'; interface LandingPageProps { title?: string; children?: ReactNode; - isLoading?: boolean; + psInfoKey?: PSInfoKeyType; + iframeSrc?: string; + iframeBorderClass?: string; + extraClasses?: string; } -const LandingPage = ({ title, children, isLoading }: LandingPageProps) => { +const LandingPage = ({ + title, + psInfoKey, + iframeSrc, + iframeBorderClass, + children, + extraClasses, +}: LandingPageProps) => { + const [loading, setLoading] = useState(iframeSrc ? true : false); const [open, setOpen] = useState(true); - const [news, setNews] = useState([]); - - const fetchLatestNews = async () => { - try { - const response = await fetch('https://privacysandbox.com/rss/'); - const xmlResponse = await response.text(); - - const parser = new XMLParser(); - const parsedFeed = parser.parse(xmlResponse); - - const items = parsedFeed?.rss?.channel?.item; - - if (items) { - const newsArray = items - .map((item: BulletListItem) => ({ - title: item.title, - link: item.link, - date: item.pubDate ? new Date(item.pubDate).toISOString() : '', - })) // @ts-ignore - .sort((a, b) => b.date.localeCompare(a.date)); - - setNews(newsArray); - } - } catch (error) { - // Currently logging, but ideally inform user through UI. - console.warn('Error fetching latest news', error); - } - }; - - useEffect(() => { - fetchLatestNews(); - }, []); return ( <> - {isLoading && } -
-
-
- -
- - {/* Section Content */} + {loading && } +
+
+ +
+
- {children} -
-
- -
- {/* Quick Links */} -
- + {iframeSrc && ( +