This directory contains comprehensive documentation for the Sections system in the Fynd Commerce App. Sections are reusable UI components that allow sellers to create customizable page templates through the Theme Editor.
- Section Pages Overview - Complete guide to understanding section pages, how they work, and their architecture
- Creating Sections Guide - Step-by-step practical guide for creating custom sections
- Read the Overview: Start with Section Pages Overview to understand the system
- Follow the Guide: Use Creating Sections Guide for hands-on development
- Check Examples: Review existing sections in
src/sections/for reference
- Section Pages: Dynamic pages that render multiple sections
- Section Renderer: Component that handles section loading and rendering
- Section Map: Registry of available sections
- Navigation Tracker: Handles URL parsing and theme data fetching
User Navigation β URL Parsing β Theme Fetching β Section Rendering β Predicate Evaluation β UI Display
- Hero Image: Banner section with image, text, and call-to-action
- Text Section: Simple text content display
- Product Grid: Product listing with customizable layout
- Custom Sections: Developer-created reusable components
- Content Sections: Display text, images, and media
- Interactive Sections: Buttons, forms, and user interactions
- Layout Sections: Containers and structural elements
- Data Sections: Display dynamic content from APIs
- Define section purpose and functionality
- Identify configuration requirements
- Plan responsive behavior
- Determine predicate needs
- Create section directory structure
- Implement component logic
- Define settings configuration
- Add to section map
- Unit test component functionality
- Test configuration options
- Verify responsive behavior
- Validate predicate logic
- Add to theme configuration
- Test in Theme Editor
- Deploy to staging
- Monitor performance
section-name/
βββ index.ts # Default export
βββ section-name.tsx # Main component
βββ styles.ts # Styled components
βββ README.md # Documentation
// Component export
export function SectionName({props, blocks}: any) {
// Implementation
}
// Settings export
export const settings = {
label: 'Section Display Name',
props: [
// Configuration schema
],
blocks: [
// Block configurations
],
};- text: Single line text input
- textarea: Multi-line text input
- image: Image upload/selection
- url: URL input with validation
- color: Color picker
- select: Dropdown selection
- checkbox: Boolean toggle
- number: Numeric input
- category: Category selection
{
type: "text",
id: "heading",
default: "Default Value",
label: "User-Friendly Label",
info: "Help text for users"
}predicate: {
user: {
anonymous: true, // Show for non-logged-in users
authenticated: true // Show for logged-in users
}
}predicate: {
screen: {
mobile: true, // Show on mobile devices
tablet: true // Show on tablet devices
}
}predicate: {
platform: {
ios: true, // Show on iOS
android: true // Show on Android
}
}- Mobile: < 768px width
- Tablet: β₯ 768px width
- Design mobile-first
- Use flexible layouts
- Test on multiple devices
- Handle orientation changes
- Optimize for performance
import {render, fireEvent} from '@testing-library/react-native';
import {MyCustomSection} from './my-custom-section';
describe('MyCustomSection', () => {
it('renders correctly', () => {
const {getByText} = render(<MyCustomSection {...mockProps} />);
expect(getByText('Test Heading')).toBeTruthy();
});
});- Test section rendering in SectionRenderer
- Verify predicate evaluation
- Test configuration options
- Validate navigation behavior
- Use React.lazy for code splitting
- Implement React.memo for memoization
- Optimize image loading
- Minimize re-renders
- Cache expensive calculations
- Track section load times
- Monitor memory usage
- Measure user interactions
- Analyze performance metrics
-
Section Not Rendering
- Check section map registration
- Verify predicate conditions
- Look for console errors
-
Configuration Not Working
- Validate prop structure
- Check prop value access
- Verify default values
-
Styling Issues
- Check theme integration
- Verify style function
- Test on different devices
-
Performance Problems
- Implement memoization
- Optimize image loading
- Check for unnecessary re-renders
See src/sections/hero-image/ for a complete example with:
- Complex layout positioning
- Hotspot functionality
- Responsive design
- Multiple configuration options
- Predicate support
Use the template in src/sections/my-custom-section/ as a starting point.
When contributing new sections:
- Follow established patterns
- Add comprehensive tests
- Include proper documentation
- Test on multiple devices
- Optimize for performance
- Follow accessibility guidelines
For questions or issues:
- Check the troubleshooting section
- Review existing examples
- Consult the platform documentation
- Contact the development team
Last Updated: December 2024
Version: 1.0.0