Shopify / blockchain-components

Blockchain related React UI components for Shopify storefronts
https://blockchain.shopify.dev
MIT License
81 stars 18 forks source link

:sparkles: Adds support for custom titles with dynamic values #185

Closed QuintonC closed 1 year ago

QuintonC commented 1 year ago

⚠️ Fixes:

ℹ️ What is the context for these changes?

This PR adds support for custom discountTitles that retain the discount value within the title. This will work for both locked and unlocked title variants.

This also relocates some code that was used for tokengate state / titles, etc. The files were quite large and becoming cumbersome to comb through while attempting to add support for new features.

🕹️ Demonstration

Dynamic values

Locked Unlocked
discount-dynamic-value-locked discount-dynamic-value-unlocked

Order limits

ALL ANY Pluralization
order-limit-all order-limit-any singular-pluralization

🎩 How can this be tophatted?

I updated Storybook to include the ability to specify custom titles in it. To place the dynamic value anywhere, just place {{value}} inside of your custom title.

📖 Storybook

✅ Checklist

QuintonC commented 1 year ago

/snapit

github-actions[bot] commented 1 year ago

🫰✨ Thanks @QuintonC! Your snapshot has been published to npm.

Test the snapshot by updating your package.json with the newly published version:

yarn add @shopify/tokengate@0.0.0-snapshot-20230511185047
QuintonC commented 1 year ago

LGTM

This is good as-is. Some of these changes seem like a matter of preference rather than needing to be done to test/clean up the code. I only mention this b/c you mentioned this PR being a bigger one.

👍 It's a mix of quite a few things which I think make it big. Those things being preference, organization, separation of concerns (in some areas), adding tests where there weren't tests before, supporting custom titles + pluralization, and addressing a bug with the redemption limit subtitle + adding tests for that fix.