diff --git a/.eslintignore b/.eslintignore
index d843e378b..a7ac8f542 100644
--- a/.eslintignore
+++ b/.eslintignore
@@ -1,3 +1,4 @@
+__mocks__
dist/
www/
diff --git a/__mocks__/@stencil/state-tunnel/index.ts b/__mocks__/@stencil/state-tunnel/index.ts
new file mode 100644
index 000000000..9a2e01b9d
--- /dev/null
+++ b/__mocks__/@stencil/state-tunnel/index.ts
@@ -0,0 +1,85 @@
+import { FunctionalComponent, HTMLStencilElement } from '@stencil/core';
+import { SubscribeCallback, ConsumerRenderer, PropList } from '../declarations';
+
+export const createProviderConsumer = Featuring products
<manifold-marketplace featured="piio,zerosix" />
-
- When users click on a product card, you expect something to happen, right? By
- default, service cards will emit a manifold-serviceCard-click
custom
- event whenever a user clicks anywhere on a card. You can listen for it like so, and
- use this value to navigate client-side or perform some other action of your choice:
+ This component emits
+ custom events
+ when it updates. To listen to those events, add an event listener either on the
+ component itself, or document
.
document.addEventListener('manifold-serviceCard-click', { detail: { label } } => {
- alert(`You clicked the card for ${label}`);
+ document.addEventListener('manifold-marketplace-click', { detail: { productLabel } } => {
+ alert(`You clicked the card for ${productLabel}`);
});
+ The following events are emitted:
+
+
+
+ Event Name
+ Description
+ Data
+
+
+
+
+ manifold-marketplace-click
+
+ Fires whenever a user has clicked on a product.
+
+
+ productId
, productLabel
+
+
+
+ manifold-template-click
+
+ Fires whenever a user has clicked on a custom template.
+
+ category
+
+
+
+ Navigation
- Alternately, if you’d like the service cards to be plain, ol’
- <a>
tags, you can specify a link-format
attribute,
- where :product
will be substituted with each product’s URL-friendly
- slug:
+ By default, service cards will only emit the
+ manifold-marketplace-click
event (above). But it can also be turned
+ into an <a>
tag by specifying link-format
:
<manifold-marketplace link-format="/product/:product" />
<!-- <a href="/product/jawsdb-mysql"> -->
- Note that template cards also emit an event as well:
- manifold-templateCard-click
.
-
- Handling Events in React
-
- Attaching listeners to custom components in React
- requires the use of refs.
- Example:
+ :product
will be replaced with the url-friendly slug for the product.
- marketplaceLoaded(node) {
- node.addEventListener("manifold-serviceCard-click", ({ detail: { label } }) => {
- alert(`You clicked the card for ${label}`);
- });
-}
-
-render() {
- return <manifold-marketplace ref={this.marketplaceLoaded} />;
-}
-
Properties
@@ -539,42 +552,71 @@ Plan Selector
Display the plans for a product.
<manifold-plan-selector product-label="jawsdb-mysql" />
- Product Label
You can find the :product
label for each at
https://manifold.co/services/:product
.
- Detecting changes
+ Events
- Events are dispatched on the manifold-planUpdated
custom event. To
- listen for that, listen for the event on document
like so:
+ This component emits
+ custom events
+ when it updates. To listen to those events, add an event listener either on the
+ component itself, or document
.
- document.addEventListener('manifold-planUpdated', ({ detail }) => {
+ document.addEventListener('manifold-planSelector-change', ({ detail }) => {
console.log(detail);
});
-// { id: "2357v8j36f5h866c32ddwwjxvfe8j", label: "nvidia-1080ti-100gb-ssd", product: "zerosix", features: { … } } }
+// { planId: "2357v8j36f5h866c32ddwwjxvfe8j", planLabel: "nvidia-1080ti-100gb-ssd", productLabel: "zerosix", features: { … } } }
+ The following events are emitted:
+
+
+
+ Event Name
+ Description
+ Data
+
+
+
+
+ manifold-planSelector-change
+ Fires whenever a user makes a change.
+
+ planID
, planLabel
, productLabel
,
+ features
+
+
+
+ manifold-planSelector-load
+
+ Identical to -update
above, but this fires once on DOM mount to
+ set the initial state (i.e. user hasn’t interacted yet).
+
+
+ planID
, planLabel
, productLabel
,
+ features
+
+
+
+ manifold-planSelector-click
+
+ If the CTA is showing (see hide-cta
below), this will fire when
+ clicked.
+
+
+ planID
, planLabel
, productLabel
,
+ features
+
+
+
+
Navigation
- The large CTA in the bottom-right is configurable. By default, this component emits
- a manifold-planCTA-click
custom event whenever the main CTA is clicked.
- Listen for it like so:
-
- document.addEventListener(
- 'manifold-productCTA-click',
- ({ detail: { product, plan, features } }) => {
- alert(
- `You clicked the CTA for the ${plan} plan on ${product} with these features: ${JSON.stringify(
- features
- )}`
- );
- }
-);
-
-
- To turn the CTA into an <a>
tag, specify a
- link-format
attribute, using :product
, :plan
,
- and :features
as placeholders:
+ By default, the CTA bottom-right will fire the
+ manifold-planSelector-click
event (above). But it can also be turned
+ into an <a>
tag by specifying link-format
:
<manifold-product
product-label="aiven-redis"
@@ -582,7 +624,14 @@ Navigation
/>
<!-- <a href="/product/aiven-redis?plan=startup-4&cpus=1"> -->
- Hiding provision button
+
+ :plan
, :product
, and :features
(for
+ customizable plans) will all be replaced with url-friendly slugs for each. In most
+ cases, these are all passable to
+ data components.
+
+ Hiding CTA
If you would like to hide the CTA altogether, specify hide-cta
:
<manifold-product product-label="till" hide-cta />
@@ -900,14 +949,14 @@ Example
document
.querySelector('manifold-marketplace')
- .addEventListener('manifold-serviceCard-click', e => {
+ .addEventListener('manifold-marketplace-click', e => {
const overlay = document.createElement('div');
overlay.className = 'overlay';
const modal = document.createElement('div');
modal.className = 'modal';
overlay.appendChild(modal);
const productPage = document.createElement('manifold-product');
- productPage.productLabel = e.detail.label;
+ productPage.productLabel = e.detail.productLabel;
modal.appendChild(productPage);
document.body.appendChild(overlay);