@tpitre/story-ui 4.6.2 → 4.6.3
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/dist/story-generator/framework-adapters/base-adapter.d.ts +1 -1
- package/dist/story-generator/framework-adapters/base-adapter.d.ts.map +1 -1
- package/dist/story-generator/framework-adapters/base-adapter.js +44 -5
- package/dist/story-generator/framework-adapters/index.d.ts.map +1 -1
- package/dist/story-generator/framework-adapters/index.js +5 -1
- package/dist/story-generator/promptGenerator.d.ts +6 -0
- package/dist/story-generator/promptGenerator.d.ts.map +1 -1
- package/dist/story-generator/promptGenerator.js +41 -4
- package/dist/templates/StoryUI/StoryUIPanel.css +60 -12
- package/package.json +1 -1
- package/templates/StoryUI/StoryUIPanel.css +60 -12
|
@@ -69,7 +69,7 @@ export declare abstract class BaseFrameworkAdapter implements FrameworkAdapter {
|
|
|
69
69
|
*/
|
|
70
70
|
protected log(message: string, data?: Record<string, unknown>): void;
|
|
71
71
|
/**
|
|
72
|
-
* Get common story structure rules
|
|
72
|
+
* Get common story structure rules including MANDATORY spacing
|
|
73
73
|
*/
|
|
74
74
|
protected getCommonRules(): string;
|
|
75
75
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-adapter.d.ts","sourceRoot":"","sources":["../../../story-generator/framework-adapters/base-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,sBAAsB,EACvB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAG/D;;GAEG;AACH,8BAAsB,oBAAqB,YAAW,gBAAgB;IACpE,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IACtC,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;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AmB,EAAE,GAChC,MAAM,CAAC,MAAM,EAAE,mBAAmB,EAAE,CAAC;IAcxC;;OAEG;IACH,QAAQ,CAAC,gBAAgB,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM;IAExD;;OAEG;IACH,QAAQ,CAAC,mBAAmB,CAC1B,MAAM,EAAE,aAAa,EACrB,UAAU,EAAE,mBAAmB,EAAE,GAChC,MAAM;IAET;;OAEG;IACH,eAAe,CACb,UAAU,EAAE,mBAAmB,EAAE,EACjC,MAAM,EAAE,aAAa,GACpB,MAAM;IAoBT;;;OAGG;IACH,WAAW,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM;IAmBzC;;OAEG;IACH,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG;QAAE,KAAK,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,MAAM,EAAE,CAAA;KAAE;IAkBpE;;OAEG;IACH,QAAQ,CAAC,gBAAgB,CAAC,OAAO,CAAC,EAAE,sBAAsB,GAAG,MAAM;IAEnE;;OAEG;IACH,SAAS,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAIpE;;OAEG;IACH,SAAS,CAAC,cAAc,IAAI,MAAM;CA2DnC"}
|
|
@@ -132,7 +132,7 @@ export class BaseFrameworkAdapter {
|
|
|
132
132
|
logger.debug(`[${this.name}Adapter] ${message}`, data);
|
|
133
133
|
}
|
|
134
134
|
/**
|
|
135
|
-
* Get common story structure rules
|
|
135
|
+
* Get common story structure rules including MANDATORY spacing
|
|
136
136
|
*/
|
|
137
137
|
getCommonRules() {
|
|
138
138
|
return `
|
|
@@ -148,10 +148,49 @@ IMAGE RULES:
|
|
|
148
148
|
- Always include alt text for images
|
|
149
149
|
- Example: https://picsum.photos/400/300?random=1
|
|
150
150
|
|
|
151
|
-
SPACING RULES:
|
|
152
|
-
-
|
|
153
|
-
|
|
154
|
-
|
|
151
|
+
MANDATORY SPACING & LAYOUT RULES (NON-NEGOTIABLE):
|
|
152
|
+
** CRITICAL: Every generated component MUST have professional-quality spacing. Components without proper spacing look broken and unprofessional. **
|
|
153
|
+
|
|
154
|
+
1. STORY WRAPPER (REQUIRED for every story):
|
|
155
|
+
- The render function MUST return a wrapper div with padding
|
|
156
|
+
- Pattern: render: () => <div style={{ padding: "24px" }}>...content...</div>
|
|
157
|
+
- This ensures content has breathing room within the Storybook canvas
|
|
158
|
+
|
|
159
|
+
2. FORM FIELD SPACING (CRITICAL):
|
|
160
|
+
- ALWAYS wrap form fields in a container with vertical spacing
|
|
161
|
+
- Use flexbox column with gap: <div style={{ display: "flex", flexDirection: "column", gap: "16px" }}>
|
|
162
|
+
- Or use design system spacing tokens if available
|
|
163
|
+
- MINIMUM 16px gap between form fields
|
|
164
|
+
|
|
165
|
+
3. BUTTON SPACING:
|
|
166
|
+
- Submit/action buttons: 24px margin-top from form fields above
|
|
167
|
+
- Pattern: <div style={{ marginTop: "24px" }}><Button>Submit</Button></div>
|
|
168
|
+
- Button groups should be wrapped with margin-top from content
|
|
169
|
+
|
|
170
|
+
4. SECTION SPACING:
|
|
171
|
+
- Between major sections: 32-48px
|
|
172
|
+
- Between related content groups: 24px
|
|
173
|
+
- Use dividers or significant whitespace between unrelated content
|
|
174
|
+
|
|
175
|
+
5. HEADING SPACING:
|
|
176
|
+
- More space ABOVE headings (24-32px) than below (8-16px)
|
|
177
|
+
- Pattern: <Heading style={{ marginTop: "32px", marginBottom: "12px" }}>
|
|
178
|
+
|
|
179
|
+
6. CARD/CONTAINER PADDING:
|
|
180
|
+
- Internal padding: minimum 16px, preferred 24px
|
|
181
|
+
- Pattern: <Card style={{ padding: "24px" }}>
|
|
182
|
+
|
|
183
|
+
7. SPECIFIC VALUES TO USE:
|
|
184
|
+
- Tight spacing (icons, inline): 4-8px
|
|
185
|
+
- Related items: 8-12px
|
|
186
|
+
- Form fields: 16px gap
|
|
187
|
+
- Buttons from content: 24px margin-top
|
|
188
|
+
- Sections: 32-48px
|
|
189
|
+
- Major divisions: 48-64px
|
|
190
|
+
|
|
191
|
+
SPACING VALIDATION (Self-check before generating):
|
|
192
|
+
Ask yourself: "Does every element have adequate breathing room from its neighbors?"
|
|
193
|
+
If any elements appear cramped or touching, add appropriate spacing.
|
|
155
194
|
`;
|
|
156
195
|
}
|
|
157
196
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../story-generator/framework-adapters/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,cAAc,YAAY,CAAC;AAG3B,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,oBAAoB,GACrB,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAGzD,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACtE,OAAO,EAAE,oBAAoB,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAC;AAC/F,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAGzE,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,EACf,sBAAsB,EACvB,MAAM,YAAY,CAAC;AAOpB,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../story-generator/framework-adapters/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,cAAc,YAAY,CAAC;AAG3B,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,oBAAoB,GACrB,M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;OAEG;IACG,UAAU,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAoBjE;;OAEG;IACH,oBAAoB,IAAI,iBAAiB,GAAG,IAAI;IAIhD;;OAEG;IACG,cAAc,CAClB,MAAM,EAAE,aAAa,EACrB,UAAU,EAAE,mBAAmB,EAAE,EACjC,OAAO,CAAC,EAAE,sBAAsB,GAC/B,OAAO,CAAC,eAAe,CAAC;CAkC5B;AAKD;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,eAAe,CAKpD;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,aAAa,GAAG,gBAAgB,GAAG,SAAS,CAE5E;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,gBAAgB,CAEpD;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAEvF;AAED;;GAEG;AACH,wBAAsB,uBAAuB,CAC3C,MAAM,EAAE,aAAa,EACrB,UAAU,EAAE,mBAAmB,EAAE,EACjC,OAAO,CAAC,EAAE,sBAAsB,GAC/B,OAAO,CAAC,eAAe,CAAC,CAE1B"}
|
|
@@ -22,6 +22,7 @@ import { AngularAdapter } from './angular-adapter.js';
|
|
|
22
22
|
import { SvelteAdapter } from './svelte-adapter.js';
|
|
23
23
|
import { detectFramework } from './framework-detector.js';
|
|
24
24
|
import { logger } from '../logger.js';
|
|
25
|
+
import { generateLayoutInstructions } from '../promptGenerator.js';
|
|
25
26
|
/**
|
|
26
27
|
* Framework Adapter Registry
|
|
27
28
|
*
|
|
@@ -147,10 +148,13 @@ class AdapterRegistry {
|
|
|
147
148
|
adapter = await this.autoDetect();
|
|
148
149
|
}
|
|
149
150
|
logger.debug('Generating prompt with adapter', { adapter: adapter.type });
|
|
151
|
+
// Generate layout instructions including mandatory spacing rules
|
|
152
|
+
const layoutInstructionsArray = generateLayoutInstructions(config);
|
|
153
|
+
const layoutInstructionsString = layoutInstructionsArray.join('\n');
|
|
150
154
|
return {
|
|
151
155
|
systemPrompt: adapter.generateSystemPrompt(config, options),
|
|
152
156
|
componentReference: adapter.generateComponentReference(components, config),
|
|
153
|
-
layoutInstructions:
|
|
157
|
+
layoutInstructions: layoutInstructionsString,
|
|
154
158
|
examples: adapter.generateExamples(config),
|
|
155
159
|
sampleStory: adapter.generateSampleStory(config, components),
|
|
156
160
|
framework: this.detectedFramework || {
|
|
@@ -19,6 +19,12 @@ export interface GeneratedPrompt {
|
|
|
19
19
|
* Generates a comprehensive AI prompt based on the configuration and discovered components
|
|
20
20
|
*/
|
|
21
21
|
export declare function generatePrompt(config: StoryUIConfig, components: DiscoveredComponent[]): GeneratedPrompt;
|
|
22
|
+
/**
|
|
23
|
+
* Generates layout-specific instructions including MANDATORY vertical spacing rules
|
|
24
|
+
* @param config - The StoryUI configuration object
|
|
25
|
+
* @returns Array of layout instruction strings to be included in the prompt
|
|
26
|
+
*/
|
|
27
|
+
export declare function generateLayoutInstructions(config: StoryUIConfig): string[];
|
|
22
28
|
/**
|
|
23
29
|
* Builds the complete Claude prompt
|
|
24
30
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"promptGenerator.d.ts","sourceRoot":"","sources":["../../story-generator/promptGenerator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAI9D,OAAO,EAEL,eAAe,EACf,sBAAsB,EACtB,aAAa,EACb,gBAAgB,EACjB,MAAM,+BAA+B,CAAC;AAyOvC;;;GAGG;AACH,MAAM,WAAW,oBAAqB,SAAQ,IAAI,CAAC,eAAe,EAAE,oBAAoB,CAAC;IACvF,kBAAkB,EAAE,MAAM,EAAE,CAAC;CAC9B;AAED,MAAM,WAAW,eAAe;IAC9B,YAAY,EAAE,MAAM,CAAC;IACrB,kBAAkB,EAAE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BAA4B,CAChD,MAAM,EAAE,aAAa,EACrB,UAAU,EAAE,mBAAmB,EAAE,EACjC,OAAO,CAAC,EAAE,sBAAsB,GAC/B,OAAO,CAAC,oBAAoB,CAAC,CAqB/B;AAED;;;GAGG;AACH,wBAAsB,yBAAyB,CAC7C,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,aAAa,EACrB,UAAU,EAAE,mBAAmB,EAAE,EACjC,OAAO,CAAC,EAAE,sBAAsB,GAC/B,OAAO,CAAC,MAAM,CAAC,CAiHjB;AA4ED;;GAEG;AACH,wBAAsB,sBAAsB,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAIzF;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,aAAa,GAAG,gBAAgB,CAG9E;AAED;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,aAAa,EAAE,CAGxD"}
|
|
@@ -465,13 +465,47 @@ function formatComponentReference(component, config) {
|
|
|
465
465
|
return reference;
|
|
466
466
|
}
|
|
467
467
|
/**
|
|
468
|
-
* Generates layout-specific instructions
|
|
468
|
+
* Generates layout-specific instructions including MANDATORY vertical spacing rules
|
|
469
|
+
* @param config - The StoryUI configuration object
|
|
470
|
+
* @returns Array of layout instruction strings to be included in the prompt
|
|
469
471
|
*/
|
|
470
|
-
function generateLayoutInstructions(config) {
|
|
472
|
+
export function generateLayoutInstructions(config) {
|
|
471
473
|
const instructions = [];
|
|
472
474
|
const layoutRules = config.layoutRules;
|
|
475
|
+
// MANDATORY VERTICAL SPACING RULES - These are non-negotiable for professional UI quality
|
|
476
|
+
instructions.push('MANDATORY VERTICAL SPACING RULES (NON-NEGOTIABLE):');
|
|
477
|
+
instructions.push('');
|
|
478
|
+
instructions.push('** CRITICAL: Every component MUST have proper vertical spacing. Components without spacing look broken and unprofessional. **');
|
|
479
|
+
instructions.push('');
|
|
480
|
+
instructions.push('1. FORM FIELDS: Always wrap form fields in a container with vertical spacing:');
|
|
481
|
+
instructions.push(' - Use flexbox column with gap: <div style={{ display: "flex", flexDirection: "column", gap: "16px" }}>');
|
|
482
|
+
instructions.push(' - Or use your design system\'s spacing tokens if available');
|
|
483
|
+
instructions.push(' - MINIMUM 16px gap between form fields, 24px for complex forms');
|
|
484
|
+
instructions.push('');
|
|
485
|
+
instructions.push('2. BUTTON SPACING: Buttons MUST have margin-top from content above:');
|
|
486
|
+
instructions.push(' - Submit/action buttons: 24px margin-top from form fields');
|
|
487
|
+
instructions.push(' - Button groups: wrap in <div style={{ marginTop: "24px" }}>');
|
|
488
|
+
instructions.push('');
|
|
489
|
+
instructions.push('3. SECTION SPACING: Logical sections need clear visual separation:');
|
|
490
|
+
instructions.push(' - Between major sections: 32-48px');
|
|
491
|
+
instructions.push(' - Between related content groups: 24px');
|
|
492
|
+
instructions.push(' - Use dividers or significant whitespace between unrelated content');
|
|
493
|
+
instructions.push('');
|
|
494
|
+
instructions.push('4. HEADING SPACING: Headings need asymmetric spacing:');
|
|
495
|
+
instructions.push(' - More space ABOVE headings (24-32px) than below (8-16px)');
|
|
496
|
+
instructions.push(' - This creates visual hierarchy and groups content with its heading');
|
|
497
|
+
instructions.push('');
|
|
498
|
+
instructions.push('5. CARD/CONTAINER PADDING: Internal padding is mandatory:');
|
|
499
|
+
instructions.push(' - Minimum 16px padding on all sides');
|
|
500
|
+
instructions.push(' - Preferred 24px for cards with multiple elements');
|
|
501
|
+
instructions.push(' - Use design system spacing tokens when available');
|
|
502
|
+
instructions.push('');
|
|
503
|
+
instructions.push('6. WRAPPER PATTERN (REQUIRED): The story render function MUST return a wrapper div with padding:');
|
|
504
|
+
instructions.push(' - render: () => <div style={{ padding: "24px" }}>...content...</div>');
|
|
505
|
+
instructions.push(' - This ensures content has breathing room within the Storybook canvas');
|
|
506
|
+
instructions.push('');
|
|
473
507
|
if (layoutRules.multiColumnWrapper && layoutRules.columnComponent) {
|
|
474
|
-
instructions.push('
|
|
508
|
+
instructions.push('MULTI-COLUMN LAYOUT RULES:');
|
|
475
509
|
instructions.push(`- For ANY multi-column layout (2, 3, or more columns), use ${layoutRules.multiColumnWrapper} components`);
|
|
476
510
|
instructions.push(`- Each column must be wrapped in its own ${layoutRules.columnComponent} element`);
|
|
477
511
|
instructions.push(`- Structure: <${layoutRules.multiColumnWrapper}><${layoutRules.columnComponent}>column 1</${layoutRules.columnComponent}><${layoutRules.columnComponent}>column 2</${layoutRules.columnComponent}></${layoutRules.multiColumnWrapper}>`);
|
|
@@ -479,14 +513,17 @@ function generateLayoutInstructions(config) {
|
|
|
479
513
|
instructions.push(`- NEVER use CSS properties as props (like display="grid" or gridTemplateColumns) - these are not valid props`);
|
|
480
514
|
instructions.push(`- For grid-like layouts, use Flex with wrap prop and appropriate gap, NOT CSS Grid`);
|
|
481
515
|
instructions.push(`- The ${layoutRules.multiColumnWrapper} should be the main component in your story for multi-column layouts`);
|
|
516
|
+
instructions.push('');
|
|
482
517
|
}
|
|
483
518
|
if (layoutRules.prohibitedElements && layoutRules.prohibitedElements.length > 0) {
|
|
484
519
|
instructions.push(`- NEVER use plain HTML ${layoutRules.prohibitedElements.join(', ')} elements - ALWAYS use the provided design system components`);
|
|
485
520
|
}
|
|
486
521
|
// Generic layout instructions for all design systems
|
|
522
|
+
instructions.push('GENERAL LAYOUT BEST PRACTICES:');
|
|
487
523
|
instructions.push(`- Use semantic heading components from your design system instead of raw <h1>-<h6> tags`);
|
|
488
|
-
instructions.push(`- Use the design system's layout components and spacing tokens instead of inline styles`);
|
|
524
|
+
instructions.push(`- Use the design system's layout components and spacing tokens instead of inline styles when available`);
|
|
489
525
|
instructions.push(`- Prefer design system components over plain HTML elements for consistent styling`);
|
|
526
|
+
instructions.push(`- ALWAYS test mentally: "Does this component have enough visual breathing room?" If not, add spacing.`);
|
|
490
527
|
return instructions;
|
|
491
528
|
}
|
|
492
529
|
/**
|
|
@@ -1248,6 +1248,7 @@
|
|
|
1248
1248
|
|
|
1249
1249
|
/* ============================================
|
|
1250
1250
|
Completion Card - shares bubble styling with message bubbles
|
|
1251
|
+
Uses explicit colors with !important to prevent design system overrides
|
|
1251
1252
|
============================================ */
|
|
1252
1253
|
.sui-completion {
|
|
1253
1254
|
max-width: 85%;
|
|
@@ -1256,9 +1257,17 @@
|
|
|
1256
1257
|
border-bottom-left-radius: var(--radius-sm);
|
|
1257
1258
|
font-size: 0.9375rem;
|
|
1258
1259
|
line-height: 1.6;
|
|
1259
|
-
|
|
1260
|
-
background:
|
|
1261
|
-
color:
|
|
1260
|
+
/* Explicit light mode colors */
|
|
1261
|
+
background: #ffffff !important;
|
|
1262
|
+
color: #18181b !important;
|
|
1263
|
+
border: 1px solid #e4e4e7 !important;
|
|
1264
|
+
}
|
|
1265
|
+
|
|
1266
|
+
/* Completion card - dark mode */
|
|
1267
|
+
.sui-root.dark .sui-completion {
|
|
1268
|
+
background: #27272a !important;
|
|
1269
|
+
color: #fafafa !important;
|
|
1270
|
+
border: 1px solid #3f3f46 !important;
|
|
1262
1271
|
}
|
|
1263
1272
|
|
|
1264
1273
|
.sui-completion-header {
|
|
@@ -1266,7 +1275,13 @@
|
|
|
1266
1275
|
align-items: center;
|
|
1267
1276
|
gap: var(--space-2);
|
|
1268
1277
|
font-weight: 500;
|
|
1269
|
-
|
|
1278
|
+
/* Explicit green for success - readable on white */
|
|
1279
|
+
color: #16a34a !important;
|
|
1280
|
+
}
|
|
1281
|
+
|
|
1282
|
+
/* Completion header - dark mode */
|
|
1283
|
+
.sui-root.dark .sui-completion-header {
|
|
1284
|
+
color: #22c55e !important;
|
|
1270
1285
|
}
|
|
1271
1286
|
|
|
1272
1287
|
.sui-completion-components {
|
|
@@ -1278,48 +1293,81 @@
|
|
|
1278
1293
|
|
|
1279
1294
|
.sui-completion-tag {
|
|
1280
1295
|
padding: 0.125rem var(--space-2);
|
|
1281
|
-
|
|
1282
|
-
|
|
1296
|
+
/* Explicit blue colors - readable tag styling */
|
|
1297
|
+
background: #eff6ff !important;
|
|
1298
|
+
color: #2563eb !important;
|
|
1283
1299
|
border-radius: var(--radius-full);
|
|
1284
1300
|
font-size: 0.75rem;
|
|
1285
1301
|
font-family: var(--font-mono);
|
|
1286
1302
|
}
|
|
1287
1303
|
|
|
1304
|
+
/* Completion tag - dark mode */
|
|
1305
|
+
.sui-root.dark .sui-completion-tag {
|
|
1306
|
+
background: #1e3a5f !important;
|
|
1307
|
+
color: #60a5fa !important;
|
|
1308
|
+
}
|
|
1309
|
+
|
|
1288
1310
|
.sui-completion-metrics {
|
|
1289
1311
|
display: flex;
|
|
1290
1312
|
gap: var(--space-4);
|
|
1291
1313
|
margin-top: var(--space-3);
|
|
1292
1314
|
font-size: 0.8125rem;
|
|
1293
|
-
|
|
1315
|
+
/* Explicit muted gray */
|
|
1316
|
+
color: #71717a !important;
|
|
1317
|
+
}
|
|
1318
|
+
|
|
1319
|
+
/* Completion metrics - dark mode */
|
|
1320
|
+
.sui-root.dark .sui-completion-metrics {
|
|
1321
|
+
color: #a1a1aa !important;
|
|
1294
1322
|
}
|
|
1295
1323
|
|
|
1296
1324
|
/* Fallback story styling (error placeholder was created) */
|
|
1297
1325
|
.sui-completion-fallback .sui-completion-header {
|
|
1298
|
-
color:
|
|
1326
|
+
color: #ca8a04 !important; /* Amber/warning color */
|
|
1327
|
+
}
|
|
1328
|
+
|
|
1329
|
+
.sui-root.dark .sui-completion-fallback .sui-completion-header {
|
|
1330
|
+
color: #facc15 !important; /* Lighter amber for dark mode */
|
|
1299
1331
|
}
|
|
1300
1332
|
|
|
1301
1333
|
.sui-completion-fallback-warning {
|
|
1302
1334
|
margin-top: var(--space-2);
|
|
1303
1335
|
padding: var(--space-2) var(--space-3);
|
|
1304
|
-
background:
|
|
1336
|
+
background: #fef9c3 !important; /* Light amber background */
|
|
1305
1337
|
border-radius: var(--radius-md);
|
|
1306
1338
|
font-size: 0.8125rem;
|
|
1307
1339
|
}
|
|
1308
1340
|
|
|
1341
|
+
.sui-root.dark .sui-completion-fallback-warning {
|
|
1342
|
+
background: #422006 !important; /* Dark amber background */
|
|
1343
|
+
}
|
|
1344
|
+
|
|
1309
1345
|
.sui-completion-fallback-warning strong {
|
|
1310
1346
|
display: block;
|
|
1311
|
-
color:
|
|
1347
|
+
color: #ca8a04 !important; /* Amber text */
|
|
1312
1348
|
margin-bottom: var(--space-1);
|
|
1313
1349
|
}
|
|
1314
1350
|
|
|
1351
|
+
.sui-root.dark .sui-completion-fallback-warning strong {
|
|
1352
|
+
color: #facc15 !important;
|
|
1353
|
+
}
|
|
1354
|
+
|
|
1315
1355
|
.sui-completion-fallback-warning p {
|
|
1316
1356
|
margin: 0;
|
|
1317
|
-
color:
|
|
1357
|
+
color: #71717a !important; /* Muted gray */
|
|
1358
|
+
}
|
|
1359
|
+
|
|
1360
|
+
.sui-root.dark .sui-completion-fallback-warning p {
|
|
1361
|
+
color: #a1a1aa !important;
|
|
1318
1362
|
}
|
|
1319
1363
|
|
|
1320
1364
|
/* Error completion styling (generation failed completely) */
|
|
1321
1365
|
.sui-completion-error .sui-completion-header {
|
|
1322
|
-
color:
|
|
1366
|
+
color: #dc2626 !important; /* Red for errors */
|
|
1367
|
+
}
|
|
1368
|
+
|
|
1369
|
+
.sui-root.dark .sui-completion-error .sui-completion-header {
|
|
1370
|
+
color: #f87171 !important; /* Lighter red for dark mode */
|
|
1323
1371
|
}
|
|
1324
1372
|
|
|
1325
1373
|
/* ============================================
|
package/package.json
CHANGED
|
@@ -1248,6 +1248,7 @@
|
|
|
1248
1248
|
|
|
1249
1249
|
/* ============================================
|
|
1250
1250
|
Completion Card - shares bubble styling with message bubbles
|
|
1251
|
+
Uses explicit colors with !important to prevent design system overrides
|
|
1251
1252
|
============================================ */
|
|
1252
1253
|
.sui-completion {
|
|
1253
1254
|
max-width: 85%;
|
|
@@ -1256,9 +1257,17 @@
|
|
|
1256
1257
|
border-bottom-left-radius: var(--radius-sm);
|
|
1257
1258
|
font-size: 0.9375rem;
|
|
1258
1259
|
line-height: 1.6;
|
|
1259
|
-
|
|
1260
|
-
background:
|
|
1261
|
-
color:
|
|
1260
|
+
/* Explicit light mode colors */
|
|
1261
|
+
background: #ffffff !important;
|
|
1262
|
+
color: #18181b !important;
|
|
1263
|
+
border: 1px solid #e4e4e7 !important;
|
|
1264
|
+
}
|
|
1265
|
+
|
|
1266
|
+
/* Completion card - dark mode */
|
|
1267
|
+
.sui-root.dark .sui-completion {
|
|
1268
|
+
background: #27272a !important;
|
|
1269
|
+
color: #fafafa !important;
|
|
1270
|
+
border: 1px solid #3f3f46 !important;
|
|
1262
1271
|
}
|
|
1263
1272
|
|
|
1264
1273
|
.sui-completion-header {
|
|
@@ -1266,7 +1275,13 @@
|
|
|
1266
1275
|
align-items: center;
|
|
1267
1276
|
gap: var(--space-2);
|
|
1268
1277
|
font-weight: 500;
|
|
1269
|
-
|
|
1278
|
+
/* Explicit green for success - readable on white */
|
|
1279
|
+
color: #16a34a !important;
|
|
1280
|
+
}
|
|
1281
|
+
|
|
1282
|
+
/* Completion header - dark mode */
|
|
1283
|
+
.sui-root.dark .sui-completion-header {
|
|
1284
|
+
color: #22c55e !important;
|
|
1270
1285
|
}
|
|
1271
1286
|
|
|
1272
1287
|
.sui-completion-components {
|
|
@@ -1278,48 +1293,81 @@
|
|
|
1278
1293
|
|
|
1279
1294
|
.sui-completion-tag {
|
|
1280
1295
|
padding: 0.125rem var(--space-2);
|
|
1281
|
-
|
|
1282
|
-
|
|
1296
|
+
/* Explicit blue colors - readable tag styling */
|
|
1297
|
+
background: #eff6ff !important;
|
|
1298
|
+
color: #2563eb !important;
|
|
1283
1299
|
border-radius: var(--radius-full);
|
|
1284
1300
|
font-size: 0.75rem;
|
|
1285
1301
|
font-family: var(--font-mono);
|
|
1286
1302
|
}
|
|
1287
1303
|
|
|
1304
|
+
/* Completion tag - dark mode */
|
|
1305
|
+
.sui-root.dark .sui-completion-tag {
|
|
1306
|
+
background: #1e3a5f !important;
|
|
1307
|
+
color: #60a5fa !important;
|
|
1308
|
+
}
|
|
1309
|
+
|
|
1288
1310
|
.sui-completion-metrics {
|
|
1289
1311
|
display: flex;
|
|
1290
1312
|
gap: var(--space-4);
|
|
1291
1313
|
margin-top: var(--space-3);
|
|
1292
1314
|
font-size: 0.8125rem;
|
|
1293
|
-
|
|
1315
|
+
/* Explicit muted gray */
|
|
1316
|
+
color: #71717a !important;
|
|
1317
|
+
}
|
|
1318
|
+
|
|
1319
|
+
/* Completion metrics - dark mode */
|
|
1320
|
+
.sui-root.dark .sui-completion-metrics {
|
|
1321
|
+
color: #a1a1aa !important;
|
|
1294
1322
|
}
|
|
1295
1323
|
|
|
1296
1324
|
/* Fallback story styling (error placeholder was created) */
|
|
1297
1325
|
.sui-completion-fallback .sui-completion-header {
|
|
1298
|
-
color:
|
|
1326
|
+
color: #ca8a04 !important; /* Amber/warning color */
|
|
1327
|
+
}
|
|
1328
|
+
|
|
1329
|
+
.sui-root.dark .sui-completion-fallback .sui-completion-header {
|
|
1330
|
+
color: #facc15 !important; /* Lighter amber for dark mode */
|
|
1299
1331
|
}
|
|
1300
1332
|
|
|
1301
1333
|
.sui-completion-fallback-warning {
|
|
1302
1334
|
margin-top: var(--space-2);
|
|
1303
1335
|
padding: var(--space-2) var(--space-3);
|
|
1304
|
-
background:
|
|
1336
|
+
background: #fef9c3 !important; /* Light amber background */
|
|
1305
1337
|
border-radius: var(--radius-md);
|
|
1306
1338
|
font-size: 0.8125rem;
|
|
1307
1339
|
}
|
|
1308
1340
|
|
|
1341
|
+
.sui-root.dark .sui-completion-fallback-warning {
|
|
1342
|
+
background: #422006 !important; /* Dark amber background */
|
|
1343
|
+
}
|
|
1344
|
+
|
|
1309
1345
|
.sui-completion-fallback-warning strong {
|
|
1310
1346
|
display: block;
|
|
1311
|
-
color:
|
|
1347
|
+
color: #ca8a04 !important; /* Amber text */
|
|
1312
1348
|
margin-bottom: var(--space-1);
|
|
1313
1349
|
}
|
|
1314
1350
|
|
|
1351
|
+
.sui-root.dark .sui-completion-fallback-warning strong {
|
|
1352
|
+
color: #facc15 !important;
|
|
1353
|
+
}
|
|
1354
|
+
|
|
1315
1355
|
.sui-completion-fallback-warning p {
|
|
1316
1356
|
margin: 0;
|
|
1317
|
-
color:
|
|
1357
|
+
color: #71717a !important; /* Muted gray */
|
|
1358
|
+
}
|
|
1359
|
+
|
|
1360
|
+
.sui-root.dark .sui-completion-fallback-warning p {
|
|
1361
|
+
color: #a1a1aa !important;
|
|
1318
1362
|
}
|
|
1319
1363
|
|
|
1320
1364
|
/* Error completion styling (generation failed completely) */
|
|
1321
1365
|
.sui-completion-error .sui-completion-header {
|
|
1322
|
-
color:
|
|
1366
|
+
color: #dc2626 !important; /* Red for errors */
|
|
1367
|
+
}
|
|
1368
|
+
|
|
1369
|
+
.sui-root.dark .sui-completion-error .sui-completion-header {
|
|
1370
|
+
color: #f87171 !important; /* Lighter red for dark mode */
|
|
1323
1371
|
}
|
|
1324
1372
|
|
|
1325
1373
|
/* ============================================
|