@financial-times/n-myft-ui 24.0.0 → 25.0.0-beta.2
Sign up to get free protection for your applications and to get access to all the features.
- package/.circleci/config.yml +18 -18
- package/README.md +51 -0
- package/build-state/npm-shrinkwrap.json +41988 -10988
- package/components/collections/collections.jsx +68 -0
- package/components/collections/collections.test.js +83 -0
- package/components/concept-list/concept-list.jsx +55 -0
- package/components/concept-list/concept-list.test.js +116 -0
- package/components/follow-button/__tests__/follow-button.test.js +3 -3
- package/components/follow-button/follow-button.jsx +3 -3
- package/components/index.js +15 -0
- package/components/pin-button/pin-button.jsx +40 -0
- package/components/pin-button/pin-button.test.js +57 -0
- package/components/save-for-later/save-for-later.jsx +103 -0
- package/components/save-for-later/save-for-later.test.js +59 -0
- package/demos/app.js +18 -27
- package/demos/templates/demo-layout.html +1 -1
- package/demos/templates/demo.html +436 -413
- package/demos/templates/demo.jsx +93 -1
- package/dist/bundles/bundle.js +3133 -0
- package/package.json +19 -9
- package/webpack.config.js +34 -0
- package/components/collections/collections.html +0 -77
- package/components/concept-list/concept-list.html +0 -28
- package/components/pin-button/pin-button.html +0 -20
- package/components/save-for-later/save-for-later.html +0 -67
- package/demos/fixtures/follow-button-plus-digest.json +0 -6
- package/demos/templates/digest-on-follow.html +0 -12
package/package.json
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
{
|
2
2
|
"name": "@financial-times/n-myft-ui",
|
3
|
-
"version": "
|
3
|
+
"version": "25.0.0-beta.2",
|
4
4
|
"description": "Client side component for interaction with myft",
|
5
|
-
"main": "
|
5
|
+
"main": "dist/bundles/bundle.js",
|
6
|
+
"module": "dist/bundles/bundle.js",
|
6
7
|
"scripts": {
|
7
8
|
"test": "echo \"Error: no test specified\" && exit 1",
|
8
9
|
"commit": "commit-wizard",
|
9
|
-
"prepare": "npx snyk protect || npx snyk protect -d || true"
|
10
|
+
"prepare": "npx snyk protect || npx snyk protect -d || true",
|
11
|
+
"build-package": "webpack"
|
10
12
|
},
|
11
13
|
"repository": {
|
12
14
|
"type": "git",
|
@@ -26,10 +28,8 @@
|
|
26
28
|
"@financial-times/dotcom-page-kit-cli": "0.4.1",
|
27
29
|
"@financial-times/dotcom-server-handlebars": "^3.0.0",
|
28
30
|
"@financial-times/dotcom-server-react-jsx": "^2.6.2",
|
29
|
-
"@financial-times/n-
|
30
|
-
"@financial-times/n-
|
31
|
-
"@financial-times/n-internal-tool": "2.3.4",
|
32
|
-
"@financial-times/x-handlebars": "1.0.0-beta.21",
|
31
|
+
"@financial-times/n-express": "^22.4.1",
|
32
|
+
"@financial-times/n-gage": "^8.3.2",
|
33
33
|
"@sucrase/jest-plugin": "^2.2.0",
|
34
34
|
"@testing-library/jest-dom": "^5.16.1",
|
35
35
|
"@testing-library/react": "^12.1.2",
|
@@ -45,6 +45,8 @@
|
|
45
45
|
"babel-plugin-transform-runtime": "^6.9.0",
|
46
46
|
"babel-preset-env": "^1.7.0",
|
47
47
|
"babel-preset-es2015": "^6.6.0",
|
48
|
+
"babel-preset-react": "^6.24.1",
|
49
|
+
"babel-preset-stage-2": "^6.24.1",
|
48
50
|
"babel-runtime": "^6.9.2",
|
49
51
|
"bower": "^1.8.8",
|
50
52
|
"bower-resolve-webpack-plugin": "^1.0.5",
|
@@ -52,6 +54,7 @@
|
|
52
54
|
"brotli": "^1.3.1",
|
53
55
|
"chai": "4.2.0",
|
54
56
|
"chalk": "2.4.2",
|
57
|
+
"check-engine": "^1.10.1",
|
55
58
|
"css-loader": "^0.23.1",
|
56
59
|
"denodeify": "^1.2.1",
|
57
60
|
"eslint": "6.5.1",
|
@@ -83,20 +86,27 @@
|
|
83
86
|
"mocha": "6.2.2",
|
84
87
|
"mockery": "2.1.0",
|
85
88
|
"node-fetch": "2.6.0",
|
86
|
-
"node-sass": "4.
|
89
|
+
"node-sass": "^4.14.1",
|
87
90
|
"nodemon": "^1.9.2",
|
88
91
|
"npm-prepublish": "^1.2.1",
|
89
92
|
"pa11y-ci": "^2.1.1",
|
90
93
|
"postcss-loader": "^0.9.1",
|
91
94
|
"react": "^17.0.2",
|
92
95
|
"regenerator-runtime": "^0.13.3",
|
93
|
-
"sass-loader": "^3.2.0",
|
94
96
|
"semver": "6.3.0",
|
95
97
|
"sinon": "^7.1.0",
|
96
98
|
"sinon-chai": "^3.2.0",
|
97
99
|
"snyk": "^1.216.5",
|
98
100
|
"sucrase": "^3.10.1"
|
99
101
|
},
|
102
|
+
"volta": {
|
103
|
+
"node": "12.22.5",
|
104
|
+
"npm": "7.20.2"
|
105
|
+
},
|
106
|
+
"engines": {
|
107
|
+
"node": "12.x",
|
108
|
+
"npm": "7.x || 8.x"
|
109
|
+
},
|
100
110
|
"x-dash": {
|
101
111
|
"engine": {
|
102
112
|
"server": "hyperons"
|
@@ -0,0 +1,34 @@
|
|
1
|
+
const path = require('path');
|
2
|
+
|
3
|
+
module.exports = {
|
4
|
+
entry: './components/index.js',
|
5
|
+
resolve: {
|
6
|
+
extensions: ['.js', '.jsx']
|
7
|
+
},
|
8
|
+
module: {
|
9
|
+
rules: [
|
10
|
+
{
|
11
|
+
test: /\.(js|jsx)$/,
|
12
|
+
exclude: /node_modules/,
|
13
|
+
use: [
|
14
|
+
{
|
15
|
+
loader: 'babel-loader',
|
16
|
+
options: {
|
17
|
+
presets: [
|
18
|
+
'react',
|
19
|
+
'stage-2'
|
20
|
+
]
|
21
|
+
}
|
22
|
+
}
|
23
|
+
]
|
24
|
+
}
|
25
|
+
]
|
26
|
+
},
|
27
|
+
target: 'node',
|
28
|
+
output: {
|
29
|
+
path: path.resolve(__dirname, 'dist/bundles'),
|
30
|
+
filename: 'bundle.js',
|
31
|
+
libraryTarget: 'umd',
|
32
|
+
library: '@financial-times/n-myft-ui'
|
33
|
+
}
|
34
|
+
};
|
@@ -1,77 +0,0 @@
|
|
1
|
-
<section
|
2
|
-
class="collection {{#if liteStyle}}collection--lite{{else}}collection--regular{{/if}}"
|
3
|
-
data-trackable="{{#if trackable}}{{trackable}}{{else}}collection{{/if}}">
|
4
|
-
<header class="collection__header {{#if liteStyle}}collection__header--lite{{else}}collection__header--regular{{/if}}">
|
5
|
-
<h2 class="collection__title {{#if liteStyle}}collection__title--lite{{else}}collection__title--regular{{/if}}">
|
6
|
-
{{title}}
|
7
|
-
</h2>
|
8
|
-
</header>
|
9
|
-
<ul class="collection__concepts">
|
10
|
-
{{#concepts}}
|
11
|
-
<li class="collection__concept">
|
12
|
-
{{#if ../liteStyle}}
|
13
|
-
{{{renderReactComponent localPath="components/follow-button/follow-button" variant="primary" buttonText=name flags=@root.flags collectionName=../collectionName}}}
|
14
|
-
{{else}}
|
15
|
-
{{{renderReactComponent localPath="components/follow-button/follow-button" variant="inverse" buttonText=name flags=@root.flags collectionName=../collectionName}}}
|
16
|
-
{{/if}}
|
17
|
-
</li>
|
18
|
-
{{/concepts}}
|
19
|
-
</ul>
|
20
|
-
<div class="collection__meta">
|
21
|
-
<form
|
22
|
-
method="POST"
|
23
|
-
action="#"
|
24
|
-
data-myft-ui="follow"
|
25
|
-
{{#if collectionName}}data-myft-tracking="collectionName={{collectionName}}"{{/if}}
|
26
|
-
data-concept-id="
|
27
|
-
{{~#concepts~}}
|
28
|
-
{{conceptId}}
|
29
|
-
{{~#unless @last~}}
|
30
|
-
,
|
31
|
-
{{~/unless~}}
|
32
|
-
{{~/concepts~}}"
|
33
|
-
class="n-myft-ui n-myft-ui--follow n-ui-hide-core collection-follow-all">
|
34
|
-
<input
|
35
|
-
type="hidden"
|
36
|
-
name="directType"
|
37
|
-
value="
|
38
|
-
{{~#concepts~}}
|
39
|
-
{{directType}}
|
40
|
-
{{~#unless @last~}}
|
41
|
-
,
|
42
|
-
{{~/unless~}}
|
43
|
-
{{~/concepts~}}"
|
44
|
-
/>
|
45
|
-
{{{renderReactComponent localPath="components/csrf-token/input"}}}
|
46
|
-
<input
|
47
|
-
type="hidden"
|
48
|
-
name="name"
|
49
|
-
value="
|
50
|
-
{{~#concepts~}}
|
51
|
-
{{name}}
|
52
|
-
{{~#unless @last~}}
|
53
|
-
,
|
54
|
-
{{~/unless~}}
|
55
|
-
{{~/concepts~}}"
|
56
|
-
/>
|
57
|
-
<button
|
58
|
-
type="submit"
|
59
|
-
aria-pressed="false"
|
60
|
-
class="collection-follow-all__button {{#if liteStyle}}collection-follow-all__button--lite{{else}}collection-follow-all__button--regular{{/if}}"
|
61
|
-
data-trackable="follow all"
|
62
|
-
data-concept-id="
|
63
|
-
{{~#concepts~}}
|
64
|
-
{{conceptId}}
|
65
|
-
{{~#unless @last~}}
|
66
|
-
,
|
67
|
-
{{~/unless~}}
|
68
|
-
{{~/concepts~}}"
|
69
|
-
aria-label="Add all topics in the {{title}} collection to my F T"
|
70
|
-
data-alternate-label="Remove all topics in the {{title}} collection from my F T"
|
71
|
-
data-alternate-text="Added"
|
72
|
-
title="Add all topics in the {{title}} collection to my F T">
|
73
|
-
Add all to myFT
|
74
|
-
</button>
|
75
|
-
</form>
|
76
|
-
</div>
|
77
|
-
</section>
|
@@ -1,28 +0,0 @@
|
|
1
|
-
{{#ifAll @root.flags.myFtApi @root.flags.myFtApiWrite concepts concepts.length}}
|
2
|
-
<div
|
3
|
-
class="concept-list"
|
4
|
-
data-trackable="{{#if trackable}}{{trackable}}{{else}}concept-list{{/if}}">
|
5
|
-
{{#ifSome contentType conceptListTitle}}
|
6
|
-
<h2 class="concept-list__title">
|
7
|
-
{{#if conceptListTitle}}
|
8
|
-
{{conceptListTitle}}
|
9
|
-
{{else}}
|
10
|
-
Follow the topics in this {{contentType}}
|
11
|
-
{{/if}}
|
12
|
-
</h2>
|
13
|
-
{{/ifSome}}
|
14
|
-
<ul class="concept-list__list">
|
15
|
-
{{#each concepts}}
|
16
|
-
<li class="concept-list__list-item">
|
17
|
-
<a
|
18
|
-
href="{{relativeUrl}}"
|
19
|
-
data-trackable="{{#if conceptTrackable}}{{conceptTrackable}}{{else}}concept{{/if}}"
|
20
|
-
class="concept-list__concept">
|
21
|
-
{{prefLabel}}
|
22
|
-
</a>
|
23
|
-
{{{renderReactComponent localPath="components/follow-button/follow-button" conceptId=id name=prefLabel flags=@root.flags}}}
|
24
|
-
</li>
|
25
|
-
{{/each}}
|
26
|
-
</ul>
|
27
|
-
</div>
|
28
|
-
{{/ifAll}}
|
@@ -1,20 +0,0 @@
|
|
1
|
-
{{#if showPrioritiseButton}}
|
2
|
-
<span class="myft-pin-divider"></span>
|
3
|
-
<div class="myft-pin-button-wrapper">
|
4
|
-
<form method="post" action="/__myft/api/core/prioritised/concept/{{id}}?method={{#if prioritised}}delete{{else}}put{{/if}}" data-myft-prioritise>
|
5
|
-
{{{renderReactComponent localPath="components/csrf-token/input"}}}
|
6
|
-
<input type="hidden" value="{{name}}" name="name"> {{#if directType}}
|
7
|
-
<input type="hidden" value="{{directType}}" name="directType"> {{else}}
|
8
|
-
<input type="hidden" value="http://www.ft.com/ontology/concept/Concept" name="directType"> {{/if}}
|
9
|
-
<div
|
10
|
-
class="n-myft-ui__announcement o-normalise-visually-hidden"
|
11
|
-
aria-live="assertive"
|
12
|
-
data-pressed-text="{{name}} pinned in myFT."
|
13
|
-
data-unpressed-text="Unpinned {{name}} from myFT."
|
14
|
-
></div>
|
15
|
-
<button id="myft-pin-button__{{id}}" class="myft-pin-button" data-prioritise-button data-trackable="prioritised" data-concept-id="{{id}}" data-prioritised="{{#if prioritised}}true{{else}}false{{/if}}"
|
16
|
-
aria-label="{{#if prioritised}}Unpin{{else}}Pin{{/if}} {{name}} {{#if prioritised}}from{{else}}in{{/if}} myFT" aria-pressed="{{#if prioritised}}true{{else}}false{{/if}}" title="{{#if prioritised}}Unpin{{else}}Pin{{/if}} {{name}}">
|
17
|
-
</button>
|
18
|
-
</form>
|
19
|
-
</div>
|
20
|
-
{{/if}}
|
@@ -1,67 +0,0 @@
|
|
1
|
-
{{#if @root.flags.myFtApiWrite}}
|
2
|
-
<form class="n-myft-ui n-myft-ui--save" method="GET"
|
3
|
-
data-content-id="{{contentId}}"
|
4
|
-
data-myft-ui="saved"
|
5
|
-
action="/myft/save/{{contentId}}"
|
6
|
-
data-js-action="/__myft/api/core/saved/content/{{contentId}}?method=put">
|
7
|
-
{{{renderReactComponent localPath="components/csrf-token/input"}}}
|
8
|
-
<div
|
9
|
-
class="n-myft-ui__announcement o-normalise-visually-hidden"
|
10
|
-
aria-live="assertive"
|
11
|
-
data-pressed-text="Article saved in My FT."
|
12
|
-
data-unpressed-text="Removed article from My FT."
|
13
|
-
></div>
|
14
|
-
<button
|
15
|
-
type="submit"
|
16
|
-
class="{{#if saveButtonWithIcon}}n-myft-ui__save-button-with-icon{{else}}n-myft-ui__button{{#variant}} n-myft-ui__button--{{this}}{{/variant}}{{/if}}"
|
17
|
-
data-trackable="{{#if trackableId}}{{trackableId}}{{else}}save-for-later{{/if}}"
|
18
|
-
{{#if isSaved}}
|
19
|
-
{{!-- The value of alternate label needs to be the opposite of label / the current saved state. This allows the client side JS to toggle the labels on state changes --}}
|
20
|
-
title="{{#if title}}{{title}} is{{/if}} Saved to myFT"
|
21
|
-
aria-label="{{#if title}}{{title}} is{{/if}} Saved to myFT"
|
22
|
-
data-alternate-label="{{#if title}}Save {{title}} to myFT for later{{else}}Save this article to myFT for later{{/if}}"
|
23
|
-
aria-pressed="true"
|
24
|
-
{{else}}
|
25
|
-
title="{{#if title}}Save {{title}} to myFT for later{{else}}Save this article to myFT for later{{/if}}"
|
26
|
-
aria-label="{{#if title}}Save {{title}} to myFT for later{{else}}Save this article to myFT for later{{/if}}"
|
27
|
-
data-alternate-label="{{#if title}}{{title}} is{{/if}} Saved to myFT"
|
28
|
-
aria-pressed="false"
|
29
|
-
{{/if}}
|
30
|
-
{{#unlessEquals appIsStreamPage true}}
|
31
|
-
{{#if saveButtonWithIcon}}
|
32
|
-
data-text-variant="save-button-with-icon-copy"
|
33
|
-
{{else}}
|
34
|
-
data-text-variant="save-button-longer-copy"
|
35
|
-
{{/if}}
|
36
|
-
{{/unlessEquals}}
|
37
|
-
{{#if alternateText}}
|
38
|
-
data-alternate-text="{{alternateText}}"
|
39
|
-
{{else}}
|
40
|
-
{{#if isSaved}}
|
41
|
-
data-alternate-text="Save "
|
42
|
-
{{else}}
|
43
|
-
data-alternate-text="Saved "
|
44
|
-
{{/if}}
|
45
|
-
{{/if}}
|
46
|
-
data-content-id="{{contentId}}" {{! duplicated here for tracking}}
|
47
|
-
>
|
48
|
-
{{#if saveButtonWithIcon}}
|
49
|
-
<span class="save-button-with-icon-copy" data-variant-label>{{#if buttonText~}}
|
50
|
-
{{buttonText}}
|
51
|
-
{{~else~}}
|
52
|
-
{{#if isSaved}}Saved{{else}}Save{{/if}}
|
53
|
-
{{~/if}}</span>
|
54
|
-
{{else}}
|
55
|
-
{{#if buttonText}}{{buttonText}}{{else}}
|
56
|
-
{{#unlessEquals appIsStreamPage true}}
|
57
|
-
<span class="save-button-longer-copy" data-variant-label>{{#if isSaved}}Saved {{else}}Save {{/if}}</span><span class="n-myft-ui__button--viewport-large" aria-hidden="true">to myFT</span>
|
58
|
-
{{else}}
|
59
|
-
<span>{{#if isSaved}}Saved{{else}}Save{{/if}}</span>
|
60
|
-
{{/unlessEquals}}
|
61
|
-
{{/if}}
|
62
|
-
{{/if}}
|
63
|
-
</button>
|
64
|
-
</form>
|
65
|
-
{{else}}
|
66
|
-
<!-- Save button hidden due to myFtApiWrite being off -->
|
67
|
-
{{/if }}
|
@@ -1,12 +0,0 @@
|
|
1
|
-
<div class="o-grid-container o-grid-container--snappy">
|
2
|
-
<h1>{{title}}</h1>
|
3
|
-
<div class="o-grid-row">
|
4
|
-
<div data-o-grid-colspan="12">
|
5
|
-
<h2>Follow button</h2>
|
6
|
-
|
7
|
-
{{#followButton}}
|
8
|
-
{{{renderReactComponent localPath="components/follow-button/follow-button" flags=@root.flags}}}
|
9
|
-
{{/followButton}}
|
10
|
-
</div>
|
11
|
-
</div>
|
12
|
-
</div>
|