@financial-times/n-myft-ui 23.1.3 → 25.0.0
Sign up to get free protection for your applications and to get access to all the features.
- package/.circleci/config.yml +27 -30
- package/.circleci/shared-helpers/helper-npm-install-peer-deps +6 -5
- package/.github/settings.yml +1 -1
- package/.scss-lint.yml +3 -3
- package/Makefile +1 -0
- package/README.md +62 -8
- package/build-state/npm-shrinkwrap.json +49383 -17508
- 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/csrf-token/__tests__/input.test.js +23 -0
- package/components/csrf-token/input.jsx +26 -0
- package/components/follow-button/__tests__/follow-button.test.js +40 -0
- package/components/follow-button/follow-button.jsx +174 -0
- package/components/index.js +15 -0
- package/components/instant-alert/instant-alert.html +1 -1
- 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/components/unread-articles-indicator/date-fns.js +5 -12
- package/demos/app.js +39 -21
- package/demos/templates/demo-layout.html +1 -1
- package/demos/templates/demo.html +436 -415
- package/demos/templates/demo.jsx +125 -0
- package/dist/bundles/bundle.js +3133 -0
- package/jest.config.js +8 -0
- package/package.json +38 -13
- package/webpack.config.js +34 -0
- package/components/collections/collections.html +0 -85
- package/components/concept-list/concept-list.html +0 -31
- package/components/csrf-token/input.html +0 -5
- package/components/follow-button/follow-button.html +0 -79
- 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/.circleci/config.yml
CHANGED
@@ -2,19 +2,12 @@
|
|
2
2
|
# template: component
|
3
3
|
|
4
4
|
references:
|
5
|
-
|
6
|
-
container_config_node12: &container_config_node12
|
5
|
+
container_config_node: &container_config_node
|
7
6
|
working_directory: ~/project/build
|
8
7
|
docker:
|
9
8
|
- image: circleci/node:12-browsers
|
10
9
|
|
11
|
-
|
12
|
-
working_directory: ~/project/build
|
13
|
-
docker:
|
14
|
-
- image: lambci/lambda:build-nodejs12.x
|
15
|
-
|
16
|
-
workspace_root: &workspace_root
|
17
|
-
~/project
|
10
|
+
workspace_root: &workspace_root ~/project
|
18
11
|
|
19
12
|
attach_workspace: &attach_workspace
|
20
13
|
attach_workspace:
|
@@ -22,31 +15,31 @@ references:
|
|
22
15
|
|
23
16
|
npm_cache_keys: &npm_cache_keys
|
24
17
|
keys:
|
25
|
-
|
26
|
-
|
27
|
-
|
18
|
+
- v8-dependency-npm-{{ checksum "package-lock.json" }}-
|
19
|
+
- v8-dependency-npm-{{ checksum "package-lock.json" }}
|
20
|
+
- v8-dependency-npm-
|
28
21
|
|
29
22
|
cache_npm_cache: &cache_npm_cache
|
30
23
|
save_cache:
|
31
|
-
|
32
|
-
|
24
|
+
key: v8-dependency-npm-{{ checksum "package-lock.json" }}-{{ epoch }}
|
25
|
+
paths:
|
33
26
|
- ./node_modules/
|
34
27
|
|
35
28
|
restore_npm_cache: &restore_npm_cache
|
36
29
|
restore_cache:
|
37
|
-
|
30
|
+
<<: *npm_cache_keys
|
38
31
|
|
39
32
|
filters_ignore_gh_pages: &filters_ignore_gh_pages
|
40
33
|
branches:
|
41
34
|
ignore: gh_pages
|
42
35
|
|
43
|
-
|
36
|
+
filters_only_main: &filters_only_main
|
44
37
|
branches:
|
45
|
-
only:
|
38
|
+
only: main
|
46
39
|
|
47
|
-
|
40
|
+
filters_ignore_main: &filters_ignore_main
|
48
41
|
branches:
|
49
|
-
ignore:
|
42
|
+
ignore: main
|
50
43
|
|
51
44
|
filters_ignore_tags: &filters_ignore_tags
|
52
45
|
tags:
|
@@ -59,14 +52,18 @@ references:
|
|
59
52
|
branches:
|
60
53
|
ignore: /.*/
|
61
54
|
|
62
|
-
version: 2
|
55
|
+
version: 2.1
|
63
56
|
|
64
|
-
|
57
|
+
orbs:
|
58
|
+
node: circleci/node@4.6.0
|
65
59
|
|
60
|
+
jobs:
|
66
61
|
build:
|
67
|
-
<<: *
|
62
|
+
<<: *container_config_node
|
68
63
|
steps:
|
69
64
|
- checkout
|
65
|
+
- node/install-npm:
|
66
|
+
version: "7"
|
70
67
|
- run:
|
71
68
|
name: Checkout next-ci-shared-helpers
|
72
69
|
command: git clone --depth 1 git@github.com:Financial-Times/next-ci-shared-helpers.git .circleci/shared-helpers
|
@@ -74,9 +71,6 @@ jobs:
|
|
74
71
|
- run:
|
75
72
|
name: Install project dependencies
|
76
73
|
command: make install
|
77
|
-
- run:
|
78
|
-
name: shared-helper / npm-install-peer-deps
|
79
|
-
command: .circleci/shared-helpers/helper-npm-install-peer-deps
|
80
74
|
- run:
|
81
75
|
name: shared-helper / npm-update
|
82
76
|
command: .circleci/shared-helpers/helper-npm-update
|
@@ -85,6 +79,9 @@ jobs:
|
|
85
79
|
command: .circleci/shared-helpers/helper-generate-build-state-artifacts
|
86
80
|
when: always
|
87
81
|
- *cache_npm_cache
|
82
|
+
- run:
|
83
|
+
name: Compile JSX templates
|
84
|
+
command: npm run build-package
|
88
85
|
- store_artifacts:
|
89
86
|
path: build-state
|
90
87
|
destination: build-state
|
@@ -94,7 +91,7 @@ jobs:
|
|
94
91
|
- build
|
95
92
|
|
96
93
|
test:
|
97
|
-
<<: *
|
94
|
+
<<: *container_config_node
|
98
95
|
parallelism: 1
|
99
96
|
steps:
|
100
97
|
- *attach_workspace
|
@@ -111,7 +108,7 @@ jobs:
|
|
111
108
|
destination: test-results
|
112
109
|
|
113
110
|
publish:
|
114
|
-
<<: *
|
111
|
+
<<: *container_config_node
|
115
112
|
steps:
|
116
113
|
- *attach_workspace
|
117
114
|
- run:
|
@@ -123,7 +120,7 @@ jobs:
|
|
123
120
|
command: .circleci/shared-helpers/helper-npm-version-and-publish-public
|
124
121
|
|
125
122
|
deploy:
|
126
|
-
<<: *
|
123
|
+
<<: *container_config_node
|
127
124
|
steps:
|
128
125
|
- *attach_workspace
|
129
126
|
- add_ssh_keys:
|
@@ -149,7 +146,7 @@ workflows:
|
|
149
146
|
- build
|
150
147
|
- deploy:
|
151
148
|
filters:
|
152
|
-
<<: *
|
149
|
+
<<: *filters_only_main
|
153
150
|
requires:
|
154
151
|
- build
|
155
152
|
build-test-publish:
|
@@ -173,7 +170,7 @@ workflows:
|
|
173
170
|
- schedule:
|
174
171
|
cron: "0 0 * * *"
|
175
172
|
filters:
|
176
|
-
<<: *
|
173
|
+
<<: *filters_only_main
|
177
174
|
jobs:
|
178
175
|
- build:
|
179
176
|
context: next-nightly-build
|
@@ -11,10 +11,10 @@
|
|
11
11
|
#
|
12
12
|
# Why we pass the flags we do to `npm install`:
|
13
13
|
#
|
14
|
-
# --no-package-lock - While we now use package-lock.json
|
15
|
-
# in our repos, skip package-lock.json in this instance
|
16
|
-
# as we don't want to accidentally modify the file
|
17
|
-
# for subsequent steps in the workflow, e.g cache keys
|
14
|
+
# --no-package-lock - While we now use package-lock.json
|
15
|
+
# in our repos, skip package-lock.json in this instance
|
16
|
+
# as we don't want to accidentally modify the file
|
17
|
+
# for subsequent steps in the workflow, e.g cache keys
|
18
18
|
# and artefact generation.
|
19
19
|
#
|
20
20
|
# --no-save - We don't want to modify package.json as we
|
@@ -34,6 +34,7 @@ if [ -e package.json ]; then
|
|
34
34
|
|
35
35
|
npm ls --production --parseable 2>&1 >/dev/null | \
|
36
36
|
sed -n -e 's/^npm ERR! peer dep missing: \(.*\),.*/\1/p' | \
|
37
|
-
|
37
|
+
xargs -I{} echo -n '"{}" ' | \
|
38
|
+
xargs npm install --no-package-lock --no-save
|
38
39
|
|
39
40
|
fi
|
package/.github/settings.yml
CHANGED
package/.scss-lint.yml
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
linters:
|
2
|
-
|
3
2
|
# Documentation:
|
4
|
-
# https://github.com/causes/scss-lint/blob/
|
3
|
+
# https://github.com/causes/scss-lint/blob/HEAD/lib/scss_lint/linter/README.md
|
5
4
|
|
6
5
|
# "value !important;" not "value!important ;"
|
7
6
|
BangFormat:
|
@@ -262,7 +261,8 @@ linters:
|
|
262
261
|
enabled: true
|
263
262
|
identifier_list: base
|
264
263
|
additional_identifiers: []
|
265
|
-
excluded_identifiers:
|
264
|
+
excluded_identifiers:
|
265
|
+
["user-select", "appearance", "font-smoothing", "osx-font-smoothing"]
|
266
266
|
severity: warning
|
267
267
|
|
268
268
|
# No units on zero values: 0 not 0px
|
package/Makefile
CHANGED
package/README.md
CHANGED
@@ -16,22 +16,76 @@ These subdirectories may contain a README. If not, please speak to the myft team
|
|
16
16
|
n-myft-ui provides the CSS, JS and most templates for the myFT components on FT.com. We use semver to control rollout of the code.
|
17
17
|
|
18
18
|
As of August 2017, The following apps use n-myft-ui:
|
19
|
-
* next-front-page
|
20
|
-
* next-stream-page
|
21
|
-
* next-article
|
22
|
-
* next-myft-page
|
23
|
-
* next-tour-page
|
24
|
-
* next-video-page
|
25
|
-
* next-search-page
|
26
19
|
|
27
|
-
|
20
|
+
- next-front-page
|
21
|
+
- next-stream-page
|
22
|
+
- next-article
|
23
|
+
- next-myft-page
|
24
|
+
- next-tour-page
|
25
|
+
- next-video-page
|
26
|
+
- next-search-page
|
27
|
+
|
28
|
+
When you merge to main, you should make a new release and then roll it out to the apps, plus n-topic-card which contains a reference to this so that there aren't missing dependencies.
|
28
29
|
|
29
30
|
If you are making a major change, you will need to update the bower.json and package.json files for the above apps. For minor and patch updates, you can rebuild without cache from CircleCI.
|
30
31
|
|
31
32
|
## Running locally
|
33
|
+
|
32
34
|
```
|
33
35
|
make install
|
34
36
|
make build
|
35
37
|
make demo
|
36
38
|
```
|
39
|
+
|
37
40
|
View the demo on `localhost:5005`
|
41
|
+
|
42
|
+
|
43
|
+
## Migration Guide
|
44
|
+
|
45
|
+
### Upgrading from v25
|
46
|
+
|
47
|
+
V24 introduces some major changes to n-myft-ui components. Some of the components have been moved from handlebars to jsx.
|
48
|
+
|
49
|
+
These components include:
|
50
|
+
- csrf-token
|
51
|
+
- follow-button
|
52
|
+
- save-for-later
|
53
|
+
- pin-button
|
54
|
+
- concept-list
|
55
|
+
- collections
|
56
|
+
|
57
|
+
A consumer of any of these components needs to render them directly as `jsx` components in a parent `jsx` component or use the `renderReactComponent` helper function provided by `@financial-times/dotcom-server-handlebars` in a consuming handlebars template/partial.
|
58
|
+
|
59
|
+
#### Example rendering in a jsx component
|
60
|
+
```jsx
|
61
|
+
import { SaveForLater } from '@financial-times/n-myft-ui';
|
62
|
+
|
63
|
+
export default function Consumer() {
|
64
|
+
return (
|
65
|
+
<SaveForLater contentId={contentId} saveButtonWithIcon={true} flags={{myFtApiWrite:myFtApiWrite}}/>
|
66
|
+
)
|
67
|
+
}
|
68
|
+
```
|
69
|
+
|
70
|
+
More examples of rendering these components can be found [here](https://github.com/Financial-Times/n-myft-ui/blob/main/demos/templates/demo.jsx) with component props passed in [here](https://github.com/Financial-Times/n-myft-ui/blob/dfbf06d10f78756871cfe8d2aeb863ce4bcca1e1/demos/app.js#L54).
|
71
|
+
|
72
|
+
|
73
|
+
#### Example rendering in a handlebars partial
|
74
|
+
To render a jsx component in a handlebars partial, consumers need to add the `helpers` provided by `@financial-times/dotcom-server-handlebars` to the PageKitHandlebars config in `express app engine` [see example](https://github.com/Financial-Times/n-myft-ui/blob/dfbf06d10f78756871cfe8d2aeb863ce4bcca1e1/demos/app.js#L41).
|
75
|
+
|
76
|
+
```hbs
|
77
|
+
<div>
|
78
|
+
<h2 class="demo-section__title">
|
79
|
+
Follow button
|
80
|
+
</h2>
|
81
|
+
|
82
|
+
{{#followButton}}
|
83
|
+
{{{renderReactComponent localPath="node_modules/@financial-times/n-myft-ui/components/follow-button/follow-button" flags=flags variant="standard" conceptId="0000-0000-0000-0000" name="Follow Item" directType="http://www.ft.com/ontology/product/Brand"}}}
|
84
|
+
{{/followButton}}
|
85
|
+
</div>
|
86
|
+
```
|
87
|
+
|
88
|
+
More examples of rendering jsx in handlebars partials can be found [here](https://github.com/Financial-Times/n-myft-ui/blob/main/demos/templates/demo.html)
|
89
|
+
|
90
|
+
|
91
|
+
NB: This branch is the development branch for v25 and all bug fixes for breaking changes related to `jsx` go here.
|