Skip to content

Commit 77981b2

Browse files
Merge pull request #1063 from Financial-Times/base-styles-rethink
integrate ex-n-ui-foundations styles into dotcom-ui-base-styles
2 parents c199dd0 + f73897c commit 77981b2

File tree

27 files changed

+95
-282
lines changed

27 files changed

+95
-282
lines changed

examples/ft-ui/client/main.scss

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
// The base styles will be output in the shared css bundle, so
2-
// only include the required mixins and variables.
3-
@import 'n-ui-foundations/mixins';
1+
@import '@financial-times/o-typography/main';
42

53
p {
64
@include oTypographySans($scale: 7);

examples/ft-ui/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"@financial-times/dotcom-middleware-navigation": "file:../../packages/dotcom-middleware-navigation",
1717
"@financial-times/dotcom-ui-layout": "file:../../packages/dotcom-ui-layout",
1818
"@financial-times/dotcom-ui-shell": "file:../../packages/dotcom-ui-shell",
19+
"@financial-times/o-typography": "^7.6.2",
1920
"express": "^4.21.2",
2021
"react": "^17.0.2",
2122
"react-dom": "^17.0.2",
@@ -25,7 +26,6 @@
2526
"@financial-times/dotcom-build-base": "file:../../packages/dotcom-build-base",
2627
"@financial-times/dotcom-build-js": "file:../../packages/dotcom-build-js",
2728
"@financial-times/dotcom-build-sass": "file:../../packages/dotcom-build-sass",
28-
"n-ui-foundations": "^9.0.0",
2929
"nodemon": "^1.18.9",
3030
"ready-state": "^2.0.5",
3131
"webpack": "^5.88.2",

examples/kitchen-sink/__test__/build.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ describe('examples/kitchen-sink/build', () => {
2424
"shared.stable.bundle.js",
2525
"styles.css",
2626
"vendors.bundle.js",
27+
"vendors.css",
2728
"webpack-runtime.bundle.js",
2829
]
2930
`)

examples/kitchen-sink/client/main.scss

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
// The base styles will be output in the shared css bundle, so
2-
// only include the required mixins and variables.
3-
@import 'n-ui-foundations/mixins';
1+
@import '@financial-times/o-typography/main';
42

53
.hello {
64
@include oTypographySans($scale: 7);

examples/kitchen-sink/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"@financial-times/dotcom-ui-layout": "file:../../packages/dotcom-ui-layout",
2323
"@financial-times/dotcom-ui-shell": "file:../../packages/dotcom-ui-shell",
2424
"@financial-times/n-tracking": "7.2.1",
25+
"@financial-times/o-typography": "^7.6.2",
2526
"express": "^4.21.2",
2627
"react": "^17.0.2",
2728
"react-dom": "^17.0.2",
@@ -32,9 +33,7 @@
3233
"@financial-times/dotcom-build-code-splitting": "file:../../packages/dotcom-build-code-splitting",
3334
"@financial-times/dotcom-build-js": "file:../../packages/dotcom-build-js",
3435
"@financial-times/dotcom-build-sass": "file:../../packages/dotcom-build-sass",
35-
"@financial-times/o-header": "^11.1.0",
3636
"@sucrase/jest-plugin": "^2.0.0",
37-
"n-ui-foundations": "^9.0.0",
3837
"nodemon": "^1.18.9",
3938
"ready-state": "^2.0.5",
4039
"webpack": "^5.88.2",

package-lock.json

Lines changed: 15 additions & 54 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@
6363
"jest-puppeteer": "^11.0.0",
6464
"lint-staged": "^10.0.0",
6565
"morphdom": "^2.7.0",
66-
"n-ui-foundations": "9.0.0",
6766
"prettier": "^2.0.2",
6867
"puppeteer": "^24.1.0",
6968
"react": "^17.0.2",

packages/dotcom-build-code-splitting/src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ export class PageKitCodeSplittingPlugin {
7575
'ftdomdelegate',
7676
'morphdom',
7777
'n-topic-search',
78-
'n-ui-foundations',
7978
'ready-state'
8079
],
8180
usedInUnknownWay: true

packages/dotcom-build-sass/src/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ export class PageKitSassPlugin {
3434
// Prefer `dart-sass`.
3535
implementation: require(this.implementation),
3636
// Prepends SCSS code before the actual entry file.
37-
// Introduced to maintain snappy grid after n-ui-foundations removed it as the default.
38-
// Once user-facing apps and components move away from using snappy grid then this can be removed.
3937
additionalData: this.additionalData,
4038
sassOptions: {
4139
// Disable formatting so that we don't spend time pretty printing

packages/dotcom-ui-base-styles/README.md

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,30 @@
11
# @financial-times/dotcom-ui-base-styles
22

3-
This new package provides the global document styles for FT.com, including normalisation styles, basic typography, focus states, and `o-grid`.
4-
5-
_Please note_ the initial goal of this package is to centralise all of the required pieces for the progressive font loading technique provided by [`o-typography`](https://github.com/Financial-Times/o-typography/#progressive-loading-web-fonts) and create a placeholder for the future inclusion of global styles from `n-ui-foundations`.
6-
3+
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.
74

85
## Getting started
96

10-
This package is compatible with Node 12+ and is distributed on npm.
11-
127
```bash
138
npm install --save @financial-times/dotcom-ui-base-styles
149
```
1510

1611
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.
1712

18-
### Server-side
13+
## Usage in apps
14+
15+
### Styles
1916

20-
If you are using React to render your app you should use the `LoadFontsEmbed` component along with the `loadCustomFontsClassNames` and `documentStyles` variables to integrate font loading and document styles with your pages:
17+
`dotcom-ui-base-styles` provides styles which should be imported into your application's main stylesheet:
18+
19+
```scss
20+
@import '@financial-times/dotcom-ui-base-styles/styles';
21+
```
22+
23+
### Critical styles and font preloading
24+
25+
`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)](https://en.wikipedia.org/wiki/Flash_of_unstyled_content).
26+
27+
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:
2128

2229
```jsx
2330
import {
@@ -40,7 +47,7 @@ export default (props) => (
4047
)
4148
```
4249

43-
Otherwise you can insert the code snippet into a `<script>` element:
50+
Otherwise, you can insert the code snippet into a `<script>` element:
4451

4552
```js
4653
const {
@@ -64,20 +71,17 @@ function page() {
6471
}
6572
```
6673

67-
### Client-side
68-
69-
Once you are rendering the styles, class names, and code snippets in your page you will need to initialise the client-side code.
74+
### Client-side Javascript
7075

71-
To initialise the client-side JavaScript import the package and call the `.init()` method:
76+
`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:
7277

7378
```js
7479
import * as baseStyles from '@financial-times/dotcom-ui-base-styles'
7580

7681
baseStyles.init()
7782
```
7883

79-
This component also provides styles written in Sass which should be imported into your application's main Sass stylesheet:
84+
### Components
8085

81-
```scss
82-
@import '@financial-times/dotcom-ui-base-styles/styles';
83-
```
86+
> [!WARNING]
87+
> `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.

0 commit comments

Comments
 (0)