tinky-status-message 0.1.0

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.
package/README.md ADDED
@@ -0,0 +1,118 @@
1
+ # tinky-status-message
2
+
3
+ A React status message component for CLI applications, built on the Tinky framework.
4
+
5
+ ## Features
6
+
7
+ - Four status variants: info, success, warning, error
8
+ - Icon-based visual indicators
9
+ - Customizable colors and styles
10
+ - Theme support via tinky-theme
11
+ - Full TypeScript support
12
+
13
+ ## Installation
14
+
15
+ ```bash
16
+ bun add tinky-status-message
17
+ ```
18
+
19
+ ## Usage
20
+
21
+ ```tsx
22
+ import { StatusMessage } from "tinky-status-message";
23
+ import { render } from "tinky";
24
+
25
+ render(
26
+ <>
27
+ <StatusMessage variant="success">
28
+ Operation completed successfully
29
+ </StatusMessage>
30
+ <StatusMessage variant="error">An error occurred</StatusMessage>
31
+ <StatusMessage variant="warning">This is a warning</StatusMessage>
32
+ <StatusMessage variant="info">Additional information</StatusMessage>
33
+ </>,
34
+ );
35
+ ```
36
+
37
+ ## API
38
+
39
+ ### StatusMessage
40
+
41
+ The main status message component.
42
+
43
+ #### Props
44
+
45
+ | Prop | Type | Required | Description |
46
+ | ---------- | --------------------------------------------- | -------- | ------------------------------------------------- |
47
+ | `children` | `ReactNode` | Yes | The message content to display |
48
+ | `variant` | `'info' \| 'success' \| 'error' \| 'warning'` | Yes | The status variant that determines color and icon |
49
+
50
+ #### Examples
51
+
52
+ ```tsx
53
+ // Success message
54
+ <StatusMessage variant="success">File saved successfully</StatusMessage>
55
+
56
+ // Error message
57
+ <StatusMessage variant="error">Failed to connect to server</StatusMessage>
58
+
59
+ // Warning message
60
+ <StatusMessage variant="warning">This action cannot be undone</StatusMessage>
61
+
62
+ // Info message
63
+ <StatusMessage variant="info">Your changes have been queued</StatusMessage>
64
+ ```
65
+
66
+ ## Theme Integration
67
+
68
+ `StatusMessage` integrates with `tinky-theme` for styling:
69
+
70
+ ```tsx
71
+ import { extendTheme } from "tinky-theme";
72
+
73
+ const theme = extendTheme(defaultTheme, {
74
+ components: {
75
+ StatusMessage: {
76
+ config: (props) => ({
77
+ icon: customIconMap[props.variant],
78
+ }),
79
+ styles: {
80
+ container: () => ({
81
+ columnGap: 2, // Increase spacing
82
+ }),
83
+ },
84
+ },
85
+ },
86
+ });
87
+ ```
88
+
89
+ ## Styling
90
+
91
+ Each variant uses a predefined color:
92
+
93
+ - `success` - Green (✓)
94
+ - `error` - Red (✗)
95
+ - `warning` - Yellow (⚠)
96
+ - `info` - Blue (ℹ)
97
+
98
+ You can customize these through the theme system.
99
+
100
+ ### Development
101
+
102
+ ```bash
103
+ # Install dependencies
104
+ bun install
105
+
106
+ # Run tests
107
+ bun test
108
+
109
+ # Run linter
110
+ bun run lint
111
+
112
+ # Build the project
113
+ bun run build
114
+ ```
115
+
116
+ ## License
117
+
118
+ MIT
@@ -0,0 +1,195 @@
1
+ /**
2
+ * StatusMessage component implementation for terminal UI applications.
3
+ *
4
+ * This module provides the StatusMessage component, a message display component for
5
+ * showing notifications, warnings, errors, and information in terminal interfaces.
6
+ * The component supports four variants with semantic colors and icons.
7
+ *
8
+ * Key features:
9
+ * - Four semantic variants: info, success, error, warning
10
+ * - Automatic color mapping for each variant
11
+ * - Variant-specific icons with Unicode/fallback detection
12
+ * - Integration with tinky-theme for consistent styling
13
+ * - Flexible content support via ReactNode
14
+ *
15
+ * Variant characteristics:
16
+ * - info: Blue color with ℹ️ icon (fallback: ℹ) for general information
17
+ * - success: Green color with ✅ icon (fallback: √) for successful operations
18
+ * - error: Red color with ❌ icon (fallback: ×) for error notifications
19
+ * - warning: Yellow color with ⚠️ icon (fallback: ‼) for cautionary messages
20
+ *
21
+ * The component uses the tinky-theme system to resolve styling and
22
+ * configuration, allowing for easy customization through theme extension.
23
+ *
24
+ * @example
25
+ * Basic usage:
26
+ * ```tsx
27
+ * import { StatusMessage } from "tinky-status-message";
28
+ *
29
+ * <StatusMessage variant="info">
30
+ * This is an informational message
31
+ * </StatusMessage>
32
+ * ```
33
+ *
34
+ * @example
35
+ * Success message:
36
+ * ```tsx
37
+ * import { StatusMessage } from "tinky-status-message";
38
+ *
39
+ * <StatusMessage variant="success">
40
+ * Your operation completed successfully
41
+ * </StatusMessage>
42
+ * ```
43
+ *
44
+ * @example
45
+ * Error message:
46
+ * ```tsx
47
+ * import { StatusMessage } from "tinky-status-message";
48
+ *
49
+ * <StatusMessage variant="error">
50
+ * Failed to connect to the server
51
+ * </StatusMessage>
52
+ * ```
53
+ *
54
+ * @example
55
+ * Warning message:
56
+ * ```tsx
57
+ * import { StatusMessage } from "tinky-status-message";
58
+ *
59
+ * <StatusMessage variant="warning">
60
+ * Your session will expire in 5 minutes
61
+ * </StatusMessage>
62
+ * ```
63
+ *
64
+ * @see {@link StatusMessageProps}
65
+ * @see {@link statusMessageTheme}
66
+ */
67
+ import { type JSX, type ReactNode } from "react";
68
+ import { type StatusMessageVariant } from "../types/status-message-types.js";
69
+ /**
70
+ * Props for the StatusMessage component.
71
+ *
72
+ * @interface StatusMessageProps
73
+ *
74
+ * @property {ReactNode} children - The message content to display within the status message.
75
+ * This is the main body of the status message and can include text or any valid ReactNode.
76
+ * The message is rendered in normal text style for readability.
77
+ * Must be a valid ReactNode (components, elements, strings, numbers, etc.).
78
+ *
79
+ * @property {"info" | "success" | "error" | "warning"} variant - The status variant
80
+ * determines the visual appearance including icon color and semantic meaning.
81
+ *
82
+ * Variant options and their meanings:
83
+ * - `info`: General information or neutral messages (blue color, ℹ️ icon / ℹ fallback)
84
+ * - `success`: Successful operations or confirmations (green color, ✅ icon / √ fallback)
85
+ * - `error`: Error messages or failure notifications (red color, ❌ icon / × fallback)
86
+ * - `warning`: Warning messages or cautionary notes (yellow color, ⚠️ icon / ‼ fallback)
87
+ *
88
+ * Each variant has associated:
89
+ * - Icon color for visual emphasis
90
+ * - Icon character displayed alongside the message
91
+ * - Semantic meaning for accessibility and understanding
92
+ *
93
+ * @example
94
+ * Info status message:
95
+ * ```tsx
96
+ * const infoMessage: StatusMessageProps = {
97
+ * variant: "info",
98
+ * children: "Your request was received successfully"
99
+ * };
100
+ * ```
101
+ *
102
+ * @example
103
+ * Success status message:
104
+ * ```tsx
105
+ * const successMessage: StatusMessageProps = {
106
+ * variant: "success",
107
+ * children: "All systems operational"
108
+ * };
109
+ * ```
110
+ */
111
+ export interface StatusMessageProps {
112
+ /**
113
+ * The message content to display within the status message.
114
+ * This is the main body of the status message and can include text or any valid ReactNode.
115
+ */
116
+ readonly children: ReactNode;
117
+ /**
118
+ * The status variant that determines the visual appearance including icon color,
119
+ * and semantic meaning.
120
+ */
121
+ readonly variant: StatusMessageVariant;
122
+ }
123
+ /**
124
+ * StatusMessage component for displaying messages in terminal UIs.
125
+ *
126
+ * @param {StatusMessageProps} props - Component props
127
+ * @param {ReactNode} props.children - Message content to display
128
+ * @param {"info" | "success" | "error" | "warning"} props.variant - Status variant for styling
129
+ *
130
+ * @returns {JSX.Element} The rendered status message component
131
+ *
132
+ * This is the main status message component that renders stylized message boxes with
133
+ * variant-specific colors and icons for terminal applications.
134
+ *
135
+ * Component structure:
136
+ * ```
137
+ * ┌─────────────────────┐
138
+ * │ [icon] Message │ <- icon container + message text
139
+ * └─────────────────────┘
140
+ * ```
141
+ *
142
+ * Rendering behavior:
143
+ * 1. Reads theme configuration for the StatusMessage component
144
+ * 2. Resolves variant-specific styles from theme
145
+ * 3. Detects Unicode support in the terminal environment
146
+ * 4. Displays icon on the left side (non-shrinking)
147
+ * - Uses Unicode emoji if terminal supports it
148
+ * - Falls back to ASCII character for unsupported terminals
149
+ * 5. Displays content on the right side
150
+ *
151
+ * Theme integration:
152
+ * - Uses `useComponentTheme` hook to resolve styles
153
+ * - Styles come from `statusMessageTheme.styles.*` functions
154
+ * - Styles are applied to Box and Text components from tinky
155
+ *
156
+ * Flex layout behavior:
157
+ * - Icon maintains fixed size (flexShrink: 0)
158
+ * - Message can expand/shrink as needed
159
+ *
160
+ * @example
161
+ * Simple info message:
162
+ * ```tsx
163
+ * <StatusMessage variant="info">
164
+ * System maintenance scheduled for tonight
165
+ * </StatusMessage>
166
+ * ```
167
+ *
168
+ * @example
169
+ * Success message:
170
+ * ```tsx
171
+ * <StatusMessage variant="success">
172
+ * Your changes have been saved
173
+ * </StatusMessage>
174
+ * ```
175
+ *
176
+ * @example
177
+ * Error message:
178
+ * ```tsx
179
+ * <StatusMessage variant="error">
180
+ * Unable to reach the server. Please try again later.
181
+ * </StatusMessage>
182
+ * ```
183
+ *
184
+ * @example
185
+ * Warning message:
186
+ * ```tsx
187
+ * <StatusMessage variant="warning">
188
+ * You are using 90% of your available storage
189
+ * </StatusMessage>
190
+ * ```
191
+ *
192
+ * @see {@link StatusMessageProps}
193
+ * @see {@link statusMessageTheme}
194
+ */
195
+ export declare function StatusMessage({ children, variant, }: StatusMessageProps): JSX.Element;
@@ -0,0 +1,92 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Box, Text, useApp } from "tinky";
3
+ import { useComponentTheme } from "tinky-theme";
4
+ import { isUnicodeSupported } from "../utils/unicode.js";
5
+ import statusMessageTheme from "../themes/status-message-theme.js";
6
+ /**
7
+ * StatusMessage component for displaying messages in terminal UIs.
8
+ *
9
+ * @param {StatusMessageProps} props - Component props
10
+ * @param {ReactNode} props.children - Message content to display
11
+ * @param {"info" | "success" | "error" | "warning"} props.variant - Status variant for styling
12
+ *
13
+ * @returns {JSX.Element} The rendered status message component
14
+ *
15
+ * This is the main status message component that renders stylized message boxes with
16
+ * variant-specific colors and icons for terminal applications.
17
+ *
18
+ * Component structure:
19
+ * ```
20
+ * ┌─────────────────────┐
21
+ * │ [icon] Message │ <- icon container + message text
22
+ * └─────────────────────┘
23
+ * ```
24
+ *
25
+ * Rendering behavior:
26
+ * 1. Reads theme configuration for the StatusMessage component
27
+ * 2. Resolves variant-specific styles from theme
28
+ * 3. Detects Unicode support in the terminal environment
29
+ * 4. Displays icon on the left side (non-shrinking)
30
+ * - Uses Unicode emoji if terminal supports it
31
+ * - Falls back to ASCII character for unsupported terminals
32
+ * 5. Displays content on the right side
33
+ *
34
+ * Theme integration:
35
+ * - Uses `useComponentTheme` hook to resolve styles
36
+ * - Styles come from `statusMessageTheme.styles.*` functions
37
+ * - Styles are applied to Box and Text components from tinky
38
+ *
39
+ * Flex layout behavior:
40
+ * - Icon maintains fixed size (flexShrink: 0)
41
+ * - Message can expand/shrink as needed
42
+ *
43
+ * @example
44
+ * Simple info message:
45
+ * ```tsx
46
+ * <StatusMessage variant="info">
47
+ * System maintenance scheduled for tonight
48
+ * </StatusMessage>
49
+ * ```
50
+ *
51
+ * @example
52
+ * Success message:
53
+ * ```tsx
54
+ * <StatusMessage variant="success">
55
+ * Your changes have been saved
56
+ * </StatusMessage>
57
+ * ```
58
+ *
59
+ * @example
60
+ * Error message:
61
+ * ```tsx
62
+ * <StatusMessage variant="error">
63
+ * Unable to reach the server. Please try again later.
64
+ * </StatusMessage>
65
+ * ```
66
+ *
67
+ * @example
68
+ * Warning message:
69
+ * ```tsx
70
+ * <StatusMessage variant="warning">
71
+ * You are using 90% of your available storage
72
+ * </StatusMessage>
73
+ * ```
74
+ *
75
+ * @see {@link StatusMessageProps}
76
+ * @see {@link statusMessageTheme}
77
+ */
78
+ export function StatusMessage({ children, variant, }) {
79
+ const { styles } = useComponentTheme("StatusMessage", statusMessageTheme, { variant });
80
+ const { env } = useApp();
81
+ const supportsUnicode = isUnicodeSupported(env ?? {});
82
+ const iconMap = {
83
+ info: { unicode: "ℹ️", fallback: "ℹ" },
84
+ success: { unicode: "✅", fallback: "√" },
85
+ error: { unicode: "❌", fallback: "×" },
86
+ warning: { unicode: "⚠️", fallback: "‼" },
87
+ };
88
+ const icon = supportsUnicode
89
+ ? iconMap[variant].unicode
90
+ : iconMap[variant].fallback;
91
+ return (_jsxs(Box, { ...styles.container, children: [_jsx(Box, { ...styles.iconContainer, children: _jsx(Text, { ...styles.icon, children: icon }) }), _jsx(Text, { ...styles.message, children: children })] }));
92
+ }
package/lib/index.d.ts ADDED
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Main entry point for tinky-status-message package.
3
+ *
4
+ * This module provides the public API for the tinky-status-message package,
5
+ * exporting the StatusMessage component and its associated theme configuration.
6
+ *
7
+ * The package exports:
8
+ * - `StatusMessage` - Main status message component for displaying messages in terminal UIs
9
+ * - `StatusMessageProps` - TypeScript interface for StatusMessage component props
10
+ * - `statusMessageTheme` - Default theme configuration for StatusMessage components
11
+ * - `StatusMessageTheme` - TypeScript type for the StatusMessage theme
12
+ * - `StatusMessageThemeProps` - TypeScript interface for StatusMessage theme functions
13
+ * - `isUnicodeSupported` - Utility function for detecting Unicode support in terminals
14
+ *
15
+ * @example
16
+ * Basic usage:
17
+ * ```tsx
18
+ * import { StatusMessage } from "tinky-status-message";
19
+ *
20
+ * <StatusMessage variant="success">
21
+ * Operation completed successfully
22
+ * </StatusMessage>
23
+ * ```
24
+ *
25
+ * @example
26
+ * With theme provider:
27
+ * ```tsx
28
+ * import { StatusMessage, statusMessageTheme } from "tinky-status-message";
29
+ * import { ThemeProvider } from "tinky-theme";
30
+ *
31
+ * <ThemeProvider theme={{ components: { StatusMessage: statusMessageTheme } }}>
32
+ * <StatusMessage variant="info">
33
+ * Important information message
34
+ * </StatusMessage>
35
+ * </ThemeProvider>
36
+ * ```
37
+ *
38
+ * @see {@link StatusMessage}
39
+ * @see {@link statusMessageTheme}
40
+ */
41
+ export { StatusMessage, type StatusMessageProps, } from "./components/StatusMessage.js";
42
+ export { default as statusMessageTheme, type StatusMessageTheme, type StatusMessageThemeProps, } from "./themes/status-message-theme.js";
43
+ export { type StatusMessageVariant } from "./types/status-message-types.js";
44
+ export { isUnicodeSupported } from "./utils/unicode.js";
package/lib/index.js ADDED
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Main entry point for tinky-status-message package.
3
+ *
4
+ * This module provides the public API for the tinky-status-message package,
5
+ * exporting the StatusMessage component and its associated theme configuration.
6
+ *
7
+ * The package exports:
8
+ * - `StatusMessage` - Main status message component for displaying messages in terminal UIs
9
+ * - `StatusMessageProps` - TypeScript interface for StatusMessage component props
10
+ * - `statusMessageTheme` - Default theme configuration for StatusMessage components
11
+ * - `StatusMessageTheme` - TypeScript type for the StatusMessage theme
12
+ * - `StatusMessageThemeProps` - TypeScript interface for StatusMessage theme functions
13
+ * - `isUnicodeSupported` - Utility function for detecting Unicode support in terminals
14
+ *
15
+ * @example
16
+ * Basic usage:
17
+ * ```tsx
18
+ * import { StatusMessage } from "tinky-status-message";
19
+ *
20
+ * <StatusMessage variant="success">
21
+ * Operation completed successfully
22
+ * </StatusMessage>
23
+ * ```
24
+ *
25
+ * @example
26
+ * With theme provider:
27
+ * ```tsx
28
+ * import { StatusMessage, statusMessageTheme } from "tinky-status-message";
29
+ * import { ThemeProvider } from "tinky-theme";
30
+ *
31
+ * <ThemeProvider theme={{ components: { StatusMessage: statusMessageTheme } }}>
32
+ * <StatusMessage variant="info">
33
+ * Important information message
34
+ * </StatusMessage>
35
+ * </ThemeProvider>
36
+ * ```
37
+ *
38
+ * @see {@link StatusMessage}
39
+ * @see {@link statusMessageTheme}
40
+ */
41
+ export { StatusMessage, } from "./components/StatusMessage.js";
42
+ export { default as statusMessageTheme, } from "./themes/status-message-theme.js";
43
+ export { isUnicodeSupported } from "./utils/unicode.js";
@@ -0,0 +1,280 @@
1
+ /**
2
+ * Theme configuration and styling for StatusMessage components.
3
+ *
4
+ * This module provides the default theme configuration for StatusMessage components,
5
+ * including variant-specific colors and styling functions.
6
+ *
7
+ * The theme system supports:
8
+ * - Four status message variants: info, success, error, warning
9
+ * - Automatic color mapping for each variant
10
+ * - Variant-specific styling
11
+ * - Consistent styling across all status message elements
12
+ * - Integration with the tinky-theme system
13
+ *
14
+ * Variant configurations:
15
+ * - info: Blue color with ℹ️ icon (fallback: ℹ)
16
+ * - success: Green color with ✅ icon (fallback: √)
17
+ * - error: Red color with ❌ icon (fallback: ×)
18
+ * - warning: Yellow color with ⚠️ icon (fallback: ‼)
19
+ *
20
+ * The module exports:
21
+ * 1. `statusMessageTheme` - Complete theme with styles
22
+ * 2. `StatusMessageTheme` - Type definition of the theme
23
+ * 3. `StatusMessageThemeProps` - Props interface for theme functions
24
+ *
25
+ * @example
26
+ * Using the default theme:
27
+ * ```tsx
28
+ * import { StatusMessage, statusMessageTheme } from "tinky-status-message";
29
+ * import { ThemeProvider } from "tinky-theme";
30
+ *
31
+ * <ThemeProvider theme={{ components: { StatusMessage: statusMessageTheme } }}>
32
+ * <StatusMessage variant="info">
33
+ * Information message
34
+ * </StatusMessage>
35
+ * </ThemeProvider>
36
+ * ```
37
+ *
38
+ * @example
39
+ * Customizing via theme extension:
40
+ * ```tsx
41
+ * import { extendTheme } from "tinky-theme";
42
+ * import { statusMessageTheme } from "tinky-status-message";
43
+ *
44
+ * const customTheme = extendTheme(defaultTheme, {
45
+ * components: {
46
+ * StatusMessage: {
47
+ * styles: {
48
+ * container: () => ({
49
+ * columnGap: 2
50
+ * })
51
+ * }
52
+ * }
53
+ * }
54
+ * });
55
+ * ```
56
+ *
57
+ * @see {@link StatusMessageTheme}
58
+ * @see {@link StatusMessage}
59
+ */
60
+ import { type BoxProps, type TextProps } from "tinky";
61
+ import { type StatusMessageVariant } from "../types/status-message-types.js";
62
+ /**
63
+ * Props interface for StatusMessage theme functions.
64
+ *
65
+ * @interface StatusMessageThemeProps
66
+ *
67
+ * @property {StatusMessageVariant} variant - The status message variant
68
+ * determines the color scheme. Each variant has specific semantic meaning:
69
+ * - info: General information or neutral messages
70
+ * - success: Successful operations or confirmations
71
+ * - error: Error messages or failure notifications
72
+ * - warning: Warning messages or cautionary notes
73
+ *
74
+ * Variant visual characteristics:
75
+ * - info: Blue color with ℹ️ icon (fallback: ℹ)
76
+ * - success: Green color with ✅ icon (fallback: √)
77
+ * - error: Red color with ❌ icon (fallback: ×)
78
+ * - warning: Yellow color with ⚠️ icon (fallback: ‼)
79
+ *
80
+ * @example
81
+ * ```typescript
82
+ * const infoProps: StatusMessageThemeProps = { variant: "info" };
83
+ * const successProps: StatusMessageThemeProps = { variant: "success" };
84
+ * const errorProps: StatusMessageThemeProps = { variant: "error" };
85
+ * const warningProps: StatusMessageThemeProps = { variant: "warning" };
86
+ * ```
87
+ */
88
+ export interface StatusMessageThemeProps {
89
+ variant: StatusMessageVariant;
90
+ }
91
+ /**
92
+ * Default theme configuration for StatusMessage components.
93
+ *
94
+ * This theme provides all necessary style functions for rendering
95
+ * StatusMessage components in terminal UIs. It follows the tinky-theme
96
+ * ComponentTheme interface for seamless integration with the theme system.
97
+ *
98
+ * Theme structure:
99
+ * - `styles` - Style functions for each component element
100
+ *
101
+ * Style functions:
102
+ * Each style function returns props for the corresponding component:
103
+ * - `styles.container(props)` - BoxProps for the status message container
104
+ * - `styles.iconContainer()` - BoxProps for the icon wrapper
105
+ * - `styles.icon(props)` - TextProps for the icon character
106
+ * - `styles.message()` - TextProps for the message text
107
+ *
108
+ * @example
109
+ * Using the theme directly:
110
+ * ```tsx
111
+ * import { statusMessageTheme } from "tinky-status-message";
112
+ *
113
+ * const { styles } = statusMessageTheme;
114
+ * const containerProps = styles.container({ variant: "success" });
115
+ * // containerProps === { columnGap: 1 }
116
+ *
117
+ * <Box {...containerProps}>
118
+ * Status message content
119
+ * </Box>
120
+ * ```
121
+ *
122
+ * @example
123
+ * Integrating with theme provider:
124
+ * ```tsx
125
+ * import { ThemeProvider } from "tinky-theme";
126
+ * import { statusMessageTheme } from "tinky-status-message";
127
+ *
128
+ * <ThemeProvider theme={{
129
+ * components: {
130
+ * StatusMessage: statusMessageTheme
131
+ * }
132
+ * }}>
133
+ * <StatusMessage variant="info">Info message</StatusMessage>
134
+ * </ThemeProvider>
135
+ * ```
136
+ *
137
+ * @see {@link StatusMessageTheme}
138
+ * @see {@link StatusMessageProps}
139
+ */
140
+ declare const statusMessageTheme: {
141
+ styles: {
142
+ /**
143
+ * Style function for the status message container.
144
+ *
145
+ * @returns {BoxProps} Props for rendering the status message container
146
+ *
147
+ * The container provides the main visual structure of the status message with:
148
+ * - Horizontal layout (default flex direction)
149
+ * - Spacing between icon and message
150
+ * - Flexible sizing for responsive behavior
151
+ *
152
+ * Applied styles:
153
+ * - `columnGap: 1` - Horizontal spacing between icon and message
154
+ *
155
+ * @example
156
+ * ```typescript
157
+ * import { statusMessageTheme } from "tinky-status-message";
158
+ *
159
+ * const containerStyles = statusMessageTheme.styles.container();
160
+ * // Returns: { columnGap: 1 }
161
+ * ```
162
+ */
163
+ container: () => BoxProps;
164
+ /**
165
+ * Style function for the icon container.
166
+ *
167
+ * @returns {BoxProps} Props for rendering the icon container
168
+ *
169
+ * The icon container wraps the icon character and ensures it maintains
170
+ * its size regardless of content layout.
171
+ *
172
+ * Applied styles:
173
+ * - `flexShrink: 0` - Prevents icon from shrinking
174
+ *
175
+ * This ensures the icon always displays at its full size, even when
176
+ * the message area needs to shrink to fit constraints.
177
+ *
178
+ * @example
179
+ * ```typescript
180
+ * import { statusMessageTheme } from "tinky-status-message";
181
+ *
182
+ * const iconContainerStyles = statusMessageTheme.styles.iconContainer();
183
+ * // Returns: { flexShrink: 0 }
184
+ * ```
185
+ */
186
+ iconContainer: () => BoxProps;
187
+ /**
188
+ * Style function for the icon text element.
189
+ *
190
+ * @param {StatusMessageThemeProps} props - Props containing the variant
191
+ * @returns {TextProps} Props for rendering the icon character
192
+ *
193
+ * The icon is a variant-specific emoji character selected in the component
194
+ * based on Unicode support detection.
195
+ *
196
+ * Applied styles:
197
+ * - `color: variant-specific` - Color based on variant
198
+ *
199
+ * Icon mapping:
200
+ * - info: Blue color
201
+ * - success: Green color
202
+ * - error: Red color
203
+ * - warning: Yellow color
204
+ *
205
+ * @example
206
+ * ```typescript
207
+ * import { statusMessageTheme } from "tinky-status-message";
208
+ *
209
+ * const successIconStyles = statusMessageTheme.styles.icon({ variant: "success" });
210
+ * // Returns: { color: "green" }
211
+ * ```
212
+ */
213
+ icon: (props: StatusMessageThemeProps) => TextProps;
214
+ /**
215
+ * Style function for the message text element.
216
+ *
217
+ * @returns {TextProps} Props for rendering the message text
218
+ *
219
+ * The message is the main content of the status message, providing detailed
220
+ * information about the status message's purpose.
221
+ *
222
+ * Applied styles:
223
+ * - (none) - Default text styling
224
+ *
225
+ * The message uses normal text styling, allowing it to be more
226
+ * readable and less visually demanding than the colored icon.
227
+ *
228
+ * @example
229
+ * ```typescript
230
+ * import { statusMessageTheme } from "tinky-status-message";
231
+ *
232
+ * const messageStyles = statusMessageTheme.styles.message();
233
+ * // Returns: {}
234
+ * ```
235
+ */
236
+ message: () => TextProps;
237
+ };
238
+ };
239
+ export default statusMessageTheme;
240
+ /**
241
+ * Type definition for the StatusMessage theme.
242
+ *
243
+ * @type {typeof statusMessageTheme}
244
+ *
245
+ * This type represents the complete theme structure for StatusMessage components,
246
+ * including all style functions.
247
+ *
248
+ * Type structure:
249
+ * ```typescript
250
+ * type StatusMessageTheme = {
251
+ * styles: {
252
+ * container: () => BoxProps;
253
+ * iconContainer: () => BoxProps;
254
+ * icon: (props: StatusMessageThemeProps) => TextProps;
255
+ * message: () => TextProps;
256
+ * };
257
+ * }
258
+ * ```
259
+ *
260
+ * @example
261
+ * Creating a custom theme that extends the base:
262
+ * ```typescript
263
+ * import type { StatusMessageTheme } from "tinky-status-message";
264
+ *
265
+ * const customTheme: StatusMessageTheme = {
266
+ * ...statusMessageTheme,
267
+ * styles: {
268
+ * ...statusMessageTheme.styles,
269
+ * container: () => ({
270
+ * columnGap: 2 // Changed spacing
271
+ * })
272
+ * },
273
+ * };
274
+ * ```
275
+ *
276
+ * @see {@link statusMessageTheme}
277
+ * @see {@link StatusMessageThemeProps}
278
+ * @see {@link ComponentTheme}
279
+ */
280
+ export type StatusMessageTheme = typeof statusMessageTheme;
@@ -0,0 +1,236 @@
1
+ /**
2
+ * Theme configuration and styling for StatusMessage components.
3
+ *
4
+ * This module provides the default theme configuration for StatusMessage components,
5
+ * including variant-specific colors and styling functions.
6
+ *
7
+ * The theme system supports:
8
+ * - Four status message variants: info, success, error, warning
9
+ * - Automatic color mapping for each variant
10
+ * - Variant-specific styling
11
+ * - Consistent styling across all status message elements
12
+ * - Integration with the tinky-theme system
13
+ *
14
+ * Variant configurations:
15
+ * - info: Blue color with ℹ️ icon (fallback: ℹ)
16
+ * - success: Green color with ✅ icon (fallback: √)
17
+ * - error: Red color with ❌ icon (fallback: ×)
18
+ * - warning: Yellow color with ⚠️ icon (fallback: ‼)
19
+ *
20
+ * The module exports:
21
+ * 1. `statusMessageTheme` - Complete theme with styles
22
+ * 2. `StatusMessageTheme` - Type definition of the theme
23
+ * 3. `StatusMessageThemeProps` - Props interface for theme functions
24
+ *
25
+ * @example
26
+ * Using the default theme:
27
+ * ```tsx
28
+ * import { StatusMessage, statusMessageTheme } from "tinky-status-message";
29
+ * import { ThemeProvider } from "tinky-theme";
30
+ *
31
+ * <ThemeProvider theme={{ components: { StatusMessage: statusMessageTheme } }}>
32
+ * <StatusMessage variant="info">
33
+ * Information message
34
+ * </StatusMessage>
35
+ * </ThemeProvider>
36
+ * ```
37
+ *
38
+ * @example
39
+ * Customizing via theme extension:
40
+ * ```tsx
41
+ * import { extendTheme } from "tinky-theme";
42
+ * import { statusMessageTheme } from "tinky-status-message";
43
+ *
44
+ * const customTheme = extendTheme(defaultTheme, {
45
+ * components: {
46
+ * StatusMessage: {
47
+ * styles: {
48
+ * container: () => ({
49
+ * columnGap: 2
50
+ * })
51
+ * }
52
+ * }
53
+ * }
54
+ * });
55
+ * ```
56
+ *
57
+ * @see {@link StatusMessageTheme}
58
+ * @see {@link StatusMessage}
59
+ */
60
+ /**
61
+ * Color mapping for status message variants.
62
+ *
63
+ * Maps each variant to its corresponding terminal color:
64
+ * - info → blue
65
+ * - success → green
66
+ * - error → red
67
+ * - warning → yellow
68
+ *
69
+ * These colors are used for:
70
+ * - Icon color for visual emphasis
71
+ * - Any other variant-specific styling
72
+ *
73
+ * @constant {Record<StatusMessageVariant, string>}
74
+ * @private
75
+ */
76
+ const colorByVariant = {
77
+ success: "green",
78
+ error: "red",
79
+ warning: "yellow",
80
+ info: "blue",
81
+ };
82
+ /**
83
+ * Default theme configuration for StatusMessage components.
84
+ *
85
+ * This theme provides all necessary style functions for rendering
86
+ * StatusMessage components in terminal UIs. It follows the tinky-theme
87
+ * ComponentTheme interface for seamless integration with the theme system.
88
+ *
89
+ * Theme structure:
90
+ * - `styles` - Style functions for each component element
91
+ *
92
+ * Style functions:
93
+ * Each style function returns props for the corresponding component:
94
+ * - `styles.container(props)` - BoxProps for the status message container
95
+ * - `styles.iconContainer()` - BoxProps for the icon wrapper
96
+ * - `styles.icon(props)` - TextProps for the icon character
97
+ * - `styles.message()` - TextProps for the message text
98
+ *
99
+ * @example
100
+ * Using the theme directly:
101
+ * ```tsx
102
+ * import { statusMessageTheme } from "tinky-status-message";
103
+ *
104
+ * const { styles } = statusMessageTheme;
105
+ * const containerProps = styles.container({ variant: "success" });
106
+ * // containerProps === { columnGap: 1 }
107
+ *
108
+ * <Box {...containerProps}>
109
+ * Status message content
110
+ * </Box>
111
+ * ```
112
+ *
113
+ * @example
114
+ * Integrating with theme provider:
115
+ * ```tsx
116
+ * import { ThemeProvider } from "tinky-theme";
117
+ * import { statusMessageTheme } from "tinky-status-message";
118
+ *
119
+ * <ThemeProvider theme={{
120
+ * components: {
121
+ * StatusMessage: statusMessageTheme
122
+ * }
123
+ * }}>
124
+ * <StatusMessage variant="info">Info message</StatusMessage>
125
+ * </ThemeProvider>
126
+ * ```
127
+ *
128
+ * @see {@link StatusMessageTheme}
129
+ * @see {@link StatusMessageProps}
130
+ */
131
+ const statusMessageTheme = {
132
+ styles: {
133
+ /**
134
+ * Style function for the status message container.
135
+ *
136
+ * @returns {BoxProps} Props for rendering the status message container
137
+ *
138
+ * The container provides the main visual structure of the status message with:
139
+ * - Horizontal layout (default flex direction)
140
+ * - Spacing between icon and message
141
+ * - Flexible sizing for responsive behavior
142
+ *
143
+ * Applied styles:
144
+ * - `columnGap: 1` - Horizontal spacing between icon and message
145
+ *
146
+ * @example
147
+ * ```typescript
148
+ * import { statusMessageTheme } from "tinky-status-message";
149
+ *
150
+ * const containerStyles = statusMessageTheme.styles.container();
151
+ * // Returns: { columnGap: 1 }
152
+ * ```
153
+ */
154
+ container: () => ({
155
+ columnGap: 1,
156
+ }),
157
+ /**
158
+ * Style function for the icon container.
159
+ *
160
+ * @returns {BoxProps} Props for rendering the icon container
161
+ *
162
+ * The icon container wraps the icon character and ensures it maintains
163
+ * its size regardless of content layout.
164
+ *
165
+ * Applied styles:
166
+ * - `flexShrink: 0` - Prevents icon from shrinking
167
+ *
168
+ * This ensures the icon always displays at its full size, even when
169
+ * the message area needs to shrink to fit constraints.
170
+ *
171
+ * @example
172
+ * ```typescript
173
+ * import { statusMessageTheme } from "tinky-status-message";
174
+ *
175
+ * const iconContainerStyles = statusMessageTheme.styles.iconContainer();
176
+ * // Returns: { flexShrink: 0 }
177
+ * ```
178
+ */
179
+ iconContainer: () => ({
180
+ flexShrink: 0,
181
+ }),
182
+ /**
183
+ * Style function for the icon text element.
184
+ *
185
+ * @param {StatusMessageThemeProps} props - Props containing the variant
186
+ * @returns {TextProps} Props for rendering the icon character
187
+ *
188
+ * The icon is a variant-specific emoji character selected in the component
189
+ * based on Unicode support detection.
190
+ *
191
+ * Applied styles:
192
+ * - `color: variant-specific` - Color based on variant
193
+ *
194
+ * Icon mapping:
195
+ * - info: Blue color
196
+ * - success: Green color
197
+ * - error: Red color
198
+ * - warning: Yellow color
199
+ *
200
+ * @example
201
+ * ```typescript
202
+ * import { statusMessageTheme } from "tinky-status-message";
203
+ *
204
+ * const successIconStyles = statusMessageTheme.styles.icon({ variant: "success" });
205
+ * // Returns: { color: "green" }
206
+ * ```
207
+ */
208
+ icon: (props) => ({
209
+ color: colorByVariant[props.variant],
210
+ }),
211
+ /**
212
+ * Style function for the message text element.
213
+ *
214
+ * @returns {TextProps} Props for rendering the message text
215
+ *
216
+ * The message is the main content of the status message, providing detailed
217
+ * information about the status message's purpose.
218
+ *
219
+ * Applied styles:
220
+ * - (none) - Default text styling
221
+ *
222
+ * The message uses normal text styling, allowing it to be more
223
+ * readable and less visually demanding than the colored icon.
224
+ *
225
+ * @example
226
+ * ```typescript
227
+ * import { statusMessageTheme } from "tinky-status-message";
228
+ *
229
+ * const messageStyles = statusMessageTheme.styles.message();
230
+ * // Returns: {}
231
+ * ```
232
+ */
233
+ message: () => ({}),
234
+ },
235
+ };
236
+ export default statusMessageTheme;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Status message variant types.
3
+ */
4
+ export type StatusMessageVariant = "info" | "success" | "error" | "warning";
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Utility functions for Unicode support detection.
3
+ *
4
+ * Provides functionality to detect Unicode support in terminal environments
5
+ * and provide appropriate fallback characters for unsupported environments.
6
+ */
7
+ export declare function isUnicodeSupported(env?: Record<string, string | undefined>): boolean;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Utility functions for Unicode support detection.
3
+ *
4
+ * Provides functionality to detect Unicode support in terminal environments
5
+ * and provide appropriate fallback characters for unsupported environments.
6
+ */
7
+ export function isUnicodeSupported(env = {}) {
8
+ const lang = env.LANG || "";
9
+ const hasUtf8Locale = lang.toLowerCase().includes("utf-8");
10
+ const colorterm = env.COLORTERM || "";
11
+ const termProgram = env.TERM_PROGRAM || "";
12
+ const hasModernTerminal = colorterm.includes("truecolor") ||
13
+ colorterm.includes("24bit") ||
14
+ termProgram.includes("vscode") ||
15
+ termProgram.includes("iTerm.app") ||
16
+ termProgram.includes("Terminal.app");
17
+ const platform = env.platform || "";
18
+ const isWindows = platform === "win32";
19
+ return hasUtf8Locale || hasModernTerminal || !isWindows;
20
+ }
package/package.json ADDED
@@ -0,0 +1,76 @@
1
+ {
2
+ "name": "tinky-status-message",
3
+ "version": "0.1.0",
4
+ "description": "React status message component for terminal UIs",
5
+ "keywords": [
6
+ "react",
7
+ "cli",
8
+ "terminal",
9
+ "tinky",
10
+ "status",
11
+ "message",
12
+ "notification",
13
+ "variant"
14
+ ],
15
+ "homepage": "https://github.com/ByteLandTechnology/tinky-status-message#readme",
16
+ "bugs": {
17
+ "url": "https://github.com/ByteLandTechnology/tinky-status-message/issues"
18
+ },
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/ByteLandTechnology/tinky-status-message.git"
22
+ },
23
+ "license": "MIT",
24
+ "author": {
25
+ "name": "ByteLandTechnology"
26
+ },
27
+ "type": "module",
28
+ "main": "./lib/index.js",
29
+ "scripts": {
30
+ "test": "bun test",
31
+ "build": "tsc && npm run docs",
32
+ "lint": "eslint src tests",
33
+ "prepublish": "npm run build",
34
+ "prepare": "husky",
35
+ "docs": "typedoc && prettier --write docs/api"
36
+ },
37
+ "files": [
38
+ "./lib/*"
39
+ ],
40
+ "typings": "./lib/index.d.ts",
41
+ "dependencies": {
42
+ "tinky-theme": "^1.0.0"
43
+ },
44
+ "devDependencies": {
45
+ "@commitlint/cli": "^20.3.0",
46
+ "@commitlint/config-conventional": "^20.3.0",
47
+ "@semantic-release/changelog": "^6.0.3",
48
+ "@semantic-release/commit-analyzer": "^13.0.1",
49
+ "@semantic-release/git": "^10.0.1",
50
+ "@semantic-release/github": "^12.0.2",
51
+ "@semantic-release/npm": "^13.1.3",
52
+ "@semantic-release/release-notes-generator": "^14.1.0",
53
+ "@types/bun": "^1.3.8",
54
+ "bun": "^1.3.8",
55
+ "conventional-changelog-conventionalcommits": "^9.1.0",
56
+ "eslint": "^9.39.2",
57
+ "eslint-plugin-react": "^7.37.5",
58
+ "husky": "^9.1.7",
59
+ "jiti": "^2.6.1",
60
+ "lint-staged": "^16.2.7",
61
+ "prettier": "^3.7.4",
62
+ "semantic-release": "^25.0.2",
63
+ "tinky-test": "^1.0.0",
64
+ "typedoc": "^0.28.16",
65
+ "typedoc-plugin-markdown": "^4.9.0",
66
+ "typescript-eslint": "^8.54.0"
67
+ },
68
+ "commitlint": {
69
+ "extends": [
70
+ "@commitlint/config-conventional"
71
+ ]
72
+ },
73
+ "lint-staged": {
74
+ "*.{js,ts,jsx,tsx,json,md,yaml,yml}": "prettier --write"
75
+ }
76
+ }