Skip to content

Commit 9e599bc

Browse files
authored
A11y: Update note colors (github#39112)
1 parent 7437c5f commit 9e599bc

File tree

21 files changed

+266
-309
lines changed

21 files changed

+266
-309
lines changed

components/article/InArticlePicker.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export const InArticlePicker = ({
8383
// If you're in local development, you have the <ClientSideRefresh>
8484
// causing a XHR refresh of the content triggered by the Page Visibility
8585
// API (implemented in the uswSWR hook). That means that on the pages that
86-
// contain these `.extended-markdown` classes, any DOM changes we might
86+
// contain these `.ghd-tool` classes, any DOM changes we might
8787
// have previously made are lost and started over.
8888
useEffect(() => {
8989
let mounted = true

components/article/PlatformPicker.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const platforms = [
1717
// find all platform-specific *block* elements and hide or show as appropriate
1818
// example: {% mac %} block content {% endmac %}
1919
function showPlatformSpecificContent(platform: string) {
20-
const markdowns = Array.from(document.querySelectorAll<HTMLElement>('.extended-markdown'))
20+
const markdowns = Array.from(document.querySelectorAll<HTMLElement>('.ghd-tool'))
2121
markdowns
2222
.filter((el) => platforms.some((platform) => el.classList.contains(platform.value)))
2323
.forEach((el) => {

components/article/ToolPicker.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { InArticlePicker } from './InArticlePicker'
1212
// find all platform-specific *block* elements and hide or show as appropriate
1313
// example: {% webui %} block content {% endwebui %}
1414
function showToolSpecificContent(tool: string, supportedTools: Array<string>) {
15-
const markdowns = Array.from(document.querySelectorAll<HTMLElement>('.extended-markdown'))
15+
const markdowns = Array.from(document.querySelectorAll<HTMLElement>('.ghd-tool'))
1616
markdowns
1717
.filter((el) => supportedTools.some((tool) => el.classList.contains(tool)))
1818
.forEach((el) => {

components/ui/MarkdownContent/MarkdownContent.module.scss

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,4 @@
2828
}
2929
}
3030
}
31-
32-
[class~="note"],
33-
[class~="tip"],
34-
[class~="warning"],
35-
[class~="danger"] {
36-
// remove extra space under lists inside of notes
37-
ul,
38-
ol {
39-
margin-bottom: 0;
40-
}
41-
}
4231
}

components/ui/MarkdownContent/stylesheets/lists.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
margin-top: 1rem;
5050
}
5151

52-
[class~="extended-markdown"] {
52+
[class~="ghd-tool"] {
5353
margin-top: 1rem;
5454
}
5555

lib/get-mini-toc-items.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export default function getMiniTocItems(html, maxHeadingLevel = 2, headingScope
5151
const contents = { href, title: $(item).text().trim() }
5252
const headingLevel = parseInt($(item)[0].name.match(/\d+/)[0], 10) || 0 // the `2` from `h2`
5353

54-
const platform = $(item).parent('.extended-markdown').attr('class') || ''
54+
const platform = $(item).parent('.ghd-tool').attr('class') || ''
5555

5656
// track the most important heading level while we're looping through the items
5757
if (headingLevel < mostImportantHeadingLevel || mostImportantHeadingLevel === undefined) {

lib/page.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,14 +247,13 @@ class Page {
247247

248248
// set a flag so layout knows whether to render a mac/windows/linux switcher element
249249
this.detectedPlatforms = ['mac', 'windows', 'linux'].filter(
250-
(platform) =>
251-
html.includes(`extended-markdown ${platform}`) || html.includes(`platform-${platform}`),
250+
(platform) => html.includes(`ghd-tool ${platform}`) || html.includes(`platform-${platform}`),
252251
)
253252
this.includesPlatformSpecificContent = this.detectedPlatforms.length > 0
254253

255254
// set flags for webui, cli, etc switcher element
256255
this.detectedTools = Object.keys(allTools).filter(
257-
(tool) => html.includes(`extended-markdown ${tool}`) || html.includes(`tool-${tool}`),
256+
(tool) => html.includes(`ghd-tool ${tool}`) || html.includes(`tool-${tool}`),
258257
)
259258

260259
// pass the list of all possible tools around to components and utilities that will need it later on

src/content-linter/tests/lint-files.js

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import { jest } from '@jest/globals'
1616

1717
import { frontmatter, deprecatedProperties } from '../../../lib/frontmatter.js'
1818
import languages from '../../../lib/languages.js'
19-
import { tags } from '#src/content-render/liquid/extended-markdown.js'
2019
import releaseNotesSchema from '../lib/release-notes-schema.js'
2120
import learningTracksSchema from '../lib/learning-tracks-schema.js'
2221
import { renderContent, liquid } from '#src/content-render/index.js'
@@ -170,13 +169,6 @@ const oldVariableRegex = /{{\s*?site\.data\..*?}}/g
170169
//
171170
const oldOcticonRegex = /{{\s*?octicon-([a-z-]+)(\s[\w\s\d-]+)?\s*?}}/g
172171

173-
// - {{#note}}
174-
// - {{/note}}
175-
// - {{ #warning }}
176-
// - {{ /pizza }}
177-
//
178-
const oldExtendedMarkdownRegex = /{{\s*?[#/][a-z-]+\s*?}}/g
179-
180172
// GitHub-owned actions (e.g. actions/checkout@v2) should use a reusable in examples.
181173
// list:
182174
// - actions/checkout@v2
@@ -211,8 +203,6 @@ const oldVariableErrorText =
211203
'Found article uses old {{ site.data... }} syntax. Use {% data example.data.string %} instead!'
212204
const oldOcticonErrorText =
213205
'Found octicon variables with the old {{ octicon-name }} syntax. Use {% octicon "name" %} instead!'
214-
const oldExtendedMarkdownErrorText =
215-
'Found extended markdown tags with the old {{#note}} syntax. Use {% note %}/{% endnote %} instead!'
216206
const literalActionInsteadOfReusableErrorText =
217207
'Found a literal mention of a GitHub-owned action. Instead, use the reusables for the action. e.g {% data reusables.actions.action-checkout %}'
218208

@@ -596,21 +586,6 @@ describe('lint markdown content', () => {
596586
expect(matches.length, errorMessage).toBe(0)
597587
})
598588

599-
test('does not use old extended markdown syntax', async () => {
600-
Object.keys(tags).forEach((tag) => {
601-
const reg = new RegExp(`{{\\s*?[#|/]${tag}`, 'g')
602-
if (reg.test(content)) {
603-
const matches = content.match(oldExtendedMarkdownRegex) || []
604-
const tagMessage = oldExtendedMarkdownErrorText
605-
.replace('{{#note}}', `{{#${tag}}}`)
606-
.replace('{% note %}', `{% ${tag} %}`)
607-
.replace('{% endnote %}', `{% end${tag} %}`)
608-
const errorMessage = formatLinkError(tagMessage, matches)
609-
expect(matches.length, errorMessage).toBe(0)
610-
}
611-
})
612-
})
613-
614589
test('URLs must not contain a hard-coded language code', async () => {
615590
const matches = links.filter((link) => {
616591
return /\/(?:${languageCodes.join('|')})\//.test(link)
@@ -895,22 +870,6 @@ describe('lint yaml content', () => {
895870
const errorMessage = formatLinkError(oldOcticonErrorText, matches)
896871
expect(matches.length, errorMessage).toBe(0)
897872
})
898-
899-
test('does not use old extended markdown syntax', async () => {
900-
const matches = []
901-
902-
for (const [key, content] of Object.entries(dictionary)) {
903-
const contentStr = getContent(content)
904-
if (!contentStr) continue
905-
const valMatches = contentStr.match(oldExtendedMarkdownRegex) || []
906-
if (valMatches.length > 0) {
907-
matches.push(...valMatches.map((match) => `Key "${key}": ${match}`))
908-
}
909-
}
910-
911-
const errorMessage = formatLinkError(oldExtendedMarkdownErrorText, matches)
912-
expect(matches.length, errorMessage).toBe(0)
913-
})
914873
})
915874
})
916875

src/content-render/liquid/engine.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import IndentedDataReference from './indented-data-reference.js'
44
import Data from './data.js'
55
import Octicon from './octicon.js'
66
import Ifversion from './ifversion.js'
7-
import { ExtendedMarkdown, tags } from './extended-markdown.js'
7+
import { Tool, tags as toolTags } from './tool.js'
8+
import { Spotlight, tags as spotlightTags } from './spotlight.js'
89

910
export const engine = new Liquid({
1011
extname: '.html',
@@ -16,9 +17,12 @@ engine.registerTag('data', Data)
1617
engine.registerTag('octicon', Octicon)
1718
engine.registerTag('ifversion', Ifversion)
1819

19-
for (const tag in tags) {
20-
// Register all the extended markdown tags, like {% note %} and {% warning %}
21-
engine.registerTag(tag, ExtendedMarkdown)
20+
for (const tag of toolTags) {
21+
engine.registerTag(tag, Tool)
22+
}
23+
24+
for (const tag in spotlightTags) {
25+
engine.registerTag(tag, Spotlight)
2226
}
2327

2428
/**

src/content-render/liquid/extended-markdown.js

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

0 commit comments

Comments
 (0)