Skip to content

Commit

Permalink
Style macro options with <code> for table captions
Browse files Browse the repository at this point in the history
  • Loading branch information
colinrotherham committed Sep 28, 2023
1 parent 9a0b738 commit 810c8fa
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/get-macro-options/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,15 +219,20 @@ function getMacroOptions(componentName) {
]
.concat(
nestedOptions.map(([option]) => {
const names = option.name.split(' ')

// Wrap option name with `<code>` (excluding parents)
names[names.length - 1] = `<code>${names.at(-1)}</code>`

return {
...option,

// Append "objects" to the table caption for arrays of nested objects
// to clarify that the options are for arrays of objects, not arrays
name:
option.type === 'array' && option.params
? `Options for ${option.name} ${option.type} objects`
: `Options for ${option.name} ${option.type}`,
? `Options for ${names.join(' ')} ${option.type} objects`
: `Options for ${names.join(' ')} ${option.type}`,

options: option.params
}
Expand All @@ -237,7 +242,7 @@ function getMacroOptions(componentName) {
additionalComponents.map(([option, parent]) => ({
...option,

name: `Options for ${option.name} component`,
name: `Options for <code>${option.name}</code> component`,
options: getMacroOptionsJson(option.slug)
.map((option) => addSlugs(option, parent))
.map(renderNameWithBreaks)
Expand Down
9 changes: 9 additions & 0 deletions src/stylesheets/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ $colour-list-breakpoint: 980px;

// Add styling for inline code
li code,
caption code,
td code,
p code {
padding: 1px 3px;
Expand All @@ -259,6 +260,14 @@ p code {
}
}

// Add styling for code in headings
.govuk-heading-s code,
.govuk-heading-m code,
.govuk-heading-l code,
.govuk-heading-xl code {
font-size: inherit;
}

// Add styling for block code
pre code {
display: block;
Expand Down

0 comments on commit 810c8fa

Please sign in to comment.