Skip to content

Commit ac0fff6

Browse files
author
Nacho Torrella
committed
feat(packages/sui-svg): refactor accessibility injection in AtomIcon component
1 parent dc9d204 commit ac0fff6

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

packages/sui-svg/templates/icon-component.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@ const template = content => {
22
return `import {memo} from 'react'
33
import AtomIcon from '@s-ui/react-atom-icon'
44
5-
const MemoAtomIcon = memo(({id, title, ...props}) => {
6-
const injectAccessibility = ({id, svg, title}) => {
7-
if (!title || !id) return svg.replace(/<svg([^>]*)>/, '<svg$1 aria-hidden="true">')
5+
const injectAccessibility = ({id, svg, title}) => {
6+
if (!title || !id) return svg.replace(/<svg([^>]*)>/, '<svg$1 aria-hidden="true">')
87
9-
return svg.replace(
10-
/<svg([^>]*)>/,
11-
\`<svg$1 role="img" aria-labelledby="\${id}"><title id="\${id}">\${title}</title>\`
12-
)
13-
}
8+
return svg.replace(
9+
/<svg([^>]*)>/,
10+
\`<svg$1 role="img" aria-labelledby="\${id}"><title id="\${id}">\${title}</title>\`
11+
)
12+
}
1413
14+
const MemoAtomIcon = memo(({id, title, ...props}) => {
1515
const safeContent = injectAccessibility({id, svg: \`${content}\`, title})
1616
1717
return (

0 commit comments

Comments
 (0)