Skip to content

Commit d986d83

Browse files
committed
Update colors in code block to our theme colors, remove code block from tab order
1 parent 361a05e commit d986d83

6 files changed

Lines changed: 32 additions & 25 deletions

File tree

‎src/components/Code/CodeTabs/client/__tests__/index.spec.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ describe('CodeTabs web component', () => {
124124
expect(tabButton, 'CodeTabs should render a tab button for a single named code block').toBeTruthy()
125125
expect(tabButton?.textContent).toBe('TypeScript')
126126
expect(
127-
tabButton?.className.includes('hover:text-gray-600'),
127+
tabButton?.className.includes('hover:text-content-active'),
128128
'Single-tab UI should not change text color on hover'
129129
).toBe(false)
130130
})
@@ -159,12 +159,12 @@ describe('CodeTabs web component', () => {
159159
expect(inactiveButton).toBeTruthy()
160160

161161
expect(
162-
activeButton?.className.includes('hover:text-gray-600'),
162+
activeButton?.className.includes('hover:text-content-active'),
163163
'Active tab should not change text color on hover'
164164
).toBe(false)
165165

166166
expect(
167-
inactiveButton?.className.includes('hover:text-gray-600'),
167+
inactiveButton?.className.includes('hover:text-content-active'),
168168
'Inactive tab should change text color on hover'
169169
).toBe(true)
170170
})

‎src/components/Code/CodeTabs/client/index.ts‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ class CodeTabsElement extends HTMLElement {
120120
private buildUi(args: { shouldRenderTabs: boolean; labels: string[] }): void {
121121
const header = document.createElement('div')
122122
header.className =
123-
'flex w-full min-w-0 items-center justify-between border-b border-gray-200 bg-gray-50'
123+
'flex w-full min-w-0 items-center justify-between bg-page-base-offset'
124124

125125
const copyButton = this.createCopyButton()
126126

@@ -136,7 +136,7 @@ class CodeTabsElement extends HTMLElement {
136136

137137
const button = document.createElement('button')
138138
button.type = 'button'
139-
button.className = 'inline-block px-2 py-1 m-2 text-gray-400'
139+
button.className = 'inline-block px-2 py-1 m-2 text-content-offset'
140140
button.textContent = tabLabel
141141
button.setAttribute('data-code-tabs-button', String(index))
142142

@@ -168,7 +168,7 @@ class CodeTabsElement extends HTMLElement {
168168
const button = document.createElement('button')
169169
button.type = 'button'
170170
button.className =
171-
'flex shrink-0 items-center gap-2 mr-2 px-3 py-2 text-gray-600 hover:text-gray-900 border-l border-gray-200'
171+
'flex shrink-0 items-center gap-2 mr-2 px-3 py-2 text-content hover:text-content-active'
172172
button.setAttribute('aria-label', tooltip)
173173
button.title = tooltip
174174

@@ -203,18 +203,18 @@ class CodeTabsElement extends HTMLElement {
203203

204204
this.tabButtons.forEach((btn, i) => {
205205
const isActive = i === index
206-
btn.classList.toggle('text-gray-900', isActive)
207-
btn.classList.toggle('text-gray-400', !isActive)
206+
btn.classList.toggle('text-content', isActive)
207+
btn.classList.toggle('text-content-offset', !isActive)
208208

209209
// Hover color behavior:
210210
// - Single-tab UI: no hover color change.
211211
// - Multi-tab UI: inactive tabs change color on hover; active tab does not.
212212
if (!this.isInteractiveTabs) {
213-
btn.classList.remove('hover:text-gray-600')
213+
btn.classList.remove('hover:text-content-active')
214214
return
215215
}
216216

217-
btn.classList.toggle('hover:text-gray-600', !isActive)
217+
btn.classList.toggle('hover:text-content-active', !isActive)
218218
})
219219
}
220220

‎src/content/articles/demo/index.mdx‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ This `console.log("hello, world!")` statement is inline code.
2121
console.log("hello, world!")
2222
```
2323

24-
```bash
24+
```bash [g8:BASH]
2525
#!/bin/bash
2626

2727
LOG_DIR="/var/log/myapp"
@@ -55,6 +55,10 @@ cleanup_old_files() {
5555
}
5656
```
5757

58+
```text
59+
A text code block
60+
```
61+
5862
#### Grouped Code Tabs
5963

6064
The following examples substitute apostrophes for backticks so that they're not rendered to code blocks.
@@ -263,9 +267,9 @@ features:
263267

264268
#### Add a title to the code block
265269

266-
You can add a title to the code block by adding a `title` prop to the code block like `js title="script.js"`:
270+
You can add a title to the code block by using it for the name in the group block like `[g7:/src/script.js]`:
267271

268-
```js title="script.js"
272+
```js [g7:/src/script.js]
269273
console.log('Hello World')
270274
```
271275

‎src/lib/markdown/plugins/rehype-shiki/index.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,6 @@ const rehypeShiki: Plugin<[RehypeShikiOptions], Root> = (options: RehypeShikiOpt
304304
highlightedPre.properties[key] = value as never
305305
}
306306

307-
highlightedPre.properties['tabIndex'] = 0
308307
highlightedPre.properties['data-language'] = replacement.lang
309308

310309
highlightedPre.properties['className'] = mergeClassNames(

‎src/styles/shiki.css‎

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,28 @@
1414
pre.shiki code {
1515
counter-increment: step calc(var(--start, 1) - 1);
1616
counter-reset: step;
17-
/* Prevent Shiki's inter-line text nodes ("\n") from becoming visual blank lines. */
1817
white-space: normal;
1918
}
2019

20+
/* Prevent Shiki's inter-line text nodes ("\n") from becoming visual blank lines. */
2121
pre.shiki code .line {
2222
display: block;
23-
position: relative;
24-
padding-left: 3rem;
25-
/* Ensure empty source lines still take up vertical space for line numbers. */
2623
min-height: 1.25em;
27-
/* Allow long tokens to wrap inside the code column. */
28-
white-space: pre-wrap;
2924
overflow-wrap: anywhere;
25+
padding-left: 3rem;
26+
position: relative;
27+
white-space: pre-wrap;
3028
}
3129

3230
pre.shiki code .line::before {
3331
color: rgb(from var(--color-content-active) r g b / 40%);
3432
content: counter(step);
3533
counter-increment: step;
36-
position: absolute;
3734
left: 0;
38-
top: 0;
39-
width: 2rem;
35+
position: absolute;
4036
text-align: right;
37+
top: 0;
38+
width: 1.5rem;
4139
}
4240

4341
/* Query based dark mode */

‎src/styles/typography.css‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,10 @@
172172

173173
h1,
174174
h2,
175-
h3 {
175+
h3,
176+
h4 {
176177
font-family: var(--font-family-serif);
177-
font-weight: var(--font-weight-medium);
178+
font-weight: var(--font-weight-bold);
178179
text-rendering: optimizelegibility;
179180
}
180181

@@ -193,6 +194,11 @@
193194
font-size: var(--font-size-xl);
194195
}
195196

197+
h4,
198+
.h4 {
199+
font-size: var(--font-size-lg);
200+
}
201+
196202
@media (width <= 26em) {
197203
h1,
198204
.h1 {

0 commit comments

Comments
 (0)