theme-scripts
theme-scripts copied to clipboard
[Discussion] Create a separate package for "good practices"
Background: There was a recent PR that looked to add back a method to theme-cart
that checked for cookies https://github.com/Shopify/theme-scripts/pull/63. It was decided not to include the method because it wasn't about interacting with Shopify's cart API.
Discussion
I feel it is useful to have a method available to see whether cookies are enabled as part of theme-scripts
since cookies are required to build a cart in Shopify. It is a good practice for any theme developer to implement some behaviour when cookies are disabled. For example: On the Themes team at Shopify, we display a warning message in the cart when cookies are disabled. Alternatively, in this PR it was mentioned that a theme could save a cart object in localstorage
.
For this conversation, it's not about what a theme should do when cookies are disabled, but rather that a check for cookies is a good practice that devs should be considering. So how should we be capturing these good practices? Or should we at all?
I'd argue that we already provide a collection of "good practice" methods in theme-rte
and theme-a11y
. These scripts don't help with Shopify-specific things, like dealing with the Cart API as seen in theme-cart
, or handling a product JSON object seen in theme-product
; but they are useful to the community nonetheless in building responsive and accessible themes.
Suggestion
Perhaps we should create a "theme utilities" package that has a bunch of methods that are good web development practice. For a start: this could collapse theme-rte
and theme-a11y
into the same general web dev package.
This would send a clearer signal that packages are for handling Shopify-specific considerations, except for this one theme-utils
package that is best practices.
The theme-rte
package is only handling responsive iframes and tables. It's "Shopify specific" in as far as it is a good safety measure for merchants uploading <iframe>
and <table>
elements into the RTE. However, the accessibleLinks
method of theme-a11y
does something similar by making sure any link has proper descriptions for screen readers - which is great for links inserted via an RTE.
cc @jonathanmoore @wizardlyhel @t-kelly