--- name: diamond-fysio-frontend description: Review and write React/Next.js components for Diamond Fysio project. Use when reviewing components, adding features, or checking code quality. Enforces project patterns like Tailwind CSS, accessibility, Contentful integration, and i18n. allowed-tools: Read, Grep, Glob, Edit, Write --- # Diamond Fysio Frontend Skill This skill ensures consistency with the Diamond Fysio project's frontend patterns and best practices. ## Project Overview - **Framework**: Next.js 16 with Pages Router (primary) + App Router (new routes) - **React**: v19 - **TypeScript**: Mixed (TSX and JSX components) - **Styling**: Tailwind CSS - **CMS**: Contentful with GraphQL - **Icons**: Heroicons, FontAwesome, React Icons - **Forms**: React Hook Form - **Animation**: Framer Motion - **i18n**: Dutch (nl) and English (en) locales ## Code Review Checklist When reviewing or writing components, verify: ### 1. Accessibility (Critical) - **ARIA labels**: All interactive elements must have `aria-label` attributes - **Keyboard navigation**: Use `tabIndex={0}` for focusable elements - **Focus states**: Apply `focus:outline-none focus-visible:ring-2 focus-visible:ring-teal-500` - **Semantic HTML**: Use proper heading hierarchy (h1, h2, h3) - **Alt text**: All images must have meaningful `alt` attributes **Example from Button.jsx**: ```jsx
{title}
``` ### 2. Styling Patterns - **Use Tailwind CSS** exclusively (no inline styles or CSS modules) - **Gradient buttons**: Follow the pattern `bg-gradient-to-r from-teal-500 to-cyan-600` - **Hover states**: `hover:from-teal-400 hover:to-cyan-500` - **Responsive design**: Use `md:`, `lg:` prefixes for breakpoints - **Consistent spacing**: Use Tailwind spacing scale (px-8, py-3, etc.) **Common button classes**: ```jsx const btnType = 'w-full inline-flex items-center justify-center px-8 py-3 text-base font-medium rounded-md text-white bg-gradient-to-r from-teal-500 to-cyan-600 hover:from-teal-400 hover:to-cyan-500 md:py-4 md:text-lg md:px-10 shadow focus:outline-none focus-visible:ring-2 focus-visible:ring-teal-500'; ``` ### 3. Internationalization (i18n) - **Support both nl and en locales** - **Use router locale**: `const locale = router?.locale || 'nl'` - **Provide fallback defaults** for all translated strings - **Structure**: Create defaults object with nl/en keys **Example pattern**: ```jsx const router = useRouter(); const locale = router?.locale || 'nl'; const isEn = locale === 'en'; const defaults = { nl: { title: 'Nederlandse tekst', ... }, en: { title: 'English text', ... } }; const t = { title: i18n?.title || defaults[locale].title }; ``` ### 4. Next.js Routing - **Internal links**: Use `next/link` with `` - **External links**: Use `` - **Locale awareness**: Check `router.locale` for current language - **Pages structure**: Components in `/components`, pages in `/pages` ### 5. React Patterns - **Hooks**: Use modern hooks (useState, useRouter, etc.) - **Props destructuring**: `({ title, type, internal_link }) => {}` - **Default props**: Use ES6 defaults `extra_classes = ''` - **No React import needed**: Next.js handles this automatically ### 6. Contentful Integration - **GraphQL queries**: Store in `/lib/query/` - **Content types**: Check `/components/contentTypes/` for type definitions - **Rich text**: Use `@contentful/rich-text-react-renderer` - **Image optimization**: Use Next.js `{title}
) : ( {title} ); }; export default Button; ``` ### Issues to Fix ❌ ```jsx // Missing: Next.js Link, accessibility, Tailwind classes const Button = ({ title, link }) => { return ( {' '} {/* inline style! */} {title} {/* no aria-label! */} ); }; ``` ## When Adding New Features 1. **Check existing components** for similar patterns first 2. **Maintain accessibility** from the start 3. **Support both languages** (nl/en) 4. **Use Tailwind utilities** instead of custom CSS 5. **Test keyboard navigation** and focus states 6. **Follow the gradient/color scheme** for consistency 7. **Add proper error handling** and loading states 8. **Document complex logic** with comments if needed ## Testing Considerations - Verify accessibility with keyboard navigation - Test both Dutch and English versions - Check mobile responsiveness (Tailwind breakpoints) - Validate form submissions - Test with Contentful data (staging and production) ## Deployment & Testing URLs - **Live URL**: https://fysiodiamondfactory.nl - **Recent deployments**: Check fysiodiamondfactory.nl for the latest production version When testing features, always verify on the live site to ensure proper deployment. ## Resources - Tailwind config: `/tailwind.config.js` - ESLint config: `/eslint.config.js` - TypeScript config: `/tsconfig.json` - Documentation: `/docs/` folder