@financial-times/dotcom-ui-layout 7.3.0 → 7.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@financial-times/dotcom-ui-layout",
3
- "version": "7.3.0",
3
+ "version": "7.3.2",
4
4
  "description": "",
5
5
  "main": "component.js",
6
6
  "browser": "browser.js",
@@ -8,13 +8,12 @@
8
8
  "styles": "styles.scss",
9
9
  "scripts": {
10
10
  "test": "echo \"Error: no test specified\" && exit 1",
11
- "tsc": "../../node_modules/.bin/tsc --incremental",
12
11
  "clean": "npm run clean:dist && npm run clean:node_modules",
13
12
  "clean:dist": "rm -rf dist",
14
13
  "clean:node_modules": "rm -rf node_modules",
15
14
  "clean:install": "npm run clean && npm i",
16
- "build:node": "npm run tsc -- --module commonjs --outDir ./dist/node",
17
- "build:browser": "npm run tsc -- --module es2015 --outDir ./dist/browser",
15
+ "build:browser": "tsc --module es2015 --outDir ./dist/browser",
16
+ "build:node": "tsc",
18
17
  "build": "npm run build:node && npm run build:browser",
19
18
  "dev": "echo -n node browser | parallel -u -d ' ' npm run build:{} -- --watch",
20
19
  "preinstall": "[ \"$INIT_CWD\" != \"$PWD\" ] || npm_config_yes=true npx check-engine"
@@ -23,10 +22,10 @@
23
22
  "author": "",
24
23
  "license": "MIT",
25
24
  "dependencies": {
26
- "@financial-times/dotcom-types-navigation": "^7.3.0",
27
- "@financial-times/dotcom-ui-base-styles": "^7.3.0",
28
- "@financial-times/dotcom-ui-footer": "^7.3.0",
29
- "@financial-times/dotcom-ui-header": "^7.3.0",
25
+ "@financial-times/dotcom-types-navigation": "file:../dotcom-types-navigation",
26
+ "@financial-times/dotcom-ui-base-styles": "file:../dotcom-ui-base-styles",
27
+ "@financial-times/dotcom-ui-footer": "file:../dotcom-ui-footer",
28
+ "@financial-times/dotcom-ui-header": "file:../dotcom-ui-header",
30
29
  "focus-visible": "^5.0.0",
31
30
  "n-ui-foundations": "^9.0.0"
32
31
  },
@@ -37,6 +36,13 @@
37
36
  "node": ">= 14.0.0",
38
37
  "npm": "7.x || 8.x"
39
38
  },
39
+ "files": [
40
+ "dist/",
41
+ "src/",
42
+ "browser.js",
43
+ "component.js",
44
+ "styles.scss"
45
+ ],
40
46
  "repository": {
41
47
  "type": "git",
42
48
  "repository": "https://github.com/Financial-Times/dotcom-page-kit.git",
@@ -50,4 +56,4 @@
50
56
  "check-engine": "^1.10.1",
51
57
  "react": "^16.8.6"
52
58
  }
