Open mozey opened 3 years ago
Note that the framework is not bundled with the components. The reasons for this are
s2s-cart.js
) can be refreshed without having to rebuild all the componentsPrice.vue
) directly into their Vue appData Flow Diagram between s2s namespace, components and external APIs
The diagram above shows store giving components a copy of its internal data structure. That obviously's a good idea, we want to restrict the components to using getters (and maybe setters) on the global namespace s2s
.
For VueJS components, above can be implemented using a Simple Store Pattern. The components may set data returned by getters on their privateState
.
Above diagram does not currently describe sharedState
, as it's not yet needed, but keep it in mind in case it's needed for something in the future.
Components must respect convention and not mutate store data directly, i.e. the sharedState
is read only
@flumonion
There should be a
Stock2ShopStore.ts
object that is specific to routes defined on an API (e.g. stock2shop.com orWooCommerceStore.ts
for WooCommerce), but independent from the JavaScript framework (e.g. VueJS, React or Angular).The store
Components are isolated from the rest of the page with Shadow DOM, however they can share state via a global
stores2s
namespace, with servicess2s.store
ands2s.cart
. See https://github.com/stock2shop/cart/pull/5#issuecomment-774104315 re Javascript SDK. Side note, the components have default styling. However, since components have open shadow-root, the page can override the default styling with custom CSS (keeping in mind recent encapsulation restrictions).At a bare minimum the user must include a JS file, and create markup with custom elements, for example
Where
s2s-cart.js
might be constructed like this for Stock2Shop and VueJSOr like this for WooCommerce and React