diff --git a/examples/button.tsx b/examples/button.tsx index a72479e..f664fa9 100644 --- a/examples/button.tsx +++ b/examples/button.tsx @@ -23,12 +23,12 @@ const Button = define('Button', { states: { ":not(:disabled):hover": { - transform: 'translateY(-2px) !important', + transform: 'translateY(-2px)', filter: 'brightness(1.05)' }, ":not(:disabled):active": { - transform: 'translateY(1px) !important', - boxShadow: '0 2px 3px rgba(0, 0, 0, 0.2) !important' + transform: 'translateY(1px)', + boxShadow: '0 2px 3px rgba(0, 0, 0, 0.2)' }, }, diff --git a/examples/form.tsx b/examples/form.tsx new file mode 100644 index 0000000..e5c0370 --- /dev/null +++ b/examples/form.tsx @@ -0,0 +1,199 @@ +import { define } from '../src' +import { ExampleSection } from './ssr/helpers' + +const Input = define('Input', { + base: 'input', + + padding: '12px 16px', + fontSize: 16, + border: '2px solid #e5e7eb', + borderRadius: 8, + background: 'white', + color: '#111827', + transition: 'all 0.2s ease', + width: '100%', + boxSizing: 'border-box', + + states: { + ':focus': { + outline: 'none', + borderColor: '#3b82f6', + boxShadow: '0 0 0 3px rgba(59, 130, 246, 0.1)' + }, + ':disabled': { + background: '#f3f4f6', + color: '#9ca3af', + cursor: 'not-allowed' + } + }, + + variants: { + status: { + error: { + borderColor: '#ef4444', + states: { + ':focus': { + borderColor: '#ef4444', + boxShadow: '0 0 0 3px rgba(239, 68, 68, 0.1)' + } + } + }, + success: { + borderColor: '#10b981', + states: { + ':focus': { + borderColor: '#10b981', + boxShadow: '0 0 0 3px rgba(16, 185, 129, 0.1)' + } + } + } + } + } +}) + +const Textarea = define('Textarea', { + base: 'textarea', + + padding: '12px 16px', + fontSize: 16, + border: '2px solid #e5e7eb', + borderRadius: 8, + background: 'white', + color: '#111827', + transition: 'all 0.2s ease', + width: '100%', + minHeight: 120, + boxSizing: 'border-box', + fontFamily: 'inherit', + resize: 'vertical', + + states: { + ':focus': { + outline: 'none', + borderColor: '#3b82f6', + boxShadow: '0 0 0 3px rgba(59, 130, 246, 0.1)' + } + } +}) + +const FormGroup = define('FormGroup', { + marginBottom: 24, + + parts: { + Label: { + base: 'label', + display: 'block', + fontSize: 14, + fontWeight: 600, + color: '#374151', + marginBottom: 8 + }, + Helper: { + fontSize: 13, + color: '#6b7280', + marginTop: 6 + }, + Error: { + fontSize: 13, + color: '#ef4444', + marginTop: 6 + } + }, + + render({ props, parts: { Root, Label, Helper, Error } }) { + return ( + + {props.label && } + {props.children} + {props.helper && {props.helper}} + {props.error && {props.error}} + + ) + } +}) + +const Checkbox = define('Checkbox', { + parts: { + Input: { + base: 'input[type=checkbox]', + width: 20, + height: 20, + cursor: 'pointer' + }, + Label: { + base: 'label', + display: 'flex', + alignItems: 'center', + gap: 12, + cursor: 'pointer', + fontSize: 16, + color: '#374151', + + states: { + ':hover': { + color: '#111827' + } + }, + + selectors: { + '@Input:disabled + &': { + cursor: 'not-allowed', + color: '#9ca3af' + } + } + } + }, + + render({ props, parts: { Root, Input, Label } }) { + return ( + + + + ) + } +}) + +export const FormExamplesContent = () => ( + <> + + + + + + + + + + + + + + + + + + + + + + + + + + +