Skip to content

Commit 782729f

Browse files
committed
chore: even bigger changes
1 parent 8c4daeb commit 782729f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+540
-1279
lines changed
Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
import { StrictMode } from 'react'
22
import { createRoot } from 'react-dom/client'
33
import { TanStackDevtools } from '@tanstack/react-devtools'
4-
import { createA11yDevtoolsReactPlugin } from '@tanstack/devtools-a11y/react'
4+
import { a11yDevtoolsPlugin } from '@tanstack/devtools-a11y/react'
55

66
import App from './App'
77

88
createRoot(document.getElementById('root')!).render(
99
<StrictMode>
1010
<App />
11-
12-
<TanStackDevtools
13-
plugins={[createA11yDevtoolsReactPlugin({ runOnMount: false })[0]()]}
14-
/>
11+
<TanStackDevtools plugins={[a11yDevtoolsPlugin()]} />§
1512
</StrictMode>,
1613
)

packages/devtools-a11y/src/core/A11yDevtoolsCore.tsx

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

packages/devtools-a11y/src/ui/A11yIssueCard.tsx renamed to packages/devtools-a11y/src/core/components/IssueCard.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
import { For, Show } from 'solid-js'
44
import { Button } from '@tanstack/devtools-ui'
5-
import { useStyles } from './styles'
6-
import type { A11yIssue, SeverityThreshold } from '../types'
5+
import { useStyles } from '../styles/styles'
6+
7+
// types
8+
import type { A11yIssue, SeverityThreshold } from '../types/types'
79

810
interface A11yIssueCardProps {
911
issue: A11yIssue
@@ -15,7 +17,6 @@ interface A11yIssueCardProps {
1517

1618
export function A11yIssueCard(props: A11yIssueCardProps) {
1719
const selector = () => props.issue.nodes[0]?.selector || 'unknown'
18-
1920
const styles = useStyles()
2021

2122
return (
@@ -30,9 +31,11 @@ export function A11yIssueCard(props: A11yIssueCardProps) {
3031
<div class={styles().issueMain}>
3132
<div class={styles().issueTitleRow}>
3233
<span class={styles().dot(props.impact)} />
34+
3335
<span>{props.issue.ruleId}</span>
3436
</div>
3537
<p class={styles().issueMessage}>{props.issue.message}</p>
38+
3639
<div class={styles().selector}>{selector()}</div>
3740
</div>
3841

@@ -46,6 +49,7 @@ export function A11yIssueCard(props: A11yIssueCardProps) {
4649
>
4750
Learn more
4851
</a>
52+
4953
<Button
5054
variant="secondary"
5155
ghost

packages/devtools-a11y/src/ui/A11yIssueList.tsx renamed to packages/devtools-a11y/src/core/components/IssueList.tsx

Lines changed: 69 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,74 @@
22

33
import { For, Show } from 'solid-js'
44
import { useAllyContext } from '../contexts/allyContext'
5-
import { IMPACTS } from './panelUtils'
6-
import { SEVERITY_LABELS, useStyles } from './styles'
7-
import { A11yIssueCard } from './A11yIssueCard'
5+
import {
6+
SEVERITY_LABELS,
7+
clearHighlights,
8+
highlightAllIssues,
9+
highlightElement,
10+
scrollToElement,
11+
} from '../utils/ui.utils'
12+
import { IMPACTS } from '../utils/ally-audit.utils'
13+
import { useStyles } from '../styles/styles'
14+
import { A11yIssueCard } from './IssueCard'
15+
16+
// types
17+
import type { Signal } from 'solid-js'
818

919
interface A11yIssueListProps {
10-
selectedIssueId: string | null
11-
onIssueClick: (issueId: string) => void
12-
onDisableRule: (ruleId: string) => void
20+
selectedIssueSignal: Signal<string>
1321
}
1422

1523
export function A11yIssueList(props: A11yIssueListProps) {
24+
const [selectedIssueId, setSelectedIssueId] = props.selectedIssueSignal
25+
26+
// hooks
1627
const styles = useStyles()
28+
const { filteredIssues, audit, impactKey, setImpactKey, config, setConfig } =
29+
useAllyContext()
30+
31+
// handlers
32+
const handleIssueClick = (issueId: string) => {
33+
if (selectedIssueId() === issueId) {
34+
setSelectedIssueId('')
35+
clearHighlights()
36+
37+
if (config.showOverlays && audit && filteredIssues.length > 0) {
38+
highlightAllIssues(filteredIssues())
39+
}
40+
41+
return
42+
}
43+
44+
setSelectedIssueId(issueId)
45+
clearHighlights()
46+
47+
const issue = audit?.issues.find((i) => i.id === issueId)
48+
if (!issue || issue.nodes.length === 0) return
49+
50+
let scrolled = false
51+
for (const node of issue.nodes) {
52+
const selector = node.selector
53+
if (!selector) continue
54+
55+
try {
56+
const el = document.querySelector(selector)
57+
if (el) {
58+
if (!scrolled) {
59+
scrollToElement(selector)
60+
scrolled = true
61+
}
1762

18-
const { filteredIssues, audit, impactKey, setImpactKey } = useAllyContext()
63+
highlightElement(selector, issue.impact, {
64+
showTooltip: true,
65+
ruleId: issue.ruleId,
66+
})
67+
}
68+
} catch (error) {
69+
console.warn('[A11y Panel] Invalid selector:', selector, error)
70+
}
71+
}
72+
}
1973

2074
return (
2175
<div>
@@ -69,9 +123,14 @@ export function A11yIssueList(props: A11yIssueListProps) {
69123
<A11yIssueCard
70124
issue={issue}
71125
impact={impact}
72-
selected={props.selectedIssueId === issue.id}
73-
onSelect={() => props.onIssueClick(issue.id)}
74-
onDisableRule={props.onDisableRule}
126+
selected={selectedIssueId() === issue.id}
127+
onSelect={() => handleIssueClick(issue.id)}
128+
onDisableRule={() =>
129+
setConfig('disabledRules', [
130+
...config.disabledRules,
131+
issue.ruleId,
132+
])
133+
}
75134
/>
76135
)}
77136
</For>

0 commit comments

Comments
 (0)