How vaadin/react-components works
Main Components
• Component Libraries:
• packages/react-components: Contains the base set of React wrappers.
• packages/react-components-pro: Contains a more advanced or “pro” set of React wrappers (and may include additional features controlled via separate build scripts and utilities).
• Development Environment:
• dev: Includes example/demo pages, such as the “kitchen-sink” and various sample pages (e.g., Button.tsx, ContextMenu.tsx) that demonstrate how the components are used.
• Vite Config: The vite.config.ts file is used with a custom plugin to allow local component testing within a Vaadin application.
• Build and Utility Scripts:
• scripts: Various build, package management, and code generation scripts that drive the package build/update process.
• Testing:
• test: Contains test files for various components (e.g., ComboBox.spec.tsx, Dialog.spec.tsx) and related utility functions for testing.
• CI/CD:
• .github/workflows: Contains GitHub actions (e.g., validation.yml) to automate build/validation processes.
Establish Relationships and Interactions
• The React component libraries (react-components and react-components-pro) are core. They are built using the build scripts and then imported into consumer projects.
• The dev directory provides demos and example usage, simulating how a Vaadin consumer application can integrate the libraries. The custom Vite plugin (with its configuration in the README) is an important bridge in this interaction.
• The Vite configuration file (vite.config.ts) incorporates the “useLocalReactComponents” plugin. This plugin allows a local Vaadin project to load these libraries from the local filesystem, emphasizing a local development/testing cycle.
• Build and testing scripts collaborate to validate the changes in the component libraries during development and before deployment.
• GitHub workflows (CI/CD) ensure that code quality checks, builds, and validations are automatically applied to changes.
Architectural Patterns and Design Principles
• Monorepo Architecture: The project structure is organized into separate packages sharing a common repository. This facilitates code reuse and coordinated versioning.
• Separation of Concerns: The distinct separation between the core component libraries, development demo applications, and build/test infrastructure illustrates clear boundaries and responsibilities.
• Plugin-Based Extensibility: The custom Vite plugin (as detailed in the README) demonstrates an architectural approach to extend configuration and integration seamlessly with Vaadin projects.
• Component-Driven Architecture: Both the base and “pro” packages are designed in a modular fashion, each exporting self-contained UI components that can be individually imported and tested.
Relevant Technologies and Frameworks
• React: The component libraries are React-based.
• Vaadin: The target is to provide React wrappers around Vaadin components.
• Vite: Used as the build tool and development server, enhanced with custom plugins.
• TypeScript: Evident from the file extensions (.ts, .tsx) and the presence of tsconfig files.
• Testing Frameworks: Likely using Jest or a similar testing library (given the .spec.tsx files and testing utilities).