
Product
A New Overview in our Dashboard
We redesigned Socket's first logged-in page to display rich and insightful visualizations about your repositories protected against supply chain threats.
@phntms/ft-react-components
Advanced tools
A collection of UI/utility React/NextJS components for Phantom FT sites
A collection of React/NextJS UI and utility components for Phantom FT sites.
Currently implemented:
Install this package with npm
.
npm i @phntms/ft-react-components
Add the provider to _app.tsx, pass the site's page content to PageViewData
import { FTTrackerProvider } from "@phntms/ft-react-components";
.
.
.
return (
<FTTrackerProvider>
<PageViewData pageProps={pageProps} />
<Component {...pageProps} />;
</FTTrackerProvider>
)
Construct the pageViewData object from the site content data. use setPageViewData and setTrackingOptions to update the tracker provider. See the Phantom FT partner tracking implementation guide for the full config object schema. TODO - consider moving to this lib with empty/default values and adding Yup validation to console error/eslint when incomplete.
import { useFTTracker, TrackingOptions, ConfigType } from "@phntms/ft-react-components";
.
.
const { setPageViewData, setTrackingOptions } = useFTTracker();
useEffect(() => {
const globals = pageProps.globals;
const article = pageProps.article;
const category = pageProps.category;
setTrackingOptions({
scrollTrackerSelector: "#o_tracker_scroll",
isCustomGTMEvent: false,
});
const errorValue = "404";
if (!setPageViewData) return;
setPageViewData({
advertiserIndustry: (globals && globals.sitewide.industry) || errorValue,
app:
(article && article.content_type) ||
(globals && globals.sitewide.homepage_label) ||
errorValue,
articleName:
(article && article.title) ||
(globals && globals.sitewide.homepage_label) ||
errorValue,
author:
.
.
.
} as ConfigType);
}, [pageProps]);
Video event tracking is handled by the videoTracker instance available from the useFTTracker
hook. It is currently only compatible with react-player
implementations which is the current standard player implementation for Phantom NextJS sites.
import { useFTTracker } from "@phntms/ft-react-components";
import ReactPlayer from "react-player";
.
.
const { videoTracker } = useFTTracker();
.
.
<ReactPlayer
controls
height="100%"
style={{ position: "absolute", top: 0, left: 0 }}
onDuration={videoTracker?.setDuration}
onEnded={videoTracker?.trackEnded}
onPause={videoTracker?.trackPause}
onPlay={videoTracker?.trackPlay}
onProgress={videoTracker?.trackProgress}
width="100%"
url={fileToURL(article.video)}
light={fileToURL(article.image)}
playIcon={<PlayIconCircle />}
onClick={handlePlayButtonClick}
/>
Loads the external permutive scripts, requires Permutive project specific IDs (environment variables) - add to the sites' _document.tsx
import { PermutiveSetup } from "@phntms/ft-react-components";
.
.
// Permutive tracking
const PERMUTIVE_PROJECT_ID = process.env.PERMUTIVE_PROJECT_ID || "";
const PERMUTIVE_PUBLIC_API_KEY = process.env.PERMUTIVE_PUBLIC_API_KEY || "";
.
.
render() {
return (
<Html lang="en">
<Head>
<FontPreloadEmbed />
<FaviconEmbed />
<TrackingHeadScript id={GA_TRACKING_ID} />
<PermutiveSetup
projectID={PERMUTIVE_PROJECT_ID}
publicAPIKey={PERMUTIVE_PUBLIC_API_KEY}
/>
.
.
Render in an appropriate page level component. FTPartnerContent requires 3 props as below to display the site's required partner links
import {
CookieMessage,
FTHeader,
FTFooter,
FTPartnerContent,
} from "@phntms/ft-react-components";
.
.
<Container>
<FTHeader />
<FTPartnerContent
siteUrl={globals.sitewide.url}
siteTitle={globals.sitewide.title}
partner={{
title: "Zurich",
url: "https://www.zurich.com/",
}}
/>
{showHero && <CategoryHero />}
<Navbar categories={globals.categories} selected={category} />
<div id="o_tracker_scroll">{children}</div>
<CookieMessage />
<FTFooter />
</Container>
NOTE: all 4 components rely on a single global .scss styles file, which needs to be loaded in _app.tsx
as a global import:
//load combined FT components styles as global
import "@phntms/ft-react-components/src/components/ft/styles/app.scss";
Additionally, some the components use styling from the @financial-times root components, so adding a node_modules sass path to NextJS's next.config.js
is required:
module.exports = {
//other config
sassOptions: {
includePaths: [
// Required by the @financial-times/o-<component> sass
path.resolve(__dirname, "./node_modules/@financial-times"),
],
},
};
Currently, the partner header icons need to be copied to the NextJS sites' /public/ft/partner-content folder
Implements the placeholder div and initialisation for Brandmetrics surveys.
NOTE: Surveys also require the separate Brandmetrics external CDN script to be loaded and available on window
.
import { BrandMetricsSurvey } from "@phntms/ft-react-components";
.
.
{article.brandmetrics_survey_id && (
<BrandMetricsSurvey surveyId={article.brandmetrics_survey_id}
/>
)}
Renders a styled img with with display:hidden and height:0
import { TrackingPixel } from "@phntms/ft-react-components";
.
.
{article.brandmetrics_pixel_url && (
<TrackingPixel src={article.brandmetrics_pixel_url} />
)}
FAQs
A collection of UI/utility React/NextJS components for Phantom FT sites
The npm package @phntms/ft-react-components receives a total of 57 weekly downloads. As such, @phntms/ft-react-components popularity was classified as not popular.
We found that @phntms/ft-react-components demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
We redesigned Socket's first logged-in page to display rich and insightful visualizations about your repositories protected against supply chain threats.
Product
Automatically fix and test dependency updates with socket fix—a new CLI tool that turns CVE alerts into safe, automated upgrades.
Security News
CISA denies CVE funding issues amid backlash over a new CVE foundation formed by board members, raising concerns about transparency and program governance.