11 KiB
Claude AI Instructions
This document contains instructions for AI assistants working on this project.
Project Overview
This is a static, animated placeholder page for the Shadoll project. It features configurable gradient backgrounds and SVG logo animations, designed to be deployed on GitHub Pages without any backend infrastructure.
Core Principles
- Pure Frontend: No backend dependencies, all functionality in HTML/CSS/JavaScript
- GitHub Pages Compatible: Must work as a static site
- Performance First: Smooth 60fps animations, minimal resource usage
- Configuration Flexibility: URL parameters for customization
- Progressive Enhancement: Works without JavaScript, enhanced with it
- Mobile-First Design: Unified approach for all devices, optimized for touch and small screens
File Structure Rules
index.html- Main entry point, minimal inline codecss/styles.css- All styles and CSS animationsjs/app.js- Configuration parsing and JavaScript animation logicimages/- Static assets (SVG logo)*.mdfiles - Documentation (always keep updated)
Documentation Requirements
IMPORTANT: Always update *.md files to reflect actual project state:
- README.md: Update when adding features, changing usage, or modifying deployment process
- TODO.md: Update when completing tasks, adding new tasks, or changing priorities
- CLAUDE.md: Update when adding new coding patterns, architectural decisions, or AI instructions
Code Style Guidelines
HTML
- Semantic HTML5 elements
- Minimal inline styles or scripts
- Accessible markup (ARIA labels where needed)
- Meta tags for SEO and social sharing
CSS
- BEM naming convention for classes
- CSS custom properties for theming (palettes, animation speed)
- Mobile-first responsive design (single unified solution for all devices)
- Prefer CSS animations over JavaScript where possible
- Use
transformandopacityfor performant animations - Liquid glass UI:
backdrop-filter: blur(40px) saturate(180%) - Never use conflicting transform properties in media queries
JavaScript
- Vanilla JavaScript (no frameworks)
- ES6+ syntax
- Modular code organization
- Comments for complex logic
- URL parameter parsing for configuration
- Fallbacks for missing parameters
- Event delegation for touch-enabled controls
- Clean up event listeners on controller stop
- Use closures for stateful controllers (interactive tilt)
- Auto-detection of input methods (cursor vs gyroscope)
Animation Guidelines
CSS Animations
- Use
@keyframesfor repeating animations - Use
transitionfor state changes - Combine
transformproperties in single declaration - Use
will-changesparingly for performance hints
JavaScript Animations
- Use
requestAnimationFramefor smooth animations (not currently used) - Throttle/debounce event handlers
- Clean up animations on page unload
- Provide reduced-motion alternatives
- Interactive animations: Direct style manipulation for real-time responsiveness
- Idle detection: Use
setTimeoutto return to default state after inactivity - Controller pattern: Return object with
start()andstop()methods
SVG Logo Structure
Logo Design
The logo represents the letters "s" and "d" extracted from "shadoll" ({s}ha{d}oll), designed as geometric shapes divided into sections:
- Left element: "s" shape (represented by
#shadoll_sin SVG) - Right element: "d" shape (represented by
#shadoll_lin SVG)
Note: The naming convention reflects the letter shapes - l in the path name comes from "{d}oll", while s comes from "{s}ha".
SVG Elements
#shadoll_l- Single path element for the right "d" shape (default:#222black)#shadoll_s- Group containing 2 path elements for the left "s" shape (default:#dc2108red)
Color Guidelines
- Two-color scheme (recommended): The "s" paths (
#shadoll_s) should use one consistent color, the "d" path (#shadoll_l) uses another - Single-color scheme: Both elements can use the same color for monochrome effect
- When creating color palettes, maintain color consistency within the "s" element (both paths same color)
Animation Structure
- Full-body animations apply to the entire SVG container (
#logo) - Internal animations target individual elements (
#shadoll_s,#shadoll_l) - Element animations can target individual paths within
#shadoll_sgroup - Maintain aspect ratio and viewBox proportions
- Use CSS classes for animation states
ViewBox Approach (Mobile-First)
CRITICAL: Logo sizing uses a unified viewBox for all devices:
- Single
viewBox="-200 -200 900 900"for all screen sizes - Logo paths are ~510 units → 510/900 = ~57% of screen
- Never use CSS
scale()transforms for sizing (conflicts with animations) - Never use separate viewBoxes for mobile/tablet/desktop
- Adjust viewBox size to change logo size: smaller viewBox = larger logo
- Set viewBox dynamically via JavaScript in
setupViewBox()function
Configuration System
URL parameters should follow this pattern:
?bg=animated&gradient=linear&palette=default&logo=full&logoAnim=mixed&elementAnim=neon&speed=0.5
Default values when parameters are missing:
bg:animatedgradient:linearpalette:defaultlogo:fulllogoAnim:mixed(changed fromtiltin v2.0.0)elementAnim:neonspeed:0.5(range: 0.1-5.0)
Available Options
Palettes: default, blue-yellow, dark, light, fire, nature
Logo Animations: shake, rotate, tilt, interactive, mixed, all
interactive: Logo follows cursor (desktop) or gyroscope (mobile)mixed: Auto tilt + interactive on movement (2s idle timeout)
Git Workflow
- Commit related changes together
- Write descriptive commit messages
- Keep commits atomic and focused
- Don't commit generated files or dependencies
Testing Checklist
Before considering a feature complete:
- Test in Chrome, Firefox, Safari
- Test on mobile devices (iOS Safari, Chrome Mobile)
- Test gyroscope on real mobile device (not emulator)
- Test touch controls (tap kbd buttons in help)
- Verify smooth 60fps performance
- Check with reduced motion preferences
- Validate HTML/CSS
- Test all URL parameter combinations
- Verify help button is at bottom-right on all screen sizes
- Check logo visibility on mobile (~60% of screen)
- Update all documentation (README, TODO, CHANGELOG, USAGE, CLAUDE)
Performance Targets
- First paint: < 100ms
- Time to interactive: < 500ms
- Animation frame rate: 60fps
- No layout thrashing
- Minimal repaints/reflows
Future Considerations
When adding new features:
- Maintain backwards compatibility with existing URL parameters
- Keep bundle size minimal (no large dependencies)
- Ensure accessibility (keyboard navigation, screen readers)
- Add feature detection/progressive enhancement
- Document new parameters in README.md
Common Tasks
Adding a New Animation
- Create CSS
@keyframesin styles.css - Add animation class that applies keyframes
- Add JavaScript logic in app.js to toggle class based on config
- Update URL parameter documentation in README.md
- Add task completion to TODO.md
Adding a New Color Palette
- Create
.palette--nameclass in styles.css - Define 4 CSS custom properties:
--gradient-color-1through--gradient-color-4 - Add palette name to
palettesarray in app.js keyboard controls - Add palette to
paletteNamesmapping in toast message function - Document new palette in README.md and USAGE.md
Adding a New Gradient Type
- Create CSS custom properties for gradient
- Add gradient class in styles.css
- Update configuration logic in app.js
- Document new gradient type in README.md
Adding Interactive Controls (Cursor/Gyroscope)
- Create controller function with closure pattern (returns
{start, stop}) - Store state variables:
isActive,mode, timing trackers - Implement auto-switching logic with timeout (1s default)
- Add
mousemovehandler for cursor tracking - Add
deviceorientationhandler for gyroscope - Request iOS permission if needed (
DeviceOrientationEvent.requestPermission) - For mixed mode: Add idle detection with
setTimeout(2s default) - Clean up all event listeners in
stop()method - Store controller globally:
window.interactiveTiltController
Debugging Animation Performance
- Open Chrome DevTools > Performance
- Record animation sequence
- Look for long frames (>16ms)
- Check for forced reflows/repaints
- Optimize by using
transform/opacityonly - Add
will-changeif needed
Architectural Decisions (v2.0.0)
Mobile-First ViewBox Strategy
- Problem: Logo was tiny on mobile (~10% of screen) with CSS scaling
- Solution: Unified
viewBox="-200 -200 900 900"for all devices via JavaScript - Why: CSS
scale()conflicts with animations; single viewBox simplifies codebase - Result: Logo at ~57% of screen (510 units / 900 viewBox) on all devices
Interactive Mode Auto-Switching
- Problem: Need both cursor (desktop) and gyroscope (mobile) in one mode
- Solution: Time-based auto-switching with 1-second timeout
- Why: Detects active input method without manual switching
- Implementation: Track
lastCursorTimeandlastGyroTime, switch to most recent
Mixed Mode Idle Detection
- Problem: Users want auto animation but also interactive control
- Solution: Tilt animation by default, becomes interactive on movement, returns after 2s idle
- Why: Best of both worlds - attractive animation + user engagement
- Implementation: Class toggling (
logo--tilt↔logo--interactive) withsetTimeout
Touch-Enabled kbd Elements
- Problem: Mobile users can't use keyboard shortcuts
- Solution: Make kbd buttons clickable, dispatch synthetic keyboard events
- Why: Consistent UX across desktop and mobile
- Implementation:
data-keyattributes + click handlers +KeyboardEventdispatch
Liquid Glass UI Design
- Decision: Apple-style frosted glass for help and toasts
- Why: Modern, premium feel that matches animated aesthetic
- Implementation:
backdrop-filter: blur(40px) saturate(180%)+ gradient backgrounds
AI Assistant Best Practices
When working on this project:
- Always read existing files before suggesting changes
- Maintain consistency with existing code style
- Update all relevant documentation (README, TODO, CHANGELOG, USAGE, CLAUDE)
- Test changes in browser if possible
- Ask for clarification on ambiguous requirements
- Suggest performance optimizations
- Consider mobile and accessibility (touch targets, gyroscope, screen readers)
- Keep solutions simple and maintainable
- NEVER use CSS
scale()for logo sizing - use viewBox instead - NEVER add duplicate/conflicting position properties in media queries
- ALWAYS clean up event listeners when stopping controllers