payaza-storefront-layouts
v1.0.61
Published
Shared layout components for StoreFront applications
Downloads
5,867
Maintainers
Readme
payaza-storefront-layouts
A comprehensive package of shared layout components, utilities, and services for StoreFront applications. This package contains all layout components, UI components, hooks, contexts, and utility functions used across Payaza StoreFront applications.
Overview
This package provides a complete set of reusable layout components that are data-agnostic and accept storeConfig as props, allowing multiple stores to use the same layout instances with different data. It includes:
- 9 Layout Types: Food, Food Modern, Clothing, Clothing Minimal, Booking, Booking Agenda, Electronics, Electronics Grid, and Motivational Speaker
- Shared Components: Base layouts, headers, footers, and common page components
- UI Components: Buttons, modals, toasts, product cards, and more
- Learning Components: Certificate templates, mentorship progress, and certificate viewer
- Services: API services for checkout, payment, shipping, orders, and more
- Utilities: Asset helpers, currency formatting, demo detection, and more
- Contexts: Auth, Store, and Loading contexts
Installation
npm install payaza-storefront-layoutsOr using npm workspaces:
{
"dependencies": {
"payaza-storefront-layouts": "workspace:*"
}
}Peer Dependencies
This package requires the following peer dependencies (must be installed in your project):
{
"@tailwindcss/postcss": "^4.0.0",
"framer-motion": "^12.0.0",
"next": "^16.0.3",
"postcss": "^8.0.0",
"react": "^19.2.0",
"react-dom": "^19.2.0",
"tailwindcss": "^4.0.0"
}CSS Setup
This package includes a complete CSS file with Tailwind CSS v4, custom utilities, and styles. To use the layouts, you need to:
1. Install Peer Dependencies
npm install tailwindcss@^4.0.0 @tailwindcss/postcss@^4.0.0 postcss@^8.0.02. Configure PostCSS
Create or update postcss.config.mjs in your project root:
const config = {
plugins: {
"@tailwindcss/postcss": {},
},
};
export default config;3. CSS is Automatically Imported
No separate CSS import needed! The styles are automatically imported when you import any component from the package:
import { FoodHomePage } from 'payaza-storefront-layouts';
// Styles are automatically loaded - no additional import neededIf you need to import styles separately (e.g., in a CSS file), you can still use:
@import "payaza-storefront-layouts/styles";4. Configure Tailwind Content Paths
If you're using a traditional Tailwind config, ensure it scans the package files:
// tailwind.config.ts
import type { Config } from 'tailwindcss';
const config: Config = {
content: [
'./pages/**/*.{js,ts,jsx,tsx,mdx}',
'./components/**/*.{js,ts,jsx,tsx,mdx}',
'./app/**/*.{js,ts,jsx,tsx,mdx}',
'./node_modules/payaza-storefront-layouts/dist/**/*.{js,jsx}',
],
// ... rest of config
};
export default config;Note: With Tailwind CSS v4, you typically don't need a tailwind.config.ts file. The @import "tailwindcss" directive in the CSS file handles everything automatically.
Alternative: Use Your Own Tailwind Setup
If you prefer to use your own Tailwind configuration, you can:
- Skip importing the package CSS file
- Configure Tailwind to scan the package files as shown above
- Ensure you have the required custom utilities and CSS variables in your own CSS
The package CSS includes:
- Tailwind CSS v4 base styles
tw-animate-cssanimations- Custom utility classes (glassmorphism, animations, scroll utilities)
- Custom NProgress styles
- CSS variables for theming
Usage
Basic Layout Usage
import { FoodHomePage, FoodProductsPage, FoodProductDetailPage } from 'payaza-storefront-layouts';
export default function StorePage({ storeConfig }) {
return <FoodHomePage storeConfig={storeConfig} />;
}Using Layout-Specific Pages
import {
FoodProductsPage,
FoodProductDetailPage,
FoodCategoryPage,
FoodCategoriesPage,
FoodMenuPage,
FoodAboutPage,
FoodContactPage
} from 'payaza-storefront-layouts';
// Use layout-specific pages
<FoodProductsPage storeConfig={storeConfig} />
<FoodProductDetailPage storeConfig={storeConfig} productId="123" />Using Shared Components
import {
BaseStoreLayout,
GenericPageWrapper,
StoreHeader,
StoreFooter,
AccountPage,
CartPage,
CheckoutPage
} from 'payaza-storefront-layouts';
<BaseStoreLayout storeConfig={storeConfig}>
{/* Your content */}
</BaseStoreLayout>Using Learning Components
import {
CertificateCard,
CertificateViewer,
MentorshipProgress
} from 'payaza-storefront-layouts';
<CertificateCard
certificate={certificateData}
onDownload={(id) => console.log('Download', id)}
/>Using Utilities
import {
formatCurrency,
filterActiveServices,
getBannerImage,
getServiceImage,
getThemeColor,
isDemoStore,
shouldUseAPI
} from 'payaza-storefront-layouts';
const price = formatCurrency(1000, 'NGN'); // "₦1,000.00"
const activeServices = filterActiveServices(services);
const bannerUrl = getBannerImage(storeConfig);Using JSON Layout Data
import { getLayoutJSON, layoutJSONMap } from 'payaza-storefront-layouts/json';
const layoutData = getLayoutJSON('food');
// or
const layoutData = layoutJSONMap.get('food');Available Layouts
Food Layouts
FoodHomePage- Main homepage componentFoodProductsPage- Products listing pageFoodProductDetailPage- Product detail pageFoodCategoryPage- Category detail pageFoodCategoriesPage- Categories listing pageFoodMenuPage- Menu pageFoodAboutPage- About pageFoodContactPage- Contact page
Food Modern Layouts
FoodHomePageModern- Modern food homepageFoodModernProductsPage- Modern products pageFoodModernProductDetailPage- Modern product detailFoodModernCategoryPage- Modern category pageFoodModernCategoriesPage- Modern categories pageFoodModernMenuPage- Modern menu pageFoodModernAboutPage- Modern about pageFoodModernContactPage- Modern contact page
Clothing Layouts
ClothingHomePage- Clothing homepageClothingProductsPage- Products pageClothingProductDetailPage- Product detailClothingCategoryPage- Category pageClothingCategoriesPage- Categories pageClothingAboutPage- About pageClothingContactPage- Contact page
Clothing Minimal Layouts
ClothingHomePageMinimal- Minimal clothing homepageClothingMinimalProductsPage- Minimal products pageClothingMinimalProductDetailPage- Minimal product detailClothingMinimalCategoryPage- Minimal category pageClothingMinimalCategoriesPage- Minimal categories pageClothingMinimalAboutPage- Minimal about pageClothingMinimalContactPage- Minimal contact page
Booking Layouts
BookingHomePage- Booking homepageBookingBookPage- Book appointment pageBookingServicesPage- Services listing pageBookingProductDetailPage- Service detail pageBookingCategoryPage- Category pageBookingCategoriesPage- Categories pageBookingAboutPage- About pageBookingContactPage- Contact page
Booking Agenda Layouts
BookingHomePageAgenda- Agenda-based booking homepageBookingAgendaBookPage- Agenda book pageBookingAgendaServicesPage- Agenda services pageBookingAgendaProductDetailPage- Agenda service detailBookingAgendaCategoryPage- Agenda category pageBookingAgendaCategoriesPage- Agenda categories pageBookingAgendaAboutPage- Agenda about pageBookingAgendaContactPage- Agenda contact page
Electronics Layouts
ElectronicsHomePage- Electronics homepageElectronicsProductsPage- Products pageElectronicsProductDetailPage- Product detailElectronicsCategoryPage- Category pageElectronicsCategoriesPage- Categories pageElectronicsAboutPage- About pageElectronicsContactPage- Contact pageElectronicsHelpCenterPage- Help center pageElectronicsPrivacyPolicyPage- Privacy policy pageElectronicsShippingReturnsPage- Shipping & returns pageElectronicsTermsPage- Terms pageElectronicsTrackOrderPage- Track order pageElectronicsPageWrapper- Page wrapper componentElectronicsStoreHeader- Store headerElectronicsStoreFooter- Store footer
Electronics Grid Layouts
ElectronicsHomePageGrid- Grid-based electronics homepageElectronicsGridProductsPage- Grid products pageElectronicsGridProductDetailPage- Grid product detailElectronicsGridCategoryPage- Grid category pageElectronicsGridCategoriesPage- Grid categories pageElectronicsGridAboutPage- Grid about pageElectronicsGridContactPage- Grid contact pageElectronicsGridHelpCenterPage- Grid help center pageElectronicsGridPrivacyPolicyPage- Grid privacy policy pageElectronicsGridShippingReturnsPage- Grid shipping & returns pageElectronicsGridTermsPage- Grid terms pageElectronicsGridTrackOrderPage- Grid track order page
Motivational Speaker Layouts
MotivationalHomePage- Motivational speaker homepageMotivationalProductsPage- Products pageMotivationalCategoryPage- Category pageMotivationalServicesPage- Services pageMotivationalServiceDetailPage- Service detail pageMotivationalSubscriptionPage- Subscription pageMotivationalAboutPage- About pageMotivationalContactPage- Contact pageMotivationalPageWrapper- Page wrapper component
Shared Components
BaseStoreLayout- Base layout wrapper for all storesGenericPageWrapper- Generic page wrapperStoreHeader- Store header componentStoreFooter- Store footer componentPromoBanner- Promotional banner componentTestimonialCard- Testimonial card component
Shared Pages
AccountPage- User account page with tabs (Profile, Orders, Bookings, Wishlist, Learning)CartPage- Shopping cart pageCheckoutPage- Checkout pageWishlistPage- Wishlist pageTeamPage- Team members pagePortfolioPage- Portfolio pageHelpCenterPage- Help center pageShippingReturnsPage- Shipping & returns pagePrivacyPolicyPage- Privacy policy pageTermsPage- Terms of service pageCookiePolicyPage- Cookie policy pageSizeGuidePage- Size guide pageStyleGuidePage- Style guide pageTrackOrderPage- Track order pageMaintenancePage- Maintenance mode pageFeatureDisabledPage- Feature disabled page
Learning Components
CertificateCard- Certificate card componentCertificateViewer- Certificate viewer componentMentorshipProgress- Mentorship progress component
Utilities
Asset Helpers
import {
getBannerImage,
getServiceImage,
getTeamMemberImage,
getTextContent,
getLayoutText,
getThemeColor,
getLogoUrl
} from 'payaza-storefront-layouts';Currency & Formatting
import {
formatCurrency,
normalizePrice,
getCurrencySymbol,
getCurrencySymbolInfo
} from 'payaza-storefront-layouts';Demo Detection
import {
isDemoStore,
shouldUseAPI,
getBaseStoreSlug
} from 'payaza-storefront-layouts';Filtering
import {
filterActiveProducts,
filterActiveServices
} from 'payaza-storefront-layouts';Store Configuration
import {
getStoreConfigAsync,
transformProductToStoreProduct,
extractImageUrls
} from 'payaza-storefront-layouts';Services
The package includes service stubs for:
checkoutService- Checkout operationspaymentService- Payment processingshippingService- Shipping operationsorderService- Order managementwishlistService- Wishlist operationscustomerService- Customer managementbookingService- Booking operationscartService- Cart operationsproductService- Product operationscategoryService- Category operationsreviewService- Review operationsanalyticsService- Analytics tracking
Contexts
Auth Context
import { AuthProvider, useAuth } from 'payaza-storefront-layouts';
<AuthProvider>
<YourApp />
</AuthProvider>
// In components
const { user, isAuthenticated, login, logout } = useAuth();Store Context
import { StoreProvider, useStore } from 'payaza-storefront-layouts';
const { storeConfig, updateStoreConfig } = useStore();Loading Context
import { LoadingProvider, useLoading } from 'payaza-storefront-layouts';
const { startBackendLoading, stopBackendLoading } = useLoading();Hooks
Analytics Hook
import { useAnalytics } from 'payaza-storefront-layouts';
const { trackEvent, trackPageView } = useAnalytics();TypeScript Configuration
Consuming apps need to configure TypeScript paths. The package uses relative imports internally, so no special path configuration is required for the package itself.
For your app's internal @/ aliases:
{
"compilerOptions": {
"paths": {
"@/*": ["./*"]
}
}
}Next.js Configuration
Add to next.config.ts:
const nextConfig = {
transpilePackages: ['payaza-storefront-layouts'],
};Building
npm run buildThis will:
- Clean the
dist/directory - Compile TypeScript to JavaScript
- Transform path aliases using
tsc-alias - Copy JSON files to the dist directory
Package Structure
payaza-storefront-layouts/
├── dist/ # Compiled output
│ ├── layouts/ # Layout components
│ ├── components/ # UI components
│ ├── lib/ # Utilities, services, contexts
│ ├── hooks/ # Custom hooks
│ └── json/ # Layout JSON data
├── src/ # Source files
└── package.jsonDynamic Data Support
Layouts are designed to work with dynamic data:
- All layout components accept
storeConfig: StoreConfigas props - Layouts use hooks like
useStore()from consuming apps - No hardcoded data - all data comes from consuming apps
- Supports
preview_layoutquery parameter for layout preview - Demo store detection for mock data vs API data
Features
- ✅ 9 Complete Layout Types - Food, Clothing, Booking, Electronics, and more
- ✅ Shared Components - Reusable components across all layouts
- ✅ Learning Components - Certificate and mentorship features
- ✅ TypeScript Support - Full type definitions included
- ✅ Utility Functions - Currency formatting, asset helpers, filtering
- ✅ Service Stubs - Ready-to-use service interfaces
- ✅ Context Providers - Auth, Store, and Loading contexts
- ✅ Custom Hooks - Analytics and more
- ✅ Responsive Design - All components are mobile-responsive
- ✅ Accessibility - ARIA labels and keyboard navigation support
Version
Current version: 1.0.0
License
ISC
Support
For issues, questions, or contributions, please contact the Payaza development team.
