Skip to content

Commit

Permalink
feat(badge-patch): fix for badge text center (#67)
Browse files Browse the repository at this point in the history
* feat(badge-patch): fix for badge text center

* feat(fixed): empty line

* feat(badge): fix comments
  • Loading branch information
abhijeetj10 authored Jun 20, 2024
1 parent cbf7887 commit 62802f1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/patches/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ export * from './VwcCard'
export * from './vwcNoteContentOverflow'
export * from './vwcSnackBarHtmlMessage'
export * from './vwcSetAttributeValue'
export * from './vwcBadge'
21 changes: 21 additions & 0 deletions src/patches/vwcBadge.js
Original file line number Diff line number Diff line change
@@ -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 <VwcBadge ref={vwcBadgeShowTextCenterDecorator()} />
*/
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)

0 comments on commit 62802f1

Please sign in to comment.