@solo-io-public/ui-components 0.0.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.
Files changed (77) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +167 -0
  3. package/dist/Button.style-CCplEN2o.js +474 -0
  4. package/dist/Button.style-CCplEN2o.js.map +1 -0
  5. package/dist/Button.style-CI6Xbod7.cjs +10 -0
  6. package/dist/Button.style-CI6Xbod7.cjs.map +1 -0
  7. package/dist/_internal/Svg.d.ts +15 -0
  8. package/dist/_internal/colors.d.ts +17 -0
  9. package/dist/_internal/gradients.d.ts +11 -0
  10. package/dist/_internal/hexAddAlpha.d.ts +3 -0
  11. package/dist/_internal/palette.d.ts +30 -0
  12. package/dist/_internal/sizing.d.ts +14 -0
  13. package/dist/_internal/unstyledButton.d.ts +8 -0
  14. package/dist/_internal/utils.d.ts +7 -0
  15. package/dist/components/Alert/Alert.d.ts +17 -0
  16. package/dist/components/Alert/index.d.ts +1 -0
  17. package/dist/components/Button/Button.d.ts +32 -0
  18. package/dist/components/Button/Button.style.d.ts +48 -0
  19. package/dist/components/Button/index.d.ts +1 -0
  20. package/dist/components/CloseButton/CloseButton.d.ts +14 -0
  21. package/dist/components/CloseButton/index.d.ts +1 -0
  22. package/dist/components/Layout/FlexLayout.d.ts +83 -0
  23. package/dist/components/Layout/Spacer.d.ts +80 -0
  24. package/dist/components/Layout/index.d.ts +2 -0
  25. package/dist/components/MonacoEditor/EditorSettingsContext.d.ts +15 -0
  26. package/dist/components/MonacoEditor/MonacoEditorWithSettings.d.ts +20 -0
  27. package/dist/components/MonacoEditor/index.d.ts +2 -0
  28. package/dist/components/Text/Text.d.ts +71 -0
  29. package/dist/components/Text/index.d.ts +1 -0
  30. package/dist/index.d.ts +7 -0
  31. package/dist/providers/SoloContextProvider.d.ts +62 -0
  32. package/dist/providers/SoloModeContext.d.ts +5 -0
  33. package/dist/providers/index.d.ts +2 -0
  34. package/dist/solo-components.cjs +56 -0
  35. package/dist/solo-components.cjs.map +1 -0
  36. package/dist/solo-components.js +664 -0
  37. package/dist/solo-components.js.map +1 -0
  38. package/dist/styles.cjs +2 -0
  39. package/dist/styles.cjs.map +1 -0
  40. package/dist/styles.d.ts +1 -0
  41. package/dist/styles.js +5 -0
  42. package/dist/styles.js.map +1 -0
  43. package/package.json +109 -0
  44. package/src/_internal/Svg.tsx +58 -0
  45. package/src/_internal/colors.ts +26 -0
  46. package/src/_internal/gradients.ts +36 -0
  47. package/src/_internal/hexAddAlpha.ts +9 -0
  48. package/src/_internal/palette.ts +46 -0
  49. package/src/_internal/sizing.ts +15 -0
  50. package/src/_internal/unstyledButton.ts +17 -0
  51. package/src/_internal/utils.ts +11 -0
  52. package/src/components/Alert/Alert.stories.tsx +44 -0
  53. package/src/components/Alert/Alert.tsx +168 -0
  54. package/src/components/Alert/index.ts +1 -0
  55. package/src/components/Button/Button.stories.tsx +62 -0
  56. package/src/components/Button/Button.style.ts +158 -0
  57. package/src/components/Button/Button.test.tsx +47 -0
  58. package/src/components/Button/Button.tsx +84 -0
  59. package/src/components/Button/index.ts +11 -0
  60. package/src/components/CloseButton/CloseButton.tsx +76 -0
  61. package/src/components/CloseButton/index.ts +1 -0
  62. package/src/components/Layout/FlexLayout.tsx +101 -0
  63. package/src/components/Layout/Spacer.tsx +131 -0
  64. package/src/components/Layout/index.ts +2 -0
  65. package/src/components/MonacoEditor/EditorSettingsContext.test.tsx +55 -0
  66. package/src/components/MonacoEditor/EditorSettingsContext.tsx +63 -0
  67. package/src/components/MonacoEditor/MonacoEditor.stories.tsx +197 -0
  68. package/src/components/MonacoEditor/MonacoEditorWithSettings.tsx +376 -0
  69. package/src/components/MonacoEditor/index.ts +9 -0
  70. package/src/components/Text/Text.stories.tsx +63 -0
  71. package/src/components/Text/Text.tsx +65 -0
  72. package/src/components/Text/index.ts +1 -0
  73. package/src/index.ts +7 -0
  74. package/src/providers/SoloContextProvider.tsx +213 -0
  75. package/src/providers/SoloModeContext.tsx +13 -0
  76. package/src/providers/index.ts +10 -0
  77. package/src/styles.ts +5 -0
