
Security News
Oxlint Introduces Type-Aware Linting Preview
Oxlint’s new preview brings type-aware linting powered by typescript-go, combining advanced TypeScript rules with native-speed performance.
@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";
FAQs
A collection of UI/utility React/NextJS components for Phantom FT sites
The npm package @phntms/ft-react-components receives a total of 1 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.
Security News
Oxlint’s new preview brings type-aware linting powered by typescript-go, combining advanced TypeScript rules with native-speed performance.
Security News
A new site reviews software projects to reveal if they’re truly FOSS, making complex licensing and distribution models easy to understand.
Security News
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.