diff --git a/src/patches/index.js b/src/patches/index.js index 6a948ea..984cf64 100644 --- a/src/patches/index.js +++ b/src/patches/index.js @@ -4,3 +4,4 @@ export * from './VwcCard' export * from './vwcNoteContentOverflow' export * from './vwcSnackBarHtmlMessage' export * from './vwcSetAttributeValue' +export * from './vwcBadge' diff --git a/src/patches/vwcBadge.js b/src/patches/vwcBadge.js new file mode 100644 index 0000000..eb08b6c --- /dev/null +++ b/src/patches/vwcBadge.js @@ -0,0 +1,21 @@ +/** +* Patches provided vivid-3 VwcBadge instance to show text in the center +* +* @param {HTMLElement} badgeElement - target element to apply behavior to +* @example +*/ +export const vwcBadgeShowTextCenterDecorator = () => badgeElement => + setTimeout(() => { + if (!badgeElement) { + return + } + + if (badgeElement.shadowRoot) { + const span = badgeElement.shadowRoot.querySelector('span.base'); + if (span) { + span.style.display = 'flex'; + span.style.justifyContent = 'center'; + } + } + }, 0) +