Skip to content

Commit e8bccdc

Browse files
authored
Merge pull request #41164 from github/repo-sync
Repo sync
2 parents 75394fe + b3c58fe commit e8bccdc

File tree

3 files changed

+45
-3
lines changed

3 files changed

+45
-3
lines changed

src/content-render/liquid/prompt.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ export const Prompt: LiquidTag = {
3838
const href: string = `https://github.com/copilot?prompt=${promptParam}`
3939
// Use murmur hash for deterministic ID (avoids hydration mismatch)
4040
const promptId: string = generatePromptId(contentString)
41-
return `<pre hidden id="${promptId}">${content}</pre><code>${content}</code><a href="${href}" target="_blank" class="tooltipped tooltipped-nw ml-1" aria-label="Run this prompt in Copilot Chat" aria-describedby="${promptId}" style="text-decoration:none;">${octicons.copilot.toSVG()}</a>`
41+
// Show long text on larger screens and short text on smaller screens (set via accessibility.scss)
42+
const promptLabelLong: string = 'Run this prompt in Copilot Chat'
43+
const promptLabelShort: string = 'Run prompt'
44+
return [
45+
`<code id="${promptId}">${content}</code>`,
46+
`<a href="${href}" target="_blank" class="tooltipped tooltipped-n ml-1 copilot-prompt-long" aria-label="${promptLabelLong}" aria-describedby="${promptId}" style="text-decoration:none;">${octicons.copilot.toSVG()}</a>`,
47+
`<a href="${href}" target="_blank" class="tooltipped tooltipped-n ml-1 copilot-prompt-short" aria-label="${promptLabelShort}" aria-describedby="${promptId}" style="text-decoration:none;">${octicons.copilot.toSVG()}</a>`,
48+
].join('')
4249
},
4350
}

src/content-render/stylesheets/accessibility.scss

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,26 @@
2121
}
2222
}
2323
}
24+
25+
/* Responsive tooltip text for Copilot prompt links */
26+
/* Show long tooltip text on small screens and up (544px+) */
27+
.copilot-prompt-long {
28+
display: none;
29+
visibility: hidden;
30+
31+
@media (min-width: 544px) {
32+
display: inline-block;
33+
visibility: visible;
34+
}
35+
}
36+
37+
/* Show short tooltip text only on extra small screens (below 544px) */
38+
.copilot-prompt-short {
39+
display: inline-block;
40+
visibility: visible;
41+
42+
@media (min-width: 544px) {
43+
display: none;
44+
visibility: hidden;
45+
}
46+
}

src/content-render/tests/prompt.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,22 @@ import { describe, expect, test } from 'vitest'
22
import { renderContent } from '@/content-render/index'
33

44
describe('prompt tag', () => {
5-
test('wraps content in <code> and appends svg', async () => {
5+
test('wraps content in <code> with ID and appends responsive svg links', async () => {
66
const input: string = 'Here is your prompt: {% prompt %}example prompt text{% endprompt %}.'
77
const output: string = await renderContent(input)
8-
expect(output).toContain('<code>example prompt text</code><a')
8+
9+
// Should have code element with ID
10+
expect(output).toContain('<code id="')
11+
expect(output).toContain('>example prompt text</code>')
12+
13+
// Should have two responsive anchor elements
14+
expect(output).toContain('copilot-prompt-long')
15+
expect(output).toContain('copilot-prompt-short')
16+
17+
// Should contain SVG icons
918
expect(output).toContain('<svg')
19+
20+
// Should have aria-describedby pointing to the code element ID
21+
expect(output).toContain('aria-describedby=')
1022
})
1123
})

0 commit comments

Comments
 (0)