New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@financial-times/dotcom-ui-base-styles

Package Overview
Dependencies
Maintainers
0
Versions
123
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@financial-times/dotcom-ui-base-styles

This package provides the global document styles for FT.com, including normalisation styles, basic typography, and grid styles, provided by [Origami](https://github.com/financial-times/origami) components.

  • 12.3.4
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
1.8K
decreased by-0.82%
Maintainers
0
Weekly downloads
 
Created
Source

@financial-times/dotcom-ui-base-styles

This package provides the global document styles for FT.com, including normalisation styles, basic typography, and grid styles, provided by Origami components.

Getting started

npm install --save @financial-times/dotcom-ui-base-styles

After installing the package you can use it to embed the progressive font loading hooks and document styles into your pages on the server-side and initialise the font loading on client-side.

Usage in apps

Styles

dotcom-ui-base-styles provides styles which should be imported into your application's main stylesheet:

@import '@financial-times/dotcom-ui-base-styles/styles';

Critical styles and font preloading

dotcom-ui-base-styles allows apps to HTTP-preload Origami's fonts, and provides baseline styles to be rendered as a style attribute on the <html> tag, to reduce flash of unstyled content (FOUC).

If you are using React to render your app, render the LoadFontsEmbed component along with the loadCustomFontsClassNames and documentStyles variables to integrate font loading and document styles with your pages:

import {
  documentStyles
  LoadFontsEmbed,
  loadCustomFontsClassNames
} from '@financial-times/dotcom-ui-base-styles'

export default (props) => (
  <html className={loadCustomFontsClassNames} style={documentStyles}>
    <head>
      <meta charSet="utf-8" />
      <title>My Amazing Website</title>
      <LoadFontsEmbed />
    </head>
    <body>
      ...
    </body>
  </html>
)

Otherwise, you can insert the code snippet into a <script> element:

const {
  documentStyles
  loadCustomFontsJS,
  loadCustomFontsClassNames
} = require('@financial-times/dotcom-ui-base-styles')

function page() {
  return `<!DOCTYPE html>
    <html className=${loadCustomFontsClassNames} style=${documentStyles}>
    <head>
      <meta charset="utf-8">
      <title>My Amazing Website</title>
      <script>${loadCustomFontsJS}</script>
    </head>
    <body>
      ...
    </body>
  </html>`
}

Client-side Javascript

dotcom-ui-base-styles's font loader requires client-side Javascript to work. Import the package in your client-side entry point, and call the .init() method:

import * as baseStyles from '@financial-times/dotcom-ui-base-styles'

baseStyles.init()

Components

[!WARNING] n-ui-foundations, the predecessor of dotcom-ui-base-styles, provided common Origami dependencies for apps and components. dotcom-ui-base-styles only supports apps. For components, you should directly depend on and use the Origami components you require.

FAQs

Package last updated on 14 Feb 2025

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc