-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #50 from selemondev/feat/Tags
feat(app): #49 Tag
- Loading branch information
Showing
7 changed files
with
227 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
<script setup lang='ts'> | ||
import { ref } from 'vue' | ||
const selected = ref('') | ||
function handleClose() { | ||
alert('Closing') | ||
} | ||
</script> | ||
|
||
<template> | ||
<div class="grid place-items-center w-full min-h-screen"> | ||
<WSwitch v-model="selected" on-icon="ph:sun" off-icon="ph:moon" class="text-xl" /> | ||
<WTag value="Success" variant="success-light" closable @close="handleClose" /> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,4 +14,5 @@ export enum Components { | |
WKbd = 'WKbd', | ||
WDivider = 'WDivider', | ||
WSwitch = 'WSwitch', | ||
WTag = 'WTag', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<script setup lang='ts'> | ||
import { computed, defineComponent, ref } from 'vue' | ||
import { Icon } from '@iconify/vue' | ||
import classNames from 'classnames' | ||
import { getVariantPropsWithClassesList } from '../../utils/getVariantProps' | ||
import { Components } from '../../Types/enums/Components' | ||
import type { VariantJSWithClassesListProps } from '../../utils/getVariantProps' | ||
import type { WTag } from '../../Types/componentsTypes/components' | ||
import { useVariants } from '../../composables/useVariants' | ||
import windiTheme from '../../theme/windiTheme' | ||
const props = defineProps({ | ||
...getVariantPropsWithClassesList<WTag>(), | ||
closable: { | ||
type: Boolean, | ||
default: false, | ||
}, | ||
rounded: { | ||
type: String, | ||
default: 'md', | ||
}, | ||
size: { | ||
type: String, | ||
default: 'md', | ||
}, | ||
dismissLabel: { | ||
type: String, | ||
default: 'Dismiss', | ||
}, | ||
value: { | ||
type: String, | ||
default: null, | ||
}, | ||
}) | ||
const emit = defineEmits<{ | ||
(event: 'close'): void | ||
}>() | ||
const isActive = ref(true) | ||
const variant = computed(() => { | ||
const customProps = { | ||
...props, | ||
variant: props.variant, | ||
} | ||
return useVariants<WTag>( | ||
Components.WTag, | ||
customProps as VariantJSWithClassesListProps<WTag>, | ||
) | ||
}) | ||
const tagWrapperClass = computed(() => { | ||
return classNames( | ||
variant.value.root, | ||
windiTheme.WTag.base.tagRounded[props.rounded], | ||
windiTheme.WTag.base.tagSize[props.size], | ||
) | ||
}) | ||
function onDismiss() { | ||
emit('close') | ||
return isActive.value = false | ||
} | ||
</script> | ||
|
||
<script lang="ts"> | ||
export default defineComponent({ | ||
name: Components.WTag, | ||
}) | ||
</script> | ||
|
||
<template> | ||
<div v-if="isActive" :class="tagWrapperClass"> | ||
<p>{{ props.value }}</p> | ||
<p v-if="props.closable"> | ||
<Icon icon="ph:x-bold" :aria-label="dismissLabel" :class="variant.tagCloseIcon" @click="onDismiss()" /> | ||
</p> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import Tag from './WTag.vue' | ||
|
||
export default { | ||
Tag, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters