Skip to content

Commit bb2ab11

Browse files
ryanrozichclaude
andcommitted
fix: improve code block styling in filter presets showcase
- Add light theme variant for CodeBlock component - Use light theme for code blocks in FilterPresetsShowcase - Fix background color conflicts between dark theme and white containers - Add proper styling for documentation sections - Update playground editor to use dark background 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 58b8300 commit bb2ab11

File tree

4 files changed

+67
-12
lines changed

4 files changed

+67
-12
lines changed

src/demo/FilterPresetsShowcase.module.css

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,15 @@
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+
5362
.api-playground {
5463
margin-top: 2rem;
5564
}
@@ -128,3 +137,33 @@
128137
color: #666;
129138
font-size: 0.9rem;
130139
}
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: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ const FilterPresetsShowcase: React.FC = () => {
132132
</AnchorHeading>
133133
<CodeBlock
134134
language="typescript"
135+
variant="light"
135136
code={`
136137
// Enable presets with basic configuration
137138
<QuickFilterDropdown
@@ -165,6 +166,7 @@ const FilterPresetsShowcase: React.FC = () => {
165166
</AnchorHeading>
166167
<CodeBlock
167168
language="typescript"
169+
variant="light"
168170
code={`
169171
// Use the useFilterPresets hook for programmatic control
170172
const {
@@ -202,6 +204,7 @@ const handleLoad = (presetId: string) => {
202204
</AnchorHeading>
203205
<CodeBlock
204206
language="typescript"
207+
variant="light"
205208
code={`
206209
// Configure storage options
207210
const storageConfig = {
@@ -220,6 +223,7 @@ const storageConfig = {
220223
</AnchorHeading>
221224
<CodeBlock
222225
language="typescript"
226+
variant="light"
223227
code={`
224228
// Provide custom UI components
225229
<QuickFilterDropdown
@@ -257,6 +261,7 @@ const storageConfig = {
257261
</AnchorHeading>
258262
<CodeBlock
259263
language="typescript"
264+
variant="light"
260265
code={`
261266
// Listen to preset events
262267
<QuickFilterDropdown

src/demo/components/CodeBlock.tsx

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
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";
45

56
// Import only the languages we need
67
import typescript from "react-syntax-highlighter/dist/esm/languages/prism/typescript";
@@ -32,7 +33,7 @@ interface CodeBlockProps {
3233
| "css";
3334
showLineNumbers?: boolean;
3435
showCopyButton?: boolean;
35-
variant?: "default" | "hero";
36+
variant?: "default" | "hero" | "light";
3637
}
3738

3839
export const CodeBlock: React.FC<CodeBlockProps> = ({
@@ -63,12 +64,20 @@ export const CodeBlock: React.FC<CodeBlockProps> = ({
6364
// Always disable line numbers for now
6465
const shouldShowLineNumbers = false;
6566

67+
// Use light theme for light variant
68+
const isLightTheme = variant === "light";
69+
const theme = isLightTheme ? vs : vscDarkPlus;
70+
6671
return (
6772
<div className="relative group">
6873
{showCopyButton && variant !== "hero" && (
6974
<button
7075
onClick={handleCopy}
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 ${
76+
className={`absolute top-3 right-3 px-3 py-1 ${
77+
isLightTheme
78+
? "bg-gray-100/80 hover:bg-gray-200/90 text-gray-700 border-gray-300/50"
79+
: "bg-gray-700/50 hover:bg-gray-600/70 text-gray-300 border-gray-600/50"
80+
} backdrop-blur-sm rounded text-xs border transition-all duration-200 z-10 ${
7281
copied ? "opacity-100" : "opacity-50 group-hover:opacity-100"
7382
}`}
7483
title="Copy code"
@@ -114,7 +123,9 @@ export const CodeBlock: React.FC<CodeBlockProps> = ({
114123
className={`overflow-x-auto rounded-lg shadow-lg ${
115124
variant === "hero"
116125
? "bg-gray-900/80 border border-gray-700/30"
117-
: "bg-gray-900/90 border border-gray-700/50"
126+
: isLightTheme
127+
? "bg-gray-50 border border-gray-200"
128+
: "bg-gray-900/90 border border-gray-700/50"
118129
}`}
119130
>
120131
<div style={{ position: "relative" }}>
@@ -142,7 +153,7 @@ export const CodeBlock: React.FC<CodeBlockProps> = ({
142153
)}
143154
<SyntaxHighlighter
144155
language={language}
145-
style={vscDarkPlus}
156+
style={theme}
146157
showLineNumbers={false}
147158
customStyle={{
148159
margin: 0,
@@ -153,7 +164,7 @@ export const CodeBlock: React.FC<CodeBlockProps> = ({
153164
: variant === "hero"
154165
? "1.25rem"
155166
: "1rem",
156-
background: "transparent",
167+
background: isLightTheme ? "#fafafa" : "transparent",
157168
fontSize: variant === "hero" ? "0.9375rem" : "0.875rem",
158169
lineHeight: 1.7,
159170
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": "60841aabfe2d38be7c6b54f848f28ffb66463ca9",
5-
"shortHash": "60841aa",
4+
"commitHash": "58b8300b8c41fccee809f106e3849b026c6dffad",
5+
"shortHash": "58b8300",
66
"branch": "release/v0.1.1-rc2",
7-
"commitDate": "2025-07-07 13:42:13 -0500",
7+
"commitDate": "2025-07-07 22:30:18 -0500",
88
"latestTag": "v0.1.0",
9-
"commitsSinceTag": 73,
10-
"isDirty": true
9+
"commitsSinceTag": 78,
10+
"isDirty": false
1111
},
1212
"deployment": {
1313
"isPR": false,
1414
"prNumber": null,
1515
"isMainBranch": false,
1616
"deployPath": "ag-grid-react-components"
1717
},
18-
"buildTime": "2025-07-08T00:46:11.232Z",
19-
"displayVersion": "v0.1.0+73",
18+
"buildTime": "2025-07-08T03:31:04.557Z",
19+
"displayVersion": "v0.1.0+78",
2020
"displayLabel": "release/v0.1.1-rc2"
2121
}

0 commit comments

Comments
 (0)