Skip to content

Commit

Permalink
Merge branch 'main' into 2776-optimizing-scss-code
Browse files Browse the repository at this point in the history
  • Loading branch information
mfranzke authored Jun 24, 2024
2 parents d914cc2 + ed4b798 commit 98fb233
Show file tree
Hide file tree
Showing 16 changed files with 163 additions and 125 deletions.
2 changes: 1 addition & 1 deletion output/vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"test:components": "playwright test -c playwright.config.ts"
},
"dependencies": {
"vue": "^3.4.29"
"vue": "^3.4.30"
},
"devDependencies": {
"@playwright/experimental-ct-vue": "1.44.1",
Expand Down
145 changes: 68 additions & 77 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 38 additions & 3 deletions packages/components/src/components/badge/badge.lite.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,45 @@
import { useMetadata, useRef, useStore } from '@builder.io/mitosis';
import {
onMount,
onUpdate,
Show,
useMetadata,
useRef,
useStore
} from '@builder.io/mitosis';
import { DBBadgeProps, DBBadgeState } from './model';
import { cls } from '../../utils';
import { DEFAULT_LABEL } from '../../shared/constants';

useMetadata({
isAttachedToShadowDom: true
});

export default function DBBadge(props: DBBadgeProps) {
const ref = useRef<HTMLSpanElement>(null);
const state = useStore<DBBadgeState>({});
const state = useStore<DBBadgeState>({
initialized: false
});

onMount(() => {
state.initialized = true;
});

onUpdate(() => {
if (ref && state.initialized) {
if (props.placement?.startsWith('corner')) {
let parent = ref.parentElement;

if (parent && parent.localName.includes('badge')) {
// Angular workaround
parent = parent.parentElement;
}

if (parent) {
parent.setAttribute('data-has-badge', 'true');
}
}
}
}, [ref, state.initialized]);

return (
<span
Expand All @@ -18,7 +49,11 @@ export default function DBBadge(props: DBBadgeProps) {
data-semantic={props.semantic}
data-size={props.size}
data-emphasis={props.emphasis}
data-placement={props.placement}>
data-placement={props.placement}
data-label={
props.placement?.startsWith('corner') &&
(props.label ?? DEFAULT_LABEL)
}>
{props.children}
</span>
);
Expand Down
Loading

0 comments on commit 98fb233

Please sign in to comment.