You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/dotcom-ui-base-styles/README.md
+21-17Lines changed: 21 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,23 +1,30 @@
1
1
# @financial-times/dotcom-ui-base-styles
2
2
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.
7
4
8
5
## Getting started
9
6
10
-
This package is compatible with Node 12+ and is distributed on npm.
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.
17
12
18
-
### Server-side
13
+
## Usage in apps
14
+
15
+
### Styles
19
16
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:
`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:
21
28
22
29
```jsx
23
30
import {
@@ -40,7 +47,7 @@ export default (props) => (
40
47
)
41
48
```
42
49
43
-
Otherwise you can insert the code snippet into a `<script>` element:
50
+
Otherwise, you can insert the code snippet into a `<script>` element:
44
51
45
52
```js
46
53
const {
@@ -64,20 +71,17 @@ function page() {
64
71
}
65
72
```
66
73
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
70
75
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:
> `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