Skip to content

Commit 16a6df0

Browse files
committed
Fix Chromatic compatibility by removing styled shim
1 parent f383a85 commit 16a6df0

30 files changed

+37
-45
lines changed

.storybook/main.ts

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,25 @@ const config: StorybookConfig = {
1919
"options": {}
2020
},
2121
async viteFinal(config: UserConfig) {
22-
// Filter out Storybook's default React plugin
22+
// Remove any existing Vite React plugins that Storybook registers
2323
config.plugins = (config.plugins || []).filter((plugin) => {
24-
return !(
25-
Array.isArray(plugin) &&
26-
plugin[0]?.name?.includes('vite:react')
27-
);
24+
if (!plugin) return true;
25+
const pluginName = Array.isArray(plugin) ? plugin[0]?.name : plugin.name;
26+
return !pluginName?.includes('vite:react');
2827
});
2928

30-
// Add React plugin with emotion configuration
31-
// Force Babel to process all files (not just JSX) to ensure emotion transforms work
29+
// Re-register the React plugin with Emotion configuration
3230
config.plugins.push(
3331
react({
34-
include: '**/*.{jsx,tsx,ts,js}',
32+
exclude: [/\.stories\.(t|j)sx?$/, /node_modules/],
3533
jsxImportSource: '@emotion/react',
3634
babel: {
3735
plugins: ['@emotion/babel-plugin'],
3836
},
3937
})
4038
);
4139

42-
// Optimize emotion dependencies
40+
// Pre-bundle Emotion packages to reduce cold start time
4341
config.optimizeDeps = {
4442
...config.optimizeDeps,
4543
include: [
@@ -50,13 +48,7 @@ const config: StorybookConfig = {
5048
],
5149
};
5250

53-
// Ensure emotion packages are resolved correctly
54-
config.resolve = {
55-
...config.resolve,
56-
dedupe: ['@emotion/react', '@emotion/styled', '@emotion/cache'],
57-
};
58-
5951
return config;
6052
},
6153
};
62-
export default config;
54+
export default config;

src/components/AIView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useState, useEffect, useCallback } from "react";
2-
import styled from "@/styles/styled";
2+
import styled from "@emotion/styled";
33
import { MessageRenderer } from "./Messages/MessageRenderer";
44
import { InterruptedBarrier } from "./Messages/ChatBarrier/InterruptedBarrier";
55
import { StreamingBarrier } from "./Messages/ChatBarrier/StreamingBarrier";

src/components/ChatInput.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useState, useRef, useCallback, useEffect } from "react";
2-
import styled from "@/styles/styled";
2+
import styled from "@emotion/styled";
33
import { CommandSuggestions, COMMAND_SUGGESTION_KEYS } from "./CommandSuggestions";
44
import type { Toast } from "./ChatInputToast";
55
import { ChatInputToast, SolutionLabel } from "./ChatInputToast";

src/components/ChatInputToast.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { ReactNode } from "react";
22
import React, { useEffect, useCallback } from "react";
3-
import styled from "@/styles/styled";
3+
import styled from "@emotion/styled";
44
import { keyframes, css } from "@emotion/react";
55

66
const slideIn = keyframes`

src/components/ChatMetaSidebar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from "react";
2-
import styled from "@/styles/styled";
2+
import styled from "@emotion/styled";
33
import { usePersistedState } from "@/hooks/usePersistedState";
44
import { CostsTab } from "./ChatMetaSidebar/CostsTab";
55
import { ToolsTab } from "./ChatMetaSidebar/ToolsTab";

src/components/ChatMetaSidebar/CostsTab.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from "react";
2-
import styled from "@/styles/styled";
2+
import styled from "@emotion/styled";
33
import { useChatContext } from "@/contexts/ChatContext";
44
import { TooltipWrapper, Tooltip, HelpIndicator } from "../Tooltip";
55
import { getModelStats } from "@/utils/tokens/modelStats";

src/components/ChatMetaSidebar/ToolsTab.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from "react";
2-
import styled from "@/styles/styled";
2+
import styled from "@emotion/styled";
33

44
const PlaceholderContainer = styled.div`
55
color: #888888;

src/components/CommandSuggestions.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useState, useEffect } from "react";
2-
import styled from "@/styles/styled";
2+
import styled from "@emotion/styled";
33
import type { SlashSuggestion } from "@/utils/slashCommands/types";
44

55
// Export the keys that CommandSuggestions handles

src/components/ErrorBoundary.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { ReactNode } from "react";
22
import React, { Component } from "react";
3-
import styled from "@/styles/styled";
3+
import styled from "@emotion/styled";
44

55
const ErrorContainer = styled.div`
66
padding: 20px;

src/components/ErrorMessage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from "react";
2-
import styled from "@/styles/styled";
2+
import styled from "@emotion/styled";
33

44
const ErrorContainer = styled.div`
55
background-color: var(--color-error-bg, #fee);

0 commit comments

Comments
 (0)