@sublimee/surfaces 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,108 @@
1
+ import * as React from 'react';
2
+
3
+ /** Available surface elevation variants */
4
+ export type SurfaceVariant = 'base' | 'elevated' | 'higher' | 'inset' | 'extruded' | 'glass';
5
+
6
+ /** Available padding sizes */
7
+ export type SurfacePadding = 'none' | 'sm' | 'md' | 'lg' | 'xl';
8
+
9
+ /** Available border radius sizes */
10
+ export type SurfaceRadius = 'none' | 'sm' | 'md' | 'lg' | 'xl' | 'full';
11
+
12
+ /** Valid HTML element names for polymorphic rendering */
13
+ export type SurfaceElement = 'div' | 'article' | 'section' | 'aside' | 'main' | 'header' | 'footer' | 'nav';
14
+
15
+ /** Props for the Surface component */
16
+ export interface SurfaceProps extends React.HTMLAttributes<HTMLDivElement> {
17
+ /** Visual elevation variant. @default 'elevated' */
18
+ variant?: SurfaceVariant;
19
+ /** Internal padding. @default 'md' */
20
+ padding?: SurfacePadding;
21
+ /** Border radius. @default 'lg' */
22
+ radius?: SurfaceRadius;
23
+ /** Show border. @default false */
24
+ border?: boolean;
25
+ /** Enable interactive hover shadow lift. @default true */
26
+ interactive?: boolean;
27
+ /** HTML element to render. @default 'div' */
28
+ as?: SurfaceElement;
29
+ /** Child elements */
30
+ children?: React.ReactNode;
31
+ }
32
+
33
+ /** Maps padding sizes to CSS custom properties */
34
+ const paddingMap: Record<SurfacePadding, string> = {
35
+ none: '0',
36
+ sm: 'var(--sublime-space-3)', // 12px
37
+ md: 'var(--sublime-space-card-padding)', // 24px (space-6)
38
+ lg: 'var(--sublime-space-8)', // 32px
39
+ xl: 'var(--sublime-space-10)', // 40px
40
+ };
41
+
42
+ /** Maps radius sizes to CSS custom properties */
43
+ const radiusMap: Record<SurfaceRadius, string> = {
44
+ none: 'var(--sublime-radius-none)',
45
+ sm: 'var(--sublime-radius-sm)',
46
+ md: 'var(--sublime-radius-md)',
47
+ lg: 'var(--sublime-radius-lg)',
48
+ xl: 'var(--sublime-radius-xl)',
49
+ full: 'var(--sublime-radius-full)',
50
+ };
51
+
52
+ /**
53
+ * Surface component - A semantic container that wraps content with
54
+ * elevation, padding, and visual boundaries.
55
+ *
56
+ * @example
57
+ * ```tsx
58
+ * <Surface variant="elevated" padding="lg">
59
+ * <h2>Card Title</h2>
60
+ * <p>Card content</p>
61
+ * </Surface>
62
+ * ```
63
+ */
64
+ export const Surface = React.forwardRef<HTMLDivElement, SurfaceProps>((props, ref) => {
65
+ const {
66
+ variant = 'elevated',
67
+ padding = 'md',
68
+ radius = 'lg',
69
+ border = false,
70
+ interactive = true,
71
+ as: Component = 'div',
72
+ children,
73
+ className = '',
74
+ style,
75
+ ...rest
76
+ } = props;
77
+
78
+ // Build CSS classes
79
+ const classes = [
80
+ 'sublime-surface',
81
+ `sublime-surface--${variant}`,
82
+ interactive ? 'sublime-surface--interactive' : '',
83
+ border ? 'sublime-surface--border' : '',
84
+ className,
85
+ ]
86
+ .filter(Boolean)
87
+ .join(' ');
88
+
89
+ // Build inline styles
90
+ const inlineStyles: React.CSSProperties = {
91
+ padding: paddingMap[padding],
92
+ borderRadius: radiusMap[radius],
93
+ ...style,
94
+ };
95
+
96
+ return React.createElement(
97
+ Component,
98
+ {
99
+ ref,
100
+ className: classes,
101
+ style: inlineStyles,
102
+ ...rest,
103
+ },
104
+ children
105
+ );
106
+ });
107
+
108
+ Surface.displayName = 'Surface';