New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Agnostic UI #199
Merged
Agnostic UI #199
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* changes * Adding shopify commit * Changed to query page by id * Fixed page query, Changed use-search GraphQl query * Update use-search.tsx * remove unused util * Changed cookie expiration * Update tsconfig.json Co-authored-by: okbel <curciobel@gmail.com>
lfades
approved these changes
Mar 3, 2021
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Agnostic UI
Since Next.js Commerce came out one of our goals was to make it provider-agnostic. Today we're able to ship the first stable iteration of the agnostic UI.
Why
Frontend applications can be divided into two entities UI and Data. The UI accounting for the visual components and interactivity and the Data accounting for the application state and content.
Following these principles, the UI can be represented as a pure function of state or content. The less side-effects our components have, the more we can deterministically predict our application and build with confidence.
In order to make Next.js Commerce ready for multiple providers we needed a way to normalize data and inject it into the UI with the least amount of changes and with solid defaults.
That's why we built a set of wrappers and helper functions to create stable providers that the UI can trust.
Considerations
framework/commerce
contains all types, helpers and functions to be used as base to build a new provider.framework
's root folder and they will extend Next.js Commerce types and functionality.features
incommerce.config.json
and if needed it can also be accessed programatically.next.config.js
andcommerce.config.json
adding specific data related to the provider. For example in case of BigCommerce, the images CDN and additional API routes.framework/commerce
, on their own framework folder and on some dependencies included inpackage.json
env.template
file and a[readme.md](http://readme.md)
file.Features API
For feature parity between providers we added the Features API. This new addition means that you are now able to turn some features on and off based on your needs or the capabilities of the provider. This is particularly needed if a certain provider does not have e.g
wishlist
functionality, or other features.The configuration for features should be expressed at
commerce.config.json
in each provider folder. If you need to turn something off for your application independently of the chosen provider, you can achieve this by modifying the finalcommerce.config.json
at the root folder level.Enhanced Folder Structure
Both
framework
andcomponents
folders are structured by functionality. This means that all related to a specific subset of functionality will live within that folder.Common commerce functionality includes:
products
,wishlist
,customer
,cart
,auth
.These tokens by functionality are important because we might not want to build features and add them to the bundle, so it's easier to ignore them per folder.
Summary of Updates
framework/commerce
commerce.config.json
added.Wiki
How to change providers
provider
selected incommerce.config.json
and set it to the new provider:paths
defined intsconfig.json
and update the@framework
paths to point to the right folder provider:How to create a new provider
How to turn Features on and off
NOTE: The selected provider should support the feature that you are toggling. (This means that you can't turn wishlist on if the provider doesn't support this functionality out the box)
commerce.config.json
wishlist
on by settingwishlist
totrue
.Future updates
We're incredibly thankful to the amazing people that contributed to Next.js Commerce. We're pretty stoked with this release and excited to unlock the future of commerce.