@financial-times/n-myft-ui 25.0.1 → 26.0.0
Sign up to get free protection for your applications and to get access to all the features.
- package/.circleci/config.yml +3 -0
- package/README.md +50 -0
- package/build-state/npm-shrinkwrap.json +14847 -15637
- package/components/collections/collections.jsx +68 -0
- package/components/collections/collections.test.js +83 -0
- package/components/concept-list/concept-list.jsx +69 -0
- package/components/concept-list/concept-list.test.js +116 -0
- package/components/csrf-token/input.jsx +1 -7
- package/components/csrf-token/{__tests__/input.test.js → input.test.js} +2 -2
- package/components/follow-button/follow-button.jsx +6 -4
- package/components/follow-button/{__tests__/follow-button.test.js → follow-button.test.js} +4 -4
- package/components/index.js +17 -0
- package/components/instant-alert/instant-alert.jsx +73 -0
- package/components/instant-alert/instant-alert.test.js +86 -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 +101 -0
- package/components/save-for-later/save-for-later.test.js +59 -0
- package/demos/app.js +2 -4
- package/demos/templates/demo.html +8 -9
- package/demos/templates/demo.jsx +93 -1
- package/dist/bundles/bundle.js +3232 -0
- package/jsx-migration.md +16 -0
- package/package.json +7 -3
- package/webpack.config.js +34 -0
- package/components/collections/collections.html +0 -77
- package/components/concept-list/concept-list.html +0 -28
- package/components/instant-alert/instant-alert.html +0 -47
- package/components/pin-button/pin-button.html +0 -20
- package/components/save-for-later/save-for-later.html +0 -67
package/.circleci/config.yml
CHANGED
@@ -79,6 +79,9 @@ jobs:
|
|
79
79
|
command: .circleci/shared-helpers/helper-generate-build-state-artifacts
|
80
80
|
when: always
|
81
81
|
- *cache_npm_cache
|
82
|
+
- run:
|
83
|
+
name: Compile JSX templates
|
84
|
+
command: npm run build-package
|
82
85
|
- store_artifacts:
|
83
86
|
path: build-state
|
84
87
|
destination: build-state
|
package/README.md
CHANGED
@@ -38,3 +38,53 @@ make demo
|
|
38
38
|
```
|
39
39
|
|
40
40
|
View the demo on `localhost:5005`
|
41
|
+
|
42
|
+
|
43
|
+
## Migration Guide
|
44
|
+
|
45
|
+
### Upgrading from v25
|
46
|
+
|
47
|
+
V25 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
|
+
- InstantAlert
|
57
|
+
|
58
|
+
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.
|
59
|
+
|
60
|
+
#### Example rendering in a jsx component
|
61
|
+
```jsx
|
62
|
+
import { SaveForLater } from '@financial-times/n-myft-ui';
|
63
|
+
|
64
|
+
export default function Consumer() {
|
65
|
+
return (
|
66
|
+
<SaveForLater contentId={contentId} saveButtonWithIcon={true} flags={{myFtApiWrite:myFtApiWrite}}/>
|
67
|
+
)
|
68
|
+
}
|
69
|
+
```
|
70
|
+
|
71
|
+
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).
|
72
|
+
|
73
|
+
|
74
|
+
#### Example rendering in a handlebars partial
|
75
|
+
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).
|
76
|
+
|
77
|
+
```hbs
|
78
|
+
<div>
|
79
|
+
<h2 class="demo-section__title">
|
80
|
+
Follow button
|
81
|
+
</h2>
|
82
|
+
|
83
|
+
{{#followButton}}
|
84
|
+
{{{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"}}}
|
85
|
+
{{/followButton}}
|
86
|
+
</div>
|
87
|
+
```
|
88
|
+
|
89
|
+
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)
|
90
|
+
|