Skip to content

Commit 0a47bf4

Browse files
committed
fix(review): address remaining codex feedback
1 parent ccd898a commit 0a47bf4

12 files changed

Lines changed: 162 additions & 87 deletions

File tree

assets/main.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,9 @@
8585

8686
body {
8787
@apply bg-background text-foreground antialiased;
88-
min-width: 520px;
88+
min-width: 0;
89+
margin: 0;
8990
padding: 16px;
90-
overflow-x: hidden;
9191
overflow-y: hidden;
9292
}
9393
}

entrypoints/devtools-panel/devtools-panel.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ const PropertyNode = defineComponent({
252252
variant="ghost"
253253
size="icon"
254254
data-testid="theme-toggle"
255-
:aria-label="isDark ? 'Switch to light theme' : 'Switch to dark theme'"
255+
:aria-label="isDark ? t('switchToLightTheme') : t('switchToDarkTheme')"
256256
@click="handleToggleTheme"
257257
>
258258
<Sun v-if="isDark" class="h-3.5 w-3.5" />
@@ -348,7 +348,8 @@ const PropertyNode = defineComponent({
348348
variant="ghost"
349349
size="icon"
350350
class="absolute right-0 top-1/2 -translate-y-1/2"
351-
aria-label="Clear filter"
351+
:aria-label="t('clearFilter')"
352+
:title="t('clearFilter')"
352353
@click="inputValue = ''"
353354
>
354355
<X class="h-4 w-4" />

entrypoints/devtools-panel/lang.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ export type MessageKey =
3131
| 'total'
3232
| 'undefinedStyleValue'
3333
| 'copyInfo'
34+
| 'clearFilter'
3435
| 'inputPlaceholder'
36+
| 'switchToDarkTheme'
37+
| 'switchToLightTheme'
3538
| 'waitingSelection'
3639

3740
const messages = {

entrypoints/devtools-panel/utils/diff.node-test.ts

Lines changed: 0 additions & 38 deletions
This file was deleted.

entrypoints/devtools-panel/utils/locale.node-test.ts

Lines changed: 0 additions & 21 deletions
This file was deleted.

entrypoints/devtools-panel/utils/theme.node-test.ts

Lines changed: 0 additions & 24 deletions
This file was deleted.

public/_locales/en/messages.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@
88
"switchLanguage": {
99
"message": "Switch language"
1010
},
11+
"switchToDarkTheme": {
12+
"message": "Switch to dark theme"
13+
},
14+
"switchToLightTheme": {
15+
"message": "Switch to light theme"
16+
},
1117
"selection": {
1218
"message": "Selection"
1319
},
@@ -86,6 +92,9 @@
8692
"copyInfo": {
8793
"message": "Copy Success"
8894
},
95+
"clearFilter": {
96+
"message": "Clear filter"
97+
},
8998
"inputPlaceholder": {
9099
"message": "Please enter the css property you want to view"
91100
}

public/_locales/zh_CN/messages.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@
88
"switchLanguage": {
99
"message": "切换语言"
1010
},
11+
"switchToDarkTheme": {
12+
"message": "切换到深色主题"
13+
},
14+
"switchToLightTheme": {
15+
"message": "切换到浅色主题"
16+
},
1117
"selection": {
1218
"message": "选择"
1319
},
@@ -86,6 +92,9 @@
8692
"copyInfo": {
8793
"message": "复制成功"
8894
},
95+
"clearFilter": {
96+
"message": "清空筛选"
97+
},
8998
"inputPlaceholder": {
9099
"message": "请输入需要查看的 css 属性"
91100
}

tests/e2e/devtools-panel.spec.ts

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,62 @@ test('renders the built DevTools panel shell', async ({ page }) => {
224224
}
225225
})
226226

227+
test('uses localized accessible labels for icon controls', async ({ page }) => {
228+
test.skip(!existsSync(panelPath), 'Run `pnpm build:chrome` before this E2E test.')
229+
const server = await serveOutputDir()
230+
231+
try {
232+
await mockSystemTheme(page, 'light')
233+
await page.addInitScript(() => {
234+
localStorage.setItem('css-diff-locale', 'zh_CN')
235+
localStorage.setItem('css-diff-theme', 'light')
236+
})
237+
await mockExtensionApi(page)
238+
await page.goto(server.url)
239+
240+
await expect(page.getByRole('button', { name: '切换到深色主题' })).toBeVisible()
241+
242+
await page.getByPlaceholder('请输入需要查看的 css 属性').fill('color')
243+
244+
await expect(page.getByRole('button', { name: '清空筛选' })).toBeVisible()
245+
await expect(page.getByRole('button', { name: 'Clear filter' })).toHaveCount(0)
246+
}
247+
finally {
248+
await server.close()
249+
}
250+
})
251+
252+
test('lets the panel shell fit narrow DevTools sidebars', async ({ page }) => {
253+
test.skip(!existsSync(panelPath), 'Run `pnpm build:chrome` before this E2E test.')
254+
const server = await serveOutputDir()
255+
256+
try {
257+
await page.setViewportSize({ width: 420, height: 720 })
258+
await mockExtensionApi(page)
259+
await page.goto(server.url)
260+
261+
const bodyLayout = await page.evaluate(() => {
262+
const style = window.getComputedStyle(document.body)
263+
264+
return {
265+
margin: style.margin,
266+
minWidth: style.minWidth,
267+
overflowX: style.overflowX,
268+
documentWidth: document.documentElement.scrollWidth,
269+
viewportWidth: window.innerWidth,
270+
}
271+
})
272+
273+
expect(bodyLayout.margin).toBe('0px')
274+
expect(bodyLayout.minWidth).toBe('0px')
275+
expect(bodyLayout.overflowX).not.toBe('hidden')
276+
expect(bodyLayout.documentWidth).toBeLessThanOrEqual(bodyLayout.viewportWidth)
277+
}
278+
finally {
279+
await server.close()
280+
}
281+
})
282+
227283
test('follows the system theme until the user toggles manually', async ({ page }) => {
228284
test.skip(!existsSync(panelPath), 'Run `pnpm build:chrome` before this E2E test.')
229285
const server = await serveOutputDir()

tests/unit/diffUtils.test.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { describe, expect, it } from 'vitest'
2+
import { getDiffValueClass, getDiffValueTone, UNDEFINED_STYLE_VALUE } from '../../entrypoints/devtools-panel/utils/diff'
3+
4+
describe('diff utilities', () => {
5+
it('marks only the second value in a changed row as changed', () => {
6+
const row = { property: 'display', left: 'block', right: 'flex', isDiff: true }
7+
8+
expect(getDiffValueTone(row, 'left')).toBe('muted')
9+
expect(getDiffValueTone(row, 'right')).toBe('changed')
10+
expect(getDiffValueClass(row, 'left')).toMatch(/\bbg-background\b/)
11+
expect(getDiffValueClass(row, 'right')).toMatch(/\bbg-red-50\b/)
12+
})
13+
14+
it('marks a missing first value as a special tag', () => {
15+
const row = { property: 'gap', left: UNDEFINED_STYLE_VALUE, right: '8px', isDiff: true }
16+
17+
expect(getDiffValueTone(row, 'left')).toBe('missing')
18+
expect(getDiffValueTone(row, 'right')).toBe('changed')
19+
expect(getDiffValueClass(row, 'left')).toMatch(/\bborder-dashed\b/)
20+
})
21+
22+
it('marks a missing second value as a special tag', () => {
23+
const row = { property: 'gap', left: '8px', right: UNDEFINED_STYLE_VALUE, isDiff: true }
24+
25+
expect(getDiffValueTone(row, 'left')).toBe('muted')
26+
expect(getDiffValueTone(row, 'right')).toBe('missing')
27+
expect(getDiffValueClass(row, 'left')).not.toMatch(/\bborder-dashed\b/)
28+
expect(getDiffValueClass(row, 'right')).toMatch(/\bborder-dashed\b/)
29+
})
30+
31+
it('keeps equal rows visually muted', () => {
32+
const row = { property: 'display', left: 'block', right: 'block', isDiff: false }
33+
34+
expect(getDiffValueTone(row, 'left')).toBe('muted')
35+
expect(getDiffValueTone(row, 'right')).toBe('muted')
36+
})
37+
})

0 commit comments

Comments
 (0)