Skip to content

Commit 41f49b8

Browse files
committed
revert: roll back code block styling changes
Reverting commits 6e3b1cd and bb2ab11 as the code block styling improvements didn't work as expected and were causing visual issues.
1 parent 6e3b1cd commit 41f49b8

File tree

4 files changed

+12
-114
lines changed

4 files changed

+12
-114
lines changed

src/demo/FilterPresetsShowcase.module.css

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,6 @@
5050
border-radius: 0 0 4px 4px;
5151
}
5252

53-
/* Ensure proper spacing for code blocks within tabs */
54-
.tab-content > div > div {
55-
margin-bottom: 1.5rem;
56-
}
57-
58-
.tab-content > div > div:last-child {
59-
margin-bottom: 0;
60-
}
61-
6253
.api-playground {
6354
margin-top: 2rem;
6455
}
@@ -137,33 +128,3 @@
137128
color: #666;
138129
font-size: 0.9rem;
139130
}
140-
141-
.documentation-section {
142-
margin-top: 2rem;
143-
}
144-
145-
.documentation-section h3 {
146-
margin-bottom: 1rem;
147-
font-size: 1.5rem;
148-
color: #333;
149-
}
150-
151-
.documentation-section p {
152-
margin-bottom: 1rem;
153-
color: #666;
154-
}
155-
156-
.playground-editor {
157-
margin-top: 1rem;
158-
}
159-
160-
/* Ensure code blocks have proper contrast within documentation section */
161-
.documentation-section > div {
162-
margin: 1rem 0;
163-
}
164-
165-
/* Style the code editor textarea to match the theme */
166-
.code-editor {
167-
background: #1e1e1e !important;
168-
color: #d4d4d4 !important;
169-
}

