Skip to content

Commit 6992e52

Browse files
DangoDevDavid Leger
authored andcommitted
Relax Node restriction (#842)
* Relax Node restriction * Add <manifold-service-card>
1 parent 5493a99 commit 6992e52

File tree

7 files changed

+177
-4
lines changed

7 files changed

+177
-4
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project
66
adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.9.3] - 2019-01-13
9+
10+
### Added
11+
12+
- Added `<manifold-service-card>` back until 1.0 release
13+
14+
### Changed
15+
16+
- Allow Node 12.x and 13.x
17+
818
## [0.9.2] - 2019-01-13
919

1020
### Changed
@@ -484,6 +494,7 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
484494
- Changed the `manifold-resource-credentials` component to use the standalone `manifold-credentials`
485495
component.
486496

497+
[0.9.3]: https://github.com/manifoldco/ui/compare/v0.9.2...v0.9.3
487498
[0.9.2]: https://github.com/manifoldco/ui/compare/v0.9.1...v0.9.2
488499
[0.9.1]: https://github.com/manifoldco/ui/compare/v0.8.0...v0.9.1
489500
[0.8.0]: https://github.com/manifoldco/ui/compare/v0.7.2...v0.8.0

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
"bugs": {
1111
"url": "https://github.com/manifoldco/ui/issues"
1212
},
13+
"engines": {
14+
"node": ">=10 <=13"
15+
},
1316
"author": "manifoldco",
1417
"license": "BSD-3-Clause",
1518
"files": [
@@ -125,8 +128,5 @@
125128
"testcafe": "^1.5.0",
126129
"wait-on": "^3.3.0",
127130
"webpack": "^4.41.2"
128-
},
129-
"engines": {
130-
"node": "^10.0.0"
131131
}
132132
}

