diff --git a/README.md b/README.md index 664b09fc2b..926d8c0e3b 100644 --- a/README.md +++ b/README.md @@ -111,3 +111,75 @@ But this does work: 5. Launch the local development server: `shopify theme dev` + +--- + +# Other Versions of the Starter Theme + +## Tailwind Admin Fields + +- [Branch](https://github.com/TrellisCommerce/shopify-tailwind-starter-base/tree/tailwind-admin-fields) + +### How Is It Different + +Multiple admin fields have been added at the theme level, as well as at the section level, to allow for more granular control over the Dawn theme's settings and elements directly through the admin by inputting Tailwind CSS classes as values. + +### How To Use + +First, decide if you want to configure the `tailwind.config.js` file to allow for your specific font families, sizes, colors, etc to cut down on the generated Tailwind CSS file from the start, or you can just jump in and take advantage of all the default Tailwind CSS classes. + +1. Affect global animation timing & easing from [Easing Functions Cheat Sheet](https://easings.net/) in Theme Settings under Animations: + +Animation Tailwind CSS settings + +2. Affect global elements in the Theme Settings under the Tailwind CSS accordion: + +Global element Tailwind CSS theme settings + +3. Affect global elements and page-level sections under the Tailwind CSS heading for each Dawn element in the admin: + +Header Tailwind CSS settings + +### If Using in Conjunction with a Development Team + +#### Optimizing CSS + +In order to make all the Tailwind classes available for the editor in the admin, the following was added to the `tailwind.config.js` file to include ALL classes, as well as breakpoint & hover variants, and to add `!important` to each class to make sure it overrides any existing Dawn styles: + +``` +... +// safelist is added to provide all styles for design to add through the admin +safelist: [ + { + pattern: /.*/, + variants: ['xs', 'sm', 'md', 'lg', 'hover', 'group-hover'], + }, +], +// !important is added to override core Dawn styles for design +important: true, +... +``` + +If this theme is handed over to a development team who will be editing the code directly, the safelist array will need to be removed (ideal to also remove the `important` key, but that would require adjusting any conflicting Dawn styles) from the config file and the following added to the content array to have Tailwind recognize the classes added through the admin fields: + +``` +content: [ + ... + './**/*.json', +], +``` + +If desired, run the Tailwind compile command to purge any unused styles (this step is optional as making a commit with changes to the tailwind config file will auto-generate a new `app.css` file after the commit is pushed, but this step will allow for a quick check on the proper purging of the classes): `npx tailwindcss -i ./assets/app-tailwind.css -o ./assets/app.css` + +#### Lock Down the Admin Fields + +To lock down the Tailwind CSS admin fields from being editied through the admin, run `gulp` in your terminal to transform all Tailwind text fields to checkbox fields instead and to add the following paragraph text to all Tailwind sections: + +_Tailwind fields are not editable through the admin at this stage. Please contact a Trellis engineer if changes are needed._ + +| :bangbang: | Note that toggling one of the checkboxes after running `gulp` will remove the contents of the tailwind admin fields. Since removing the fields also removes the entered values, swapping to a different field type preserves the values and does not allow for editing the values. | +|:----------:|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| + +#### Code Review of Classes Inserted Through the Admin + +It is recommended to have a separate branch & connected theme version created for the design team to use when adding in classes through the admin fields. This way, when it is time to merge in the changes from that branch to another theme branch, a pull request can be created and all the commits can be reviewed all at once instead of reviewing each individual commit generated by `shopify[bot]`.