@@ -0,0 +1,213 @@
1
+ import { css, Global, ThemeProvider, type Theme } from '@emotion/react';
2
+ import type { ReactNode } from 'react';
3
+ import { Toaster, type ToasterProps } from 'react-hot-toast';
4
+ // Import the context directly (not the MonacoEditor barrel) so this provider
5
+ // never pulls the editor's heavy optional deps (antd / monaco) into apps that
6
+ // only use it for theming + toasts.
7
+ import { EditorSettingsProvider } from '../components/MonacoEditor/EditorSettingsContext';
8
+ import { SoloModeProvider, type SoloMode } from './SoloModeContext';
9
+
10
+ // region Helpers
11
+
12
+ /** Theme tokens the library — and the Monaco editor chrome — read from. */
13
+ export interface SoloTheme {
14
+ mode: SoloMode;
15
+ fontFamily: string;
16
+ colors: {
17
+ background: string;
18
+ bgElevated: string;
19
+ bgHover: string;
20
+ /** Pressed/active surface — a clearly distinct step from `bgHover`. */
21
+ bgActive: string;
22
+ borderBase: string;
23
+ primary: string;
24
+ textPrimary: string;
25
+ textSecondary: string;
26
+ };
27
+ }
28
+
29
+ const FONT_FAMILY = "'Figtree', ui-sans-serif, system-ui, sans-serif";
30
+
31
+ // Light and dark palettes. The editor chrome and components read these via the
32
+ // `--color-*` CSS variables the provider injects.
33
+ // Purple-core: neutrals are tinted toward the brand violet (#8134e2, hue ~267) so
34
+ // purple reads as the system. `bgHover` → `bgActive` is a clear, deliberate step.
35
+ const palettes: Record<SoloMode, SoloTheme['colors']> = {
36
+ dark: {
37
+ background: '#0f0b18',
38
+ bgElevated: '#1b1624',
39
+ bgHover: '#282035',
40
+ bgActive: '#352b48',
41
+ borderBase: '#3d344d',
42
+ primary: '#8134e2',
43
+ textPrimary: '#f6f4fb',
44
+ textSecondary: '#a6a0b8'
45
+ },
46
+ light: {
47
+ background: '#ffffff',
48
+ bgElevated: '#f6f3fb',
49
+ bgHover: '#ece7f5',
50
+ bgActive: '#ddd3ee',
51
+ borderBase: '#ded7ec',
52
+ primary: '#8134e2',
53
+ textPrimary: '#1a1623',
54
+ textSecondary: '#585465'
55
+ }
56
+ };
57
+
58
+ /** Default Solo theme (dark). */
59
+ export const defaultSoloTheme: SoloTheme = { mode: 'dark', fontFamily: FONT_FAMILY, colors: palettes.dark };
60
+
61
+ /** Theme overrides — non-recursive (one level of `colors`) to keep types cheap. */
62
+ export interface SoloThemeOverride {
63
+ fontFamily?: string;
64
+ colors?: Partial<SoloTheme['colors']>;
65
+ }
66
+
67
+ /** Toggle which providers `SoloContextProvider` sets up. Each defaults to `true`. */
68
+ export interface SoloFeatures {
69
+ /** emotion `ThemeProvider`, the `--color-*` CSS variables, and the web fonts. */
70
+ theme?: boolean;
71
+ /** react-hot-toast `<Toaster />`. */
72
+ toaster?: boolean;
73
+ }
74
+
75
+ /** Fully typed customization for the enabled features. */
76
+ export interface SoloConfig {
77
+ /** Theme overrides, merged over the mode palette and any outer `ThemeProvider`. */
78
+ theme?: SoloThemeOverride;
79
+ /** Props for the bundled react-hot-toast `<Toaster />`. */
80
+ toaster?: ToasterProps;
81
+ }
82
+
83
+ // Loads Figtree (UI), DM Sans, and DM Mono. Kept first in the injected sheet so
84
+ // the @import stays valid.
85
+ const FONT_IMPORT =
86
+ "@import url('https://fonts.googleapis.com/css2?family=Figtree:wght@300;400;500;600;700;800&family=DM+Sans:wght@300;400;500;600;700&family=DM+Mono:wght@300;400;500&display=swap');";
87
+
88
+ // Non-destructive merge: start from the mode palette, keep outer emotion theme
89
+ // keys, then apply the caller's overrides.
90
+ const mergeTheme = (mode: SoloMode, outer: Theme | undefined, overrides?: SoloThemeOverride): SoloTheme => {
91
+ const outerOverride = (outer ?? {}) as SoloThemeOverride;
92
+ return {
93
+ ...(outer as object),
94
+ mode,
95
+ fontFamily: overrides?.fontFamily ?? outerOverride.fontFamily ?? FONT_FAMILY,
96
+ colors: {
97
+ ...palettes[mode],
98
+ ...(outerOverride.colors ?? {}),
99
+ ...(overrides?.colors ?? {})
100
+ }
101
+ };
102
+ };
103
+
104
+ const globalStyles = (theme: SoloTheme) => css`
105
+ ${FONT_IMPORT}
106
+
107
+ :root {
108
+ --solo-font-family: ${theme.fontFamily};
109
+ --color-background: ${theme.colors.background};
110
+ --color-bg-elevated: ${theme.colors.bgElevated};
111
+ --color-bg-hover: ${theme.colors.bgHover};
112
+ --color-bg-active: ${theme.colors.bgActive};
113
+ --color-border-base: ${theme.colors.borderBase};
114
+ --color-primary: ${theme.colors.primary};
115
+ --color-text-primary: ${theme.colors.textPrimary};
116
+ --color-text-secondary: ${theme.colors.textSecondary};
117
+ }
118
+
119
+ body {
120
+ font-family: ${theme.fontFamily};
121
+ }
122
+
123
+ @keyframes fadeIn {
124
+ from {
125
+ opacity: 0;
126
+ }
127
+ to {
128
+ opacity: 1;
129
+ }
130
+ }
131
+ `;
132
+
133
+ // region Component
134
+
135
+ /**
136
+ * Wraps children in the emotion theme + CSS variables + web fonts, or passes
137
+ * them through untouched when theming is off. Isolating this keeps
138
+ * `SoloContextProvider` a flat, declarative tree instead of branching inline.
139
+ */
140
+ function ThemeLayer({
141
+ enabled,
142
+ mode,
143
+ overrides,
144
+ children
145
+ }: {
146
+ enabled: boolean;
147
+ mode: SoloMode;
148
+ overrides?: SoloThemeOverride;
149
+ children: ReactNode;
150
+ }) {
151
+ if (!enabled) return <>{children}</>;
152
+
153
+ const theme = mergeTheme(mode, undefined, overrides);
154
+ return (
155
+ <ThemeProvider theme={outer => mergeTheme(mode, outer, overrides)}>
156
+ <Global styles={globalStyles(theme)} />
157
+ {children}
158
+ </ThemeProvider>
159
+ );
160
+ }
161
+
162
+ export interface SoloContextProviderProps {
163
+ children: ReactNode;
164
+ /** Light or dark color mode. Drives the palette and the editor's default theme. Defaults to `'dark'`. */
165
+ mode?: SoloMode;
166
+ /** Toggle which providers are set up. Each feature defaults to on. */
167
+ features?: SoloFeatures;
168
+ /** Fully typed customization for the enabled features. */
169
+ config?: SoloConfig;
170
+ }
171
+
172
+ /**
173
+ * Single top-level provider for apps consuming this library. Composes the
174
+ * color mode + emotion theme (web fonts + the `--color-*` CSS variables the
175
+ * editor chrome reads), editor settings, and a react-hot-toast `<Toaster />` —
176
+ * so the library's components work as drop-ins.
177
+ *
178
+ * Opinionated by default (closed to modification), open to extension: pick
179
+ * `mode`, toggle pieces with `features`, and customize them with `config`.
180
+ *
181
+ * The body reads top-down as the provider tree it renders:
182
+ * mode → theme → editor settings → toaster → your app.
183
+ */
184
+ export function SoloContextProvider({ children, mode = 'dark', features, config }: SoloContextProviderProps) {
185
+ const themeEnabled = features?.theme !== false;
186
+ const toasterEnabled = features?.toaster !== false;
187
+
188
+ return (
189
+ <SoloModeProvider value={mode}>
190
+ <ThemeLayer enabled={themeEnabled} mode={mode} overrides={config?.theme}>
191
+ <EditorSettingsProvider>
192
+ {toasterEnabled && (
193
+ <Toaster
194
+ {...config?.toaster}
195
+ position={config?.toaster?.position ?? 'bottom-right'}
196
+ toastOptions={{
197
+ ...config?.toaster?.toastOptions,
198
+ // Themed via CSS variables so toasts match light/dark automatically.
199
+ style: {
200
+ background: 'var(--color-bg-elevated, #1e1e22)',
201
+ color: 'var(--color-text-primary, #fafafa)',
202
+ border: '1px solid var(--color-border-base, #3f3f46)',
203
+ ...config?.toaster?.toastOptions?.style
204
+ }
205
+ }}
206
+ />
207
+ )}
208
+ {children}
209
+ </EditorSettingsProvider>
210
+ </ThemeLayer>
211
+ </SoloModeProvider>
212
+ );
213
+ }
@@ -0,0 +1,13 @@
1
+ import { createContext, useContext } from 'react';
2
+
3
+ export type SoloMode = 'light' | 'dark';
4
+
5
+ const SoloModeContext = createContext<SoloMode>('dark');
6
+
7
+ /** Provides the active light/dark mode to descendants (e.g. the editor). */
8
+ export const SoloModeProvider = SoloModeContext.Provider;
9
+
10
+ /** Read the active Solo color mode. Defaults to `'dark'` outside a provider. */
11
+ export function useSoloMode(): SoloMode {
12
+ return useContext(SoloModeContext);
13
+ }
@@ -0,0 +1,10 @@
1
+ export {
2
+ SoloContextProvider,
3
+ defaultSoloTheme,
4
+ type SoloContextProviderProps,
5
+ type SoloConfig,
6
+ type SoloFeatures,
7
+ type SoloTheme,
8
+ type SoloThemeOverride
9
+ } from './SoloContextProvider';
10
+ export { useSoloMode, type SoloMode } from './SoloModeContext';
package/src/styles.ts ADDED
@@ -0,0 +1,5 @@
1
+ // Subpath entry for `@solo-io-public/ui-components/styles` — exposes the styled-component
2
+ // namespaces (`XStyles`) so consumers can target them as CSS selectors or render
3
+ // them directly. Convention: each component owns a `*.style.ts` that exports a
4
+ // single `XStyles` namespace; add one re-export line below per new component.
5
+ export { SoloButtonStyles } from "./components/Button/Button.style";