src/components.d.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,18 @@ export namespace Components {
588588
'options': Option[];
589589
'required'?: boolean;
590590
}
591+
interface ManifoldServiceCard {
592+
/**
593+
* _(hidden)_
594+
*/
595+
'graphqlFetch'?: GraphqlFetch;
596+
'hideUntilReady'?: boolean;
597+
'isFeatured'?: boolean;
598+
'preserveEvent'?: boolean;
599+
'product'?: ProductCardQuery['product'];
600+
'productLabel'?: string;
601+
'productLinkFormat'?: string;
602+
}
591603
interface ManifoldSkeletonImg {}
592604
interface ManifoldSkeletonText {}
593605
interface ManifoldTemplateCard {
@@ -942,6 +954,12 @@ declare global {
942954
new (): HTMLManifoldSelectElement;
943955
};
944956

957+
interface HTMLManifoldServiceCardElement extends Components.ManifoldServiceCard, HTMLStencilElement {}
958+
var HTMLManifoldServiceCardElement: {
959+
prototype: HTMLManifoldServiceCardElement;
960+
new (): HTMLManifoldServiceCardElement;
961+
};
962+
945963
interface HTMLManifoldSkeletonImgElement extends Components.ManifoldSkeletonImg, HTMLStencilElement {}
946964
var HTMLManifoldSkeletonImgElement: {
947965
prototype: HTMLManifoldSkeletonImgElement;
@@ -1031,6 +1049,7 @@ declare global {
10311049
'manifold-resource-status': HTMLManifoldResourceStatusElement;
10321050
'manifold-resource-status-view': HTMLManifoldResourceStatusViewElement;
10331051
'manifold-select': HTMLManifoldSelectElement;
1052+
'manifold-service-card': HTMLManifoldServiceCardElement;
10341053
'manifold-skeleton-img': HTMLManifoldSkeletonImgElement;
10351054
'manifold-skeleton-text': HTMLManifoldSkeletonTextElement;
10361055
'manifold-template-card': HTMLManifoldTemplateCardElement;
@@ -1618,6 +1637,18 @@ declare namespace LocalJSX {
16181637
'options'?: Option[];
16191638
'required'?: boolean;
16201639
}
1640+
interface ManifoldServiceCard {
1641+
/**
1642+
* _(hidden)_
1643+
*/
1644+
'graphqlFetch'?: GraphqlFetch;
1645+
'hideUntilReady'?: boolean;
1646+
'isFeatured'?: boolean;
1647+
'preserveEvent'?: boolean;
1648+
'product'?: ProductCardQuery['product'];
1649+
'productLabel'?: string;
1650+
'productLinkFormat'?: string;
1651+
}
16211652
interface ManifoldSkeletonImg {}
16221653
interface ManifoldSkeletonText {}
16231654
interface ManifoldTemplateCard {
@@ -1706,6 +1737,7 @@ declare namespace LocalJSX {
17061737
'manifold-resource-status': ManifoldResourceStatus;
17071738
'manifold-resource-status-view': ManifoldResourceStatusView;
17081739
'manifold-select': ManifoldSelect;
1740+
'manifold-service-card': ManifoldServiceCard;
17091741
'manifold-skeleton-img': ManifoldSkeletonImg;
17101742
'manifold-skeleton-text': ManifoldSkeletonText;
17111743
'manifold-template-card': ManifoldTemplateCard;
@@ -1774,6 +1806,7 @@ declare module "@stencil/core" {
17741806
'manifold-resource-status': LocalJSX.ManifoldResourceStatus & JSXBase.HTMLAttributes<HTMLManifoldResourceStatusElement>;
17751807
'manifold-resource-status-view': LocalJSX.ManifoldResourceStatusView & JSXBase.HTMLAttributes<HTMLManifoldResourceStatusViewElement>;
17761808
'manifold-select': LocalJSX.ManifoldSelect & JSXBase.HTMLAttributes<HTMLManifoldSelectElement>;
1809+
'manifold-service-card': LocalJSX.ManifoldServiceCard & JSXBase.HTMLAttributes<HTMLManifoldServiceCardElement>;
17771810
'manifold-skeleton-img': LocalJSX.ManifoldSkeletonImg & JSXBase.HTMLAttributes<HTMLManifoldSkeletonImgElement>;
17781811
'manifold-skeleton-text': LocalJSX.ManifoldSkeletonText & JSXBase.HTMLAttributes<HTMLManifoldSkeletonTextElement>;
17791812
'manifold-template-card': LocalJSX.ManifoldTemplateCard & JSXBase.HTMLAttributes<HTMLManifoldTemplateCardElement>;

src/components/manifold-product-card-view/manifold-product-card-view.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Newer version of <manifold-service-card-view>. Keep this in 1.0.
12
import { h, Component, Prop, Event, EventEmitter, Element } from '@stencil/core';
23
import logger from '../../utils/logger';
34
import loadMark from '../../utils/loadMark';

src/components/manifold-product-card/manifold-product-card.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Newer version of <manifold-service-card>. Keep this in 1.0.
12
import { h, Component, Element, State, Prop, Watch } from '@stencil/core';
23

34
import connection from '../../state/connection';
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
// Replaced by <manifold-product-card> (delete this in 1.0)
2+
import { h, Component, Element, State, Prop, Watch } from '@stencil/core';
3+
4+
import connection from '../../state/connection';
5+
import { GraphqlFetch, GraphqlError } from '../../utils/graphqlFetch';
6+
import logger from '../../utils/logger';
7+
import loadMark from '../../utils/loadMark';
8+
9+
import { ProductCardQuery, ProductCardQueryVariables } from '../../types/graphql';
10+
11+
import productCardQuery from '../manifold-product-card/product-card.graphql';
12+
13+
// Product has at least one free plan.
14+
const isFree = (product: ProductCardQuery['product']) =>
15+
!!(product.plans && product.plans.edges.find(({ node }) => node.free));
16+
17+
@Component({ tag: 'manifold-service-card' })
18+
export class ManifoldServiceCard {
19+
@Element() el: HTMLElement;
20+
/** _(hidden)_ */
21+
@Prop() graphqlFetch?: GraphqlFetch = connection.graphqlFetch;
22+
@Prop() hideUntilReady?: boolean = false;
23+
@Prop({ reflect: true }) isFeatured?: boolean;
24+
@Prop({ mutable: true }) product?: ProductCardQuery['product'];
25+
@Prop() productLabel?: string;
26+
@Prop() productLinkFormat?: string;
27+
@Prop() preserveEvent?: boolean = false;
28+
@State() free: boolean = false;
29+
@State() errors?: GraphqlError[];
30+
31+
@Watch('product') productChange(newProduct: ProductCardQuery['product']) {
32+
if (newProduct) {
33+
this.free = isFree(newProduct);
34+
}
35+
}
36+
37+
@Watch('productLabel') productLabelChange(newProductLabel: string) {
38+
if (!this.product || (this.product && this.product.label !== newProductLabel)) {
39+
this.fetchProduct(newProductLabel);
40+
}
41+
}
42+
43+
@loadMark()
44+
componentWillLoad() {
45+
console.warn(
46+
`<manifold-service-card> will be deprecated in version 1.0. Please use <manifold-product-card> instead.`
47+
);
48+
49+
let call;
50+
51+
if (this.productLabel) {
52+
call = this.fetchProduct(this.productLabel);
53+
}
54+
55+
if (this.hideUntilReady) {
56+
return call;
57+
}
58+
return undefined;
59+
}
60+
61+
get href() {
62+
if (this.productLinkFormat && this.product) {
63+
return this.productLinkFormat.replace(/:product/gi, this.product.label);
64+
}
65+
return ''; // if no format, or product is loading, don’t calculate href
66+
}
67+
68+
async fetchProduct(productLabel: string) {
69+
if (!this.graphqlFetch || !productLabel) {
70+
return;
71+
}
72+
73+
const variables: ProductCardQueryVariables = { productLabel };
74+
const { data, errors } = await this.graphqlFetch<ProductCardQuery>({
75+
query: productCardQuery,
76+
variables,
77+
element: this.el,
78+
});
79+
if (data && data.product) {
80+
this.product = data.product;
81+
}
82+
83+
if (errors) {
84+
this.errors = errors;
85+
}
86+
}
87+
88+
@logger()
89+
render() {
90+
if (this.product) {
91+
return [
92+
<manifold-product-card-view
93+
description={this.product.tagline}
94+
isFeatured={this.isFeatured}
95+
isFree={this.free}
96+
logo={this.product.logoUrl}
97+
name={this.product.displayName}
98+
preserveEvent={this.preserveEvent}
99+
productId={this.product.id}
100+
productLabel={this.product.label}
101+
productLinkFormat={this.productLinkFormat}
102+
>
103+
<manifold-forward-slot slot="cta">
104+
<slot name="cta" />
105+
</manifold-forward-slot>
106+
</manifold-product-card-view>,
107+
this.errors &&
108+
this.errors.map(({ message }) => (
109+
<manifold-toast alertType="error">{message}</manifold-toast>
110+
)),
111+
];
112+
}
113+
// ☠
114+
return (
115+
<manifold-product-card-view
116+
skeleton={true}
117+
description="Awesome product description"
118+
logo="product.jpg"
119+
name="Awesome product"
120+
>
121+
<manifold-forward-slot slot="cta">
122+
<slot name="cta" />
123+
</manifold-forward-slot>
124+
</manifold-product-card-view>
125+
);
126+
}
127+
}

0 commit comments

Comments
 (0)