src/demo/FilterPresetsShowcase.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ const FilterPresetsShowcase: React.FC = () => {
132132
</AnchorHeading>
133133
<CodeBlock
134134
language="typescript"
135-
variant="light"
136135
code={`
137136
// Enable presets with basic configuration
138137
<QuickFilterDropdown
@@ -166,7 +165,6 @@ const FilterPresetsShowcase: React.FC = () => {
166165
</AnchorHeading>
167166
<CodeBlock
168167
language="typescript"
169-
variant="light"
170168
code={`
171169
// Use the useFilterPresets hook for programmatic control
172170
const {
@@ -204,7 +202,6 @@ const handleLoad = (presetId: string) => {
204202
</AnchorHeading>
205203
<CodeBlock
206204
language="typescript"
207-
variant="light"
208205
code={`
209206
// Configure storage options
210207
const storageConfig = {
@@ -223,7 +220,6 @@ const storageConfig = {
223220
</AnchorHeading>
224221
<CodeBlock
225222
language="typescript"
226-
variant="light"
227223
code={`
228224
// Provide custom UI components
229225
<QuickFilterDropdown
@@ -261,7 +257,6 @@ const storageConfig = {
261257
</AnchorHeading>
262258
<CodeBlock
263259
language="typescript"
264-
variant="light"
265260
code={`
266261
// Listen to preset events
267262
<QuickFilterDropdown

src/demo/components/CodeBlock.tsx

Lines changed: 5 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React, { useState } from "react";
22
import { PrismLight as SyntaxHighlighter } from "react-syntax-highlighter";
33
import { vscDarkPlus } from "react-syntax-highlighter/dist/esm/styles/prism";
4-
import { vs } from "react-syntax-highlighter/dist/esm/styles/prism";
54

65
// Import only the languages we need
76
import typescript from "react-syntax-highlighter/dist/esm/languages/prism/typescript";
@@ -33,7 +32,7 @@ interface CodeBlockProps {
3332
| "css";
3433
showLineNumbers?: boolean;
3534
showCopyButton?: boolean;
36-
variant?: "default" | "hero" | "light";
35+
variant?: "default" | "hero";
3736
}
3837

3938
export const CodeBlock: React.FC<CodeBlockProps> = ({
@@ -44,52 +43,6 @@ export const CodeBlock: React.FC<CodeBlockProps> = ({
4443
variant = "default",
4544
}) => {
4645
const [copied, setCopied] = useState(false);
47-
const [detectedTheme, setDetectedTheme] = useState<"light" | "dark">("dark");
48-
49-
// Detect the actual theme based on background
50-
React.useEffect(() => {
51-
if (variant !== "default") return;
52-
53-
const checkTheme = () => {
54-
const body = document.body;
55-
const computedStyle = window.getComputedStyle(body);
56-
const bgColor = computedStyle.backgroundColor;
57-
58-
// Check if background is light
59-
if (bgColor === "rgb(255, 255, 255)" || bgColor === "white") {
60-
setDetectedTheme("light");
61-
} else {
62-
// Check the nearest parent with a background
63-
let foundDarkBg = false;
64-
65-
// Look for elements with dark backgrounds
66-
const darkElements = document.querySelectorAll(
67-
".bg-gray-950, .bg-gray-900, .min-h-screen",
68-
);
69-
darkElements.forEach((el) => {
70-
const elBg = window.getComputedStyle(el).backgroundColor;
71-
if (elBg && elBg !== "rgba(0, 0, 0, 0)" && elBg !== "transparent") {
72-
// Parse RGB values
73-
const match = elBg.match(/\d+/g);
74-
if (match) {
75-
const [r, g, b] = match.map(Number);
76-
// If all values are low, it's a dark background
77-
if (r < 50 && g < 50 && b < 50) {
78-
foundDarkBg = true;
79-
}
80-
}
81-
}
82-
});
83-
84-
setDetectedTheme(foundDarkBg ? "dark" : "light");
85-
}
86-
};
87-
88-
checkTheme();
89-
// Re-check on window resize or other changes
90-
window.addEventListener("resize", checkTheme);
91-
return () => window.removeEventListener("resize", checkTheme);
92-
}, [variant]);
9346

9447
const handleCopy = async () => {
9548
try {
@@ -110,21 +63,12 @@ export const CodeBlock: React.FC<CodeBlockProps> = ({
11063
// Always disable line numbers for now
11164
const shouldShowLineNumbers = false;
11265

113-
// Use light theme for light variant or detected light theme
114-
const isLightTheme =
115-
variant === "light" || (variant === "default" && detectedTheme === "light");
116-
const theme = isLightTheme ? vs : vscDarkPlus;
117-
11866
return (
11967
<div className="relative group">
12068
{showCopyButton && variant !== "hero" && (
12169
<button
12270
onClick={handleCopy}
123-
className={`absolute top-3 right-3 px-3 py-1 ${
124-
isLightTheme
125-
? "bg-gray-100/80 hover:bg-gray-200/90 text-gray-700 border-gray-300/50"
126-
: "bg-gray-700/50 hover:bg-gray-600/70 text-gray-300 border-gray-600/50"
127-
} backdrop-blur-sm rounded text-xs border transition-all duration-200 z-10 ${
71+
className={`absolute top-3 right-3 px-3 py-1 bg-gray-700/50 hover:bg-gray-600/70 backdrop-blur-sm rounded text-xs text-gray-300 border border-gray-600/50 transition-all duration-200 z-10 ${
12872
copied ? "opacity-100" : "opacity-50 group-hover:opacity-100"
12973
}`}
13074
title="Copy code"
@@ -170,9 +114,7 @@ export const CodeBlock: React.FC<CodeBlockProps> = ({
170114
className={`overflow-x-auto rounded-lg shadow-lg ${
171115
variant === "hero"
172116
? "bg-gray-900/80 border border-gray-700/30"
173-
: isLightTheme
174-
? "bg-gray-50 border border-gray-200"
175-
: "bg-gray-900/90 border border-gray-700/50"
117+
: "bg-gray-900/90 border border-gray-700/50"
176118
}`}
177119
>
178120
<div style={{ position: "relative" }}>
@@ -200,7 +142,7 @@ export const CodeBlock: React.FC<CodeBlockProps> = ({
200142
)}
201143
<SyntaxHighlighter
202144
language={language}
203-
style={theme}
145+
style={vscDarkPlus}
204146
showLineNumbers={false}
205147
customStyle={{
206148
margin: 0,
@@ -211,7 +153,7 @@ export const CodeBlock: React.FC<CodeBlockProps> = ({
211153
: variant === "hero"
212154
? "1.25rem"
213155
: "1rem",
214-
background: isLightTheme ? "#fafafa" : "transparent",
156+
background: "transparent",
215157
fontSize: variant === "hero" ? "0.9375rem" : "0.875rem",
216158
lineHeight: 1.7,
217159
fontFamily:

src/demo/version-info.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
{
22
"version": "0.1.0",
33
"git": {
4-
"commitHash": "bb2ab115052487299a10ab2826049fc73df5f2e0",
5-
"shortHash": "bb2ab11",
4+
"commitHash": "60841aabfe2d38be7c6b54f848f28ffb66463ca9",
5+
"shortHash": "60841aa",
66
"branch": "release/v0.1.1-rc2",
7-
"commitDate": "2025-07-07 22:38:13 -0500",
7+
"commitDate": "2025-07-07 13:42:13 -0500",
88
"latestTag": "v0.1.0",
9-
"commitsSinceTag": 79,
10-
"isDirty": false
9+
"commitsSinceTag": 73,
10+
"isDirty": true
1111
},
1212
"deployment": {
1313
"isPR": false,
1414
"prNumber": null,
1515
"isMainBranch": false,
1616
"deployPath": "ag-grid-react-components"
1717
},
18-
"buildTime": "2025-07-08T03:39:35.295Z",
19-
"displayVersion": "v0.1.0+79",
18+
"buildTime": "2025-07-08T00:46:11.232Z",
19+
"displayVersion": "v0.1.0+73",
2020
"displayLabel": "release/v0.1.1-rc2"
2121
}

0 commit comments

Comments
 (0)