Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | 'use strict'
const { resolveColorHex } = require('./colors')
function hexToRgb(hex) {
if (!hex) return ''
let h = hex[0] === '#' ? hex.slice(1) : hex
const r = parseInt(h.slice(0, 2), 16)
const g = parseInt(h.slice(2, 4), 16)
const b = parseInt(h.slice(4, 6), 16)
return `rgb(${r}, ${g}, ${b})`
}
/**
* SLDS YAML token content for a set of icons (standard or action).
* Mirrors the original generateSldsChanges output.
*/
function sldsYaml(icons, fileType) {
const disclaimer = `# Copy the below content to design-system-internal/design-tokens/bg-${fileType}.yml\n\n`
const body = icons
.map(icon => {
const key =
icon.icon_type === 'action'
? `ACTION_${icon.icon_name.toUpperCase()}`
: icon.icon_name.toUpperCase()
const hex = (resolveColorHex(icon.color) || '').toUpperCase()
return ` ${key}:\n value: '${hex}'`
})
.join('\n')
return disclaimer + body + '\n'
}
/**
* SDS CSS content for standard + action icons.
* Mirrors the original generateSdsChanges output.
*/
function sdsCss(icons) {
const disclaimer =
'/* Copy the below content to packages/design-system-2/src/slds2/icon/icon.type.css */\n\n'
const body = icons
.map(icon => {
const name = icon.icon_name.replace(/_/g, '-')
const rgb = hexToRgb(resolveColorHex(icon.color))
return ` .slds-icon-${icon.icon_type}-${name} {\n --slds-c-icon-color-background: ${rgb};\n }`
})
.join('\n')
return disclaimer + body + '\n'
}
/**
* Release notes grouped by icon type. Mirrors the original output.
*/
function releaseNotes(icons) {
const disclaimer = '<!-- RELEASENOTES.md -->\n\n'
const byType = icons.reduce((group, icon) => {
;(group[icon.icon_type] = group[icon.icon_type] || []).push(icon.icon_name)
return group
}, {})
const body = Object.entries(byType)
.map(([type, names]) => {
const list = names.map(n => ` - Added ${n}`).join('\n')
return `- ${type.charAt(0).toUpperCase() + type.slice(1)} set\n${list}`
})
.join('\n')
return disclaimer + body + '\n'
}
/**
* Metadata file content for a single icon (synonyms only), matching the
* original formatting: {\n "synonyms": ["a", "b"]\n}
*/
function metadataJson(icon) {
return `{\n "synonyms": ${JSON.stringify(icon.synonyms).replace(/,/g, ', ')}\n}`
}
module.exports = { sldsYaml, sdsCss, releaseNotes, metadataJson, hexToRgb }
|