53
- }
59
+ }
@@ -0,0 +1,38 @@
1
+ .demo {
2
+ text-align: center;
3
+ }
4
+
5
+ .demo__message {
6
+ display: inline-block;
7
+ margin: 50px 0;
8
+ padding: 1em;
9
+ border: 1px solid currentColor;
10
+ border-radius: 0.5em;
11
+
12
+ text-align: center;
13
+ font-size: 24px;
14
+
15
+ &:before,
16
+ &:after {
17
+ padding: 0 1em;
18
+ font-size: 75%;
19
+ }
20
+ }
21
+
22
+ .demo__message--scroll {
23
+ margin-bottom: 2000px;
24
+ border: none;
25
+
26
+ &:before,
27
+ &:after {
28
+ content: '▼';
29
+ }
30
+ }
31
+
32
+ .extra {
33
+ margin: 0;
34
+ padding: 0.5em;
35
+ text-align: center;
36
+ background: cornflowerblue;
37
+ color: white;
38
+ }
@@ -0,0 +1,110 @@
1
+ import React from 'react'
2
+ import { OnReady } from '../../../../.storybook/components/OnReady'
3
+
4
+ import './demos.scss'
5
+ import '../../styles.scss'
6
+
7
+ import * as layout from '../../browser'
8
+
9
+ import { navigationProps } from '../../../../__fixtures__/navigation'
10
+
11
+ import { Layout } from '..'
12
+
13
+ const Extra = ({ children }) => <p className="extra">{children}</p>
14
+
15
+ const initUiComponents = () => {
16
+ layout.init()
17
+ }
18
+
19
+ export default {
20
+ title: 'FT / Layout'
21
+ }
22
+
23
+ export const DefaultComponents = (args) => {
24
+ return (
25
+ <OnReady callback={initUiComponents}>
26
+ <Layout navigationData={navigationProps} {...args}>
27
+ <main className="demo">
28
+ <p className="demo__message">Defaults: only passing data</p>
29
+ </main>
30
+ </Layout>
31
+ </OnReady>
32
+ )
33
+ }
34
+
35
+ DefaultComponents.story = {
36
+ name: 'Default components'
37
+ }
38
+ DefaultComponents.args = {
39
+ headerVariant: 'simple',
40
+ footerVariant: 'simple'
41
+ }
42
+ DefaultComponents.argTypes = {
43
+ headerVariant: {
44
+ control: {
45
+ type: 'select',
46
+ options: {
47
+ Simple: 'simple',
48
+ 'Large Logo': 'large-logo',
49
+ 'Logo Only': 'logo-only',
50
+ None: ''
51
+ }
52
+ }
53
+ },
54
+ footerVariant: {
55
+ control: {
56
+ type: 'select',
57
+ options: {
58
+ Simple: 'simple',
59
+ Legal: 'legal',
60
+ None: ''
61
+ }
62
+ }
63
+ }
64
+ }
65
+
66
+ export const CustomSlots = () => {
67
+ return (
68
+ <OnReady callback={initUiComponents}>
69
+ <Layout
70
+ navigationData={navigationProps}
71
+ headerBefore={<Extra>Header before</Extra>}
72
+ headerAfter={<Extra>Header after</Extra>}
73
+ footerBefore={<Extra>Footer before</Extra>}
74
+ footerAfter={<Extra>Footer after</Extra>}>
75
+ <main className="demo">
76
+ <p className="demo__message">Custom content slots</p>
77
+ </main>
78
+ </Layout>
79
+ </OnReady>
80
+ )
81
+ }
82
+
83
+ CustomSlots.story = {
84
+ name: 'Custom slots'
85
+ }
86
+ CustomSlots.parameters = {
87
+ controls: { hideNoControlsWarning: true }
88
+ }
89
+
90
+ export const CustomComponents = () => {
91
+ return (
92
+ <OnReady callback={initUiComponents}>
93
+ <Layout
94
+ navigationData={navigationProps}
95
+ headerComponent={<Extra>Custom header</Extra>}
96
+ footerComponent={<Extra>Custom footer</Extra>}>
97
+ <main className="demo">
98
+ <p className="demo__message">Custom components</p>
99
+ </main>
100
+ </Layout>
101
+ </OnReady>
102
+ )
103
+ }
104
+
105
+ CustomComponents.story = {
106
+ name: 'Custom components'
107
+ }
108
+ CustomComponents.parameters = {
109
+ controls: { hideNoControlsWarning: true }
110
+ }
@@ -0,0 +1,227 @@
1
+ /**
2
+ * @jest-environment jsdom
3
+ */
4
+ import 'jest-enzyme'
5
+ import React from 'react'
6
+ import { shallow } from 'enzyme'
7
+
8
+ import { Layout as Subject } from '../Layout'
9
+ import { Header, Drawer, LogoOnly, NoOutboundLinksHeader } from '@financial-times/dotcom-ui-header'
10
+ import { Footer, LegalFooter } from '@financial-times/dotcom-ui-footer'
11
+
12
+ describe('dotcom-ui-layout/src/components/Layout', () => {
13
+ const result = shallow(<Subject />)
14
+
15
+ it('renders skip links to page landmarks', () => {
16
+ expect(result.find('a[href="#site-navigation"]')).toHaveText('Skip to navigation')
17
+ expect(result.find('a[href="#site-content"]')).toHaveText('Skip to content')
18
+ expect(result.find('a[href="#site-footer"]')).toHaveText('Skip to footer')
19
+ })
20
+
21
+ it('renders the header and drawer components', () => {
22
+ expect(result.find(Header)).toExist()
23
+ expect(result.find(Drawer)).toExist()
24
+ })
25
+
26
+ it('renders the footer component', () => {
27
+ expect(result.find(Footer)).toExist()
28
+ })
29
+
30
+ describe('header variations', () => {
31
+ describe('with the simple variant', () => {
32
+ let result
33
+
34
+ beforeAll(() => {
35
+ result = shallow(<Subject headerVariant={'simple' as any} />)
36
+ })
37
+
38
+ it('renders the header component', () => {
39
+ expect(result.find(Header)).toExist()
40
+ })
41
+
42
+ it('renders the drawer component', () => {
43
+ expect(result.find(Drawer)).toExist()
44
+ })
45
+
46
+ it('renders the navigation skip link', () => {
47
+ expect(result.find('a[href="#site-navigation"]')).toExist()
48
+ })
49
+ })
50
+
51
+ describe('with the large-logo variant', () => {
52
+ let result
53
+
54
+ beforeAll(() => {
55
+ result = shallow(<Subject headerVariant={'large-logo' as any} />)
56
+ })
57
+
58
+ it('renders the header component', () => {
59
+ expect(result.find(Header)).toExist()
60
+ })
61
+
62
+ it('renders the drawer component', () => {
63
+ expect(result.find(Drawer)).toExist()
64
+ })
65
+
66
+ it('renders the navigation skip link', () => {
67
+ expect(result.find('a[href="#site-navigation"]')).toExist()
68
+ })
69
+ })
70
+
71
+ describe('with the logo-only variant', () => {
72
+ let result
73
+
74
+ beforeAll(() => {
75
+ result = shallow(<Subject headerVariant={'logo-only' as any} />)
76
+ })
77
+
78
+ it('renders the logo only header component', () => {
79
+ expect(result.find(LogoOnly)).toExist()
80
+ })
81
+
82
+ it('does not render the drawer component', () => {
83
+ expect(result.find(Drawer)).not.toExist()
84
+ })
85
+
86
+ it('does not render the navigation skip link', () => {
87
+ expect(result.find('a[href="#site-navigation"]')).not.toExist()
88
+ })
89
+ })
90
+
91
+ describe('with the no-outbound-links variant', () => {
92
+ let result
93
+
94
+ beforeAll(() => {
95
+ result = shallow(<Subject headerVariant={'no-outbound-links' as any} />)
96
+ })
97
+
98
+ it('renders the no-outbound-links header component', () => {
99
+ expect(result.find(NoOutboundLinksHeader)).toExist()
100
+ })
101
+
102
+ it('does not render the drawer component', () => {
103
+ expect(result.find(Drawer)).not.toExist()
104
+ })
105
+
106
+ it('does not render the navigation skip link', () => {
107
+ expect(result.find('a[href="#site-navigation"]')).not.toExist()
108
+ })
109
+ })
110
+
111
+ describe('with the header disabled', () => {
112
+ let result
113
+
114
+ beforeAll(() => {
115
+ result = shallow(<Subject headerVariant={false} />)
116
+ })
117
+
118
+ it('does not render the header component', () => {
119
+ expect(result.find(Header)).not.toExist()
120
+ })
121
+
122
+ it('does not render the drawer component', () => {
123
+ expect(result.find(Drawer)).not.toExist()
124
+ })
125
+
126
+ it('does not render the navigation skip link', () => {
127
+ expect(result.find('a[href="#site-navigation"]')).not.toExist()
128
+ })
129
+ })
130
+
131
+ describe('with a custom header component', () => {
132
+ let result
133
+
134
+ beforeAll(() => {
135
+ const customHeader = <header>My custom header</header>
136
+ result = shallow(<Subject headerComponent={customHeader} />)
137
+ })
138
+
139
+ it('renders the given component', () => {
140
+ expect(result.find('header')).toHaveText('My custom header')
141
+ })
142
+
143
+ it('does not render the header component', () => {
144
+ expect(result.find(Header)).not.toExist()
145
+ })
146
+
147
+ it('does not render the drawer component', () => {
148
+ expect(result.find(Drawer)).not.toExist()
149
+ })
150
+
151
+ it('does not render the navigation skip link', () => {
152
+ expect(result.find('a[href="#site-navigation"]')).not.toExist()
153
+ })
154
+ })
155
+ })
156
+
157
+ describe('footer variations', () => {
158
+ describe('with the simple variant', () => {
159
+ let result
160
+
161
+ beforeAll(() => {
162
+ result = shallow(<Subject footerVariant={'simple' as any} />)
163
+ })
164
+
165
+ it('renders the footer component', () => {
166
+ expect(result.find(Footer)).toExist()
167
+ })
168
+
169
+ it('renders the footer skip link', () => {
170
+ expect(result.find('a[href="#site-footer"]')).toExist()
171
+ })
172
+ })
173
+
174
+ describe('with the legal variant', () => {
175
+ let result
176
+
177
+ beforeAll(() => {
178
+ result = shallow(<Subject footerVariant={'legal' as any} />)
179
+ })
180
+
181
+ it('renders the legal footer component', () => {
182
+ expect(result.find(LegalFooter)).toExist()
183
+ })
184
+
185
+ it('renders the footer skip link', () => {
186
+ expect(result.find('a[href="#site-footer"]')).toExist()
187
+ })
188
+ })
189
+
190
+ describe('with the footer disabled', () => {
191
+ let result
192
+
193
+ beforeAll(() => {
194
+ result = shallow(<Subject footerVariant={false} />)
195
+ })
196
+
197
+ it('does not render the footer component', () => {
198
+ expect(result.find(Footer)).not.toExist()
199
+ })
200
+
201
+ it('does not render the footer skip link', () => {
202
+ expect(result.find('a[href="#site-footer"]')).not.toExist()
203
+ })
204
+ })
205
+
206
+ describe('with a custom footer component', () => {
207
+ let result
208
+
209
+ beforeAll(() => {
210
+ const customFooter = <footer>My custom footer</footer>
211
+ result = shallow(<Subject footerComponent={customFooter} />)
212
+ })
213
+
214
+ it('renders the given component', () => {
215
+ expect(result.find('footer')).toHaveText('My custom footer')
216
+ })
217
+
218
+ it('does not render the footer component', () => {
219
+ expect(result.find(Footer)).not.toExist()
220
+ })
221
+
222
+ it('does not render the footer skip link', () => {
223
+ expect(result.find('a[href="#site-footer"]')).not.toExist()
224
+ })
225
+ })
226
+ })
227
+ })
@@ -0,0 +1,24 @@
1
+ /**
2
+ * @jest-environment jsdom
3
+ */
4
+ import 'jest-enzyme'
5
+ import React from 'react'
6
+ import { mount } from 'enzyme'
7
+
8
+ import Subject from '../Template'
9
+
10
+ describe('dotcom-ui-layout/src/components/Template', () => {
11
+ it('can render contents provided as a string', () => {
12
+ const result = mount(<Subject>{'<p>Hello World</p>'}</Subject>)
13
+ expect(result.html()).toBe('<div><p>Hello World</p></div>')
14
+ })
15
+
16
+ it('can render contents provided as children', () => {
17
+ const result = mount(
18
+ <Subject>
19
+ <p>Hello World</p>
20
+ </Subject>
21
+ )
22
+ expect(result.html()).toBe('<div><p>Hello World</p></div>')
23
+ })
24
+ })