-
Notifications
You must be signed in to change notification settings - Fork 1
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 #204 from PrestaShopCorp/feat/chip-component
Feat/chip component
- Loading branch information
Showing
21 changed files
with
1,272 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { withInstall } from '@puik/utils' | ||
|
||
import Chip from './src/chip.vue' | ||
|
||
export const PuikChip = withInstall(Chip) | ||
export default PuikChip | ||
|
||
export * from './src/chip' |
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,45 @@ | ||
import { buildProps } from '@puik/utils' | ||
import type { PuikTooltipPosition } from '@puik/components' | ||
import type { ExtractPropTypes, PropType } from 'vue' | ||
import type Chip from './chip.vue' | ||
|
||
export const chipSizeVariants = ['default', 'small'] as const | ||
|
||
export type PuikChipSizeVariant = (typeof chipSizeVariants)[number] | ||
|
||
export const chipProps = buildProps({ | ||
id: { | ||
type: String, | ||
required: true, | ||
default: undefined, | ||
}, | ||
content: { | ||
type: String, | ||
required: true, | ||
default: undefined, | ||
}, | ||
size: { | ||
type: String, | ||
required: false, | ||
default: 'default', | ||
}, | ||
icon: { | ||
type: String, | ||
default: '', | ||
required: false, | ||
}, | ||
disabled: { | ||
type: Boolean, | ||
required: false, | ||
default: false, | ||
}, | ||
tooltipPosition: { | ||
type: String as PropType<PuikTooltipPosition>, | ||
Required: false, | ||
default: 'bottom', | ||
}, | ||
} as const) | ||
|
||
export type ChipProps = ExtractPropTypes<typeof chipProps> | ||
|
||
export type ChipInstance = InstanceType<typeof Chip> |
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,44 @@ | ||
<template> | ||
<div | ||
:id="id" | ||
:class="[ | ||
`puik-chip puik-chip--${size as PuikChipSizeVariant}`, | ||
{ 'puik-chip--disabled': disabled }, | ||
]" | ||
> | ||
<PuikIcon v-if="icon && icon != ''" :icon="icon" class="puik-chip__icon" /> | ||
<div class="puik-chip__content"> | ||
<puik-tooltip | ||
v-if="content?.length >= 30" | ||
:position="(tooltipPosition as PuikTooltipPosition)" | ||
:description="content" | ||
> | ||
<template #description>{{ content }}</template> | ||
{{ content }} | ||
</puik-tooltip> | ||
{{ content }} | ||
</div> | ||
<PuikIcon | ||
icon="close" | ||
class="puik-chip__close" | ||
@click="disabled ? '' : handleCloseEvent()" | ||
/> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { PuikIcon } from '@puik/components/icon' | ||
import { PuikTooltip } from '@puik/components/tooltip' | ||
import { chipProps, type PuikChipSizeVariant } from './chip' | ||
import type { PuikTooltipPosition } from '@puik/components/tooltip' | ||
defineOptions({ | ||
name: 'PuikChip', | ||
}) | ||
const props = defineProps(chipProps) | ||
const emit = defineEmits(['close']) | ||
const handleCloseEvent = () => { | ||
emit('close') | ||
} | ||
</script> |
Oops, something went wrong.