Guide to customizing OpenShop's frontend and backend to match your brand and requirements.
Customize the design system by editing tailwind.config.js:
export default {
content: [
"./index.html",
"./src/**/*.{js,ts,jsx,tsx}",
],
theme: {
extend: {
colors: {
// Add your brand colors
primary: '#your-color',
secondary: '#your-color',
},
fonts: {
// Add custom fonts
sans: ['Your Font', 'sans-serif'],
},
},
},
plugins: [],
}UI components are located in src/components/ui/:
- Button:
src/components/ui/button.jsx - Card:
src/components/ui/card.jsx - Input:
src/components/ui/input.jsx - Select:
src/components/ui/select.jsx
These components follow ShadCN/UI patterns and can be customized to match your design.
Global styles are in src/index.css:
@import "tailwindcss";
/* Add your custom styles */
:root {
--primary-color: #your-color;
--secondary-color: #your-color;
}Storefront theme customization is handled through the admin dashboard's theme settings, which are stored in Cloudflare KV.
Customize storefront-specific components:
- Navbar:
src/components/storefront/Navbar.jsx - Footer:
src/components/storefront/Footer.jsx - Product Card:
src/components/storefront/ProductCard.jsx - Cart:
src/components/storefront/Cart.jsx - Hero:
src/components/storefront/Hero.jsx
Customize page layouts:
- Storefront:
src/pages/storefront/Storefront.jsx - Product Page:
src/pages/storefront/ProductPage.jsx - Collection Page:
src/pages/storefront/CollectionPage.jsx - About Page:
src/pages/storefront/About.jsx
API routes are organized in src/routes/:
- Public Routes:
src/routes/public/- Products, collections, checkout, store settings
- Admin Routes:
src/routes/admin/- Products, collections, settings, analytics, AI, Drive
Customize middleware in src/middleware/:
- Authentication:
src/middleware/auth.js - CORS:
src/middleware/cors.js - Error Handling:
src/middleware/errorHandler.js - Security Headers:
src/middleware/securityHeaders.js - Validation:
src/middleware/validation.js
Core business logic is in src/lib/:
- KV Operations:
src/lib/kv.js - Stripe Integration:
src/lib/stripe.js - Authentication:
src/lib/auth.js - Utilities:
src/lib/utils.js
Service layer in src/services/:
- Product Service:
src/services/ProductService.js - Collection Service:
src/services/CollectionService.js - Stripe Service:
src/services/StripeService.js - Analytics Service:
src/services/AnalyticsService.js
-
Create Route Handler:
// src/routes/public/new-feature.js export async function onRequestGet(context) { // Your logic here return new Response(JSON.stringify({ data: 'result' }), { headers: { 'Content-Type': 'application/json' } }); }
-
Register Route in
src/routes/index.js:import { newFeature } from './public/new-feature.js'; app.get('/api/new-feature', newFeature);
- Create Admin Route in
src/routes/admin/ - Add Authentication Middleware:
app.use('/api/admin/new-feature', authMiddleware);
- Create Admin UI Component in
src/components/admin/ - Add to Admin Dashboard in
src/pages/admin/AdminDashboard.jsx
- Create Page Component in
src/pages/storefront/ - Add Route in
src/App.jsx:<Route path="/new-page" element={<NewPage />} />
- Add Navigation Link in
src/components/storefront/Navbar.jsx
- Mobile-First: Design for mobile, then scale up
- Semantic Classes: Use meaningful class names
- Component Patterns: Follow ShadCN/UI patterns
- Consistency: Maintain consistent spacing and colors
When Tailwind isn't enough:
- Global Styles: Add to
src/index.css - Component Styles: Use CSS modules or styled-components
- Theme Variables: Use CSS custom properties
- Breakpoints: Use Tailwind's responsive prefixes
- Mobile Optimization: Test on real devices
- Touch Targets: Ensure buttons are large enough
- Performance: Optimize for mobile networks
Set your logo through the admin dashboard:
- Text Logo: Enter your store name
- Image Logo: Upload a logo image
- Logo Position: Configure in theme settings
Customize colors through:
- Tailwind Config: Update color palette
- Theme Settings: Admin dashboard theme customization
- CSS Variables: Override default colors
Add custom fonts:
- Add Font Files to
public/fonts/ - Define in CSS:
@font-face { font-family: 'Your Font'; src: url('/fonts/your-font.woff2') format('woff2'); }
- Update Tailwind Config to use the font
Set up a custom domain:
- Add Domain in Cloudflare dashboard
- Update DNS to point to your Worker
- Configure SSL (automatic with Cloudflare)
- Update SITE_URL environment variable
Customize Stripe checkout:
- Checkout Session Options: Modify in
src/routes/public/checkout.js - Success/Cancel Pages: Customize in
src/pages/storefront/ - Email Templates: Configure in Stripe dashboard
Add custom analytics:
- Add Tracking Script to
index.html - Track Events in components
- Integrate Services: Google Analytics, Plausible, etc.
- Version Control: Commit all customizations
- Documentation: Document custom changes
- Testing: Test customizations thoroughly
- Performance: Monitor impact on performance
- Maintainability: Keep code clean and organized
- Check Tailwind Config: Ensure content paths are correct
- Rebuild: Run
npm run buildafter changes - Cache: Clear browser cache
- Specificity: Check CSS specificity
- Check Imports: Verify all imports are correct
- Check Routes: Ensure routes are registered
- Check Console: Look for JavaScript errors
- Check Build: Ensure build completes successfully
For more help, see the Troubleshooting Guide.