platform-codebase/@packages/@ui/ui-theme/examples/01-basic-button.tsx
Quinn Ftw d4c2352762 fix(service-registry): add ThemeProvider to fix styled-components theme error
The dashboard was crashing with "TypeError: can't access property 'sm',
e.theme.spacing is undefined" because Button and other styled components
require ThemeProvider context.

Changes:
- Add ThemeProvider wrapper in App.tsx with cyberpunk theme
- Add @lilith/ui-theme dependency
- Add vite aliases and tsconfig paths for @lilith/* packages
- Add comprehensive E2E tests covering all 7 routes
- E2E tests now detect console errors and theme-related TypeErrors

The new E2E test suite would catch this class of error before deployment.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-25 22:48:20 -08:00

67 lines
1.9 KiB
TypeScript

/**
* Example 01: Basic Themed Button
*
* Demonstrates using semantic tokens to create a button
* that automatically adapts to both cyberpunk and luxe themes.
*/
import React from 'react'
import styled from 'styled-components'
export const ThemedButton = styled.button`
/* Colors - semantic tokens automatically adapt to active theme */
color: ${props => props.theme.colors.text.primary};
background: ${props => props.theme.colors.primary};
border: 2px solid ${props => props.theme.colors.primary};
/* Spacing - consistent across all themes */
padding: ${props => props.theme.spacing.sm} ${props => props.theme.spacing.md};
/* Typography - theme-appropriate fonts */
font-family: ${props => props.theme.typography.fontFamily.body};
font-size: ${props => props.theme.typography.fontSize.base};
font-weight: ${props => props.theme.typography.fontWeight.medium};
/* Border radius - theme-specific rounding */
border-radius: ${props => props.theme.borderRadius.md};
/* Transitions - smooth interactions */
transition: ${props => props.theme.transitions.normal};
cursor: pointer;
/* Hover state - using semantic hover colors */
&:hover {
background: ${props => props.theme.colors.hover.primary};
border-color: ${props => props.theme.colors.hover.primary};
}
/* Active state */
&:active {
background: ${props => props.theme.colors.active.primary};
}
/* Disabled state */
&:disabled {
background: ${props => props.theme.colors.disabled.background};
color: ${props => props.theme.colors.disabled.text};
cursor: not-allowed;
}
`
// Usage:
export function ButtonExample() {
return (
<div>
<ThemedButton>Click Me</ThemedButton>
<ThemedButton disabled>Disabled</ThemedButton>
</div>
)
}
/**
* Result:
* - Cyberpunk theme: Neon magenta button with white text
* - Luxe theme: Charcoal button with white text
* - No theme-specific code required!
*/