How shopify/discount-app-components works
Main Components
• Library Entry Point & Packaging:
• Main entry at src/index.ts. This represents the public API that consumers of the library will use.
• Build configuration files such as babel.config.js, the Rollup configuration in config/rollup, and the changesets files (e.g., .changeset folder). These show how the library is built and versioned.
• UI Component Modules:
• Extensive src/components directory where each discount-related component (e.g., ActiveDatesCard, CombinationCard, CurrencyField, etc.) is implemented. Each component has its own directory that includes source, styles, README, and tests.
• Emphasis on the AppProvider component in src/components/AppProvider. This wraps the discount app components and manages locale and timezone settings, making it a central component in the system.
• Storybook & Documentation:
• The src/stories directory contains multiple Storybook stories which serve as living documentation and playgrounds for the components.
• Additionally, include the documentation folder (documentation/SAMPLE_README.md) which may provide further context.
• Utilities & Configurations:
• Testing & Quality Assurance:
• Presence of tests within the src/components/*/tests folders and the separate tests directory that contains setup files and custom matchers.
• The CI configuration in .github/workflows and various config files (e.g., .eslintrc, .prettierrc) showcase the quality assurance practices.
Dependencies and External Relationships
• External Integrations:
• Connection between this library and external dependencies such as @shopify/polaris and @shopify/app-bridge (as specified in the README’s installation instructions).
• Build and Release Process:
• Automated release and publishing process (using changesets, GitHub workflows, and yalc for local testing).
• A segment for versioning and changelog generation (CHANGELOG.md and changeset files) should be shown.
Representation of Architectural Patterns
• Component-based Architecture:
• That the project is structured around discrete, stateless components that are composed to build the discount experience.
• Separation of Concerns:
• Clearly separate the UI components from utility functions, configuration, and testing.
• Extensibility & Integration Points:
• AppProvider as a critical integration point where both Polaris and discount components are composed together.
• Locales folder as it demonstrates internationalization support within components.