Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat: adds new properties #69

Merged
merged 1 commit into from
Sep 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/components/Badge/Badge.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ export const defaultArgs = {
},
defaultValue: '',
},
bordered: {
control: {
type: 'boolean',
},
defaultValue: false,
},
onClick: {
action: 'click',
},
Expand Down
15 changes: 13 additions & 2 deletions src/components/Badge/Badge.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ export interface BadgeProps {
hover?: boolean;
icon?: string;
content?: string | number;
bordered?: boolean;
over?: boolean;
}
const props = withDefaults(defineProps<BadgeProps>(), {
placement: 'right',
Expand All @@ -24,6 +26,8 @@ const props = withDefaults(defineProps<BadgeProps>(), {
hover: false,
icon: '',
content: '',
bordered: false,
over: false,
});
const emit = defineEmits(['click']);
const classes = computed(() => {
Expand All @@ -37,6 +41,8 @@ const classes = computed(() => {
'badge--overlap': props.overlap,
'badge--square': props.square,
'badge--hover': props.hover,
'badge--bordered': props.bordered,
'badge--over': props.over,
};
});
const styles = computed(() => {
Expand All @@ -55,8 +61,13 @@ const iconSize = computed(() => {
const onClick = () => emit('click');
</script>
<template>
<div class="wrapper group">
<div v-if="!props.icon" :style="styles" :class="classes" @click="onClick">
<div class="badge-wrapper group">
<div
v-if="!props.icon && props.content"
:style="styles"
:class="classes"
@click="onClick"
>
{{ props.content }}
</div>
<Icon
Expand Down
20 changes: 14 additions & 6 deletions src/components/Badge/badge.css
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
@tailwind components;

.wrapper {
@apply font-sans relative max-w-max p-2;
.badge-wrapper {
@apply transition duration-500 ease-in-out font-sans relative max-w-max p-2;
}

.badge {
@apply h-3 w-3 absolute z-50 rounded-full;
@apply min-h-[12px] min-w-[12px] absolute z-50 rounded-full p-[2px];
}

.badge--right {
Expand All @@ -20,6 +20,10 @@
@apply right-0 bottom-0;
}

.badge--bordered {
@apply border border-white border-solid;
}

.badge--overlap {
@apply top-1 right-1;
}
Expand All @@ -33,21 +37,25 @@
}

.badge__content {
@apply grid place-items-center leading-none text-xs text-white font-bold h-3.5 w-3.5;
@apply grid place-items-center leading-none text-xs text-white font-bold;
}

.badge--small {
@apply h-2 w-2;
}

.badge__content--small {
font-size: 8px;
@apply text-[8px]; /* 8px it's for without line height*/
}

.badge--large {
@apply h-4 w-4;
}

.badge__content--large {
font-size: 1rem;
@apply text-[1rem]; /* 16px it's for without line height*/
}

.badge--over {
@apply -top-2 -right-2;
}