@vue-interface/badge 3.1.0 → 3.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -31
- package/dist/badge.js +6 -6
- package/dist/badge.js.map +1 -1
- package/dist/badge.umd.cjs.map +1 -1
- package/dist/src/Badge.vue.d.ts +1 -1
- package/package.json +4 -2
- package/src/Badge.vue +1 -1
- package/src/css/badge.css +6 -0
- package/dist/src/sizes.d.ts +0 -9
- package/src/sizes.ts +0 -18
package/README.md
CHANGED
|
@@ -24,40 +24,33 @@ bun i @vue-interface/badge
|
|
|
24
24
|
|
|
25
25
|
To create a badge component, use the `badge` class. Use the `badge-close` class to add a close button to the badge.
|
|
26
26
|
|
|
27
|
-
```
|
|
28
|
-
<
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
<
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
<button class="badge-close"></button>
|
|
41
|
-
<span>Left Close</span>
|
|
42
|
-
</div>
|
|
27
|
+
```vue
|
|
28
|
+
<Badge>Basic Usage</Badge>
|
|
29
|
+
<Badge closeable @click="() => {console.log('click')}" @close="() => {console.log('close')}">
|
|
30
|
+
Right Close Button
|
|
31
|
+
</Badge>
|
|
32
|
+
<Badge closeable close-left>Left Close Button</Badge>
|
|
33
|
+
<Badge closeable class="badge-pill">Pill Badge</Badge>
|
|
34
|
+
<Badge closeable>
|
|
35
|
+
<template #close-icon>
|
|
36
|
+
<trash-icon></trash-icon>
|
|
37
|
+
</template>
|
|
38
|
+
Custom Icon
|
|
39
|
+
</Badge>
|
|
43
40
|
```
|
|
44
41
|
Use the `badge-outline` class to create an outlined badge.
|
|
45
42
|
|
|
46
|
-
```
|
|
47
|
-
<
|
|
48
|
-
|
|
49
|
-
</
|
|
50
|
-
<
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
<
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
</
|
|
57
|
-
<div class="badge badge-outline">
|
|
58
|
-
<button class="badge-close"></button>
|
|
59
|
-
<span>Left Close Button</span>
|
|
60
|
-
</div>
|
|
43
|
+
```vue
|
|
44
|
+
<Badge class="badge-outline">Basic Usage</Badge>
|
|
45
|
+
<Badge class="badge-outline" closeable>Right Close Button</Badge>
|
|
46
|
+
<Badge class="badge-outline" closeable close-left>Left Close Button</Badge>
|
|
47
|
+
<Badge closeable class="badge-pill badge-outline">Pill Badge</Badge>
|
|
48
|
+
<Badge closeable class="badge-outline">
|
|
49
|
+
<template #close-icon>
|
|
50
|
+
<trash-icon></trash-icon>
|
|
51
|
+
</template>
|
|
52
|
+
Custom Icon
|
|
53
|
+
</Badge>
|
|
61
54
|
```
|
|
62
55
|
|
|
63
56
|
For more comprehensive documentation and examples, please visit the [online documentation](https://vue-interface.github.io/packages/badge/).
|
package/dist/badge.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { openBlock as l, createElementBlock as n, createElementVNode as i, defineComponent as d, normalizeClass as u, renderSlot as c, createVNode as f, unref as m, createCommentVNode as k } from "vue";
|
|
2
2
|
function g(e, s) {
|
|
3
|
-
return
|
|
3
|
+
return l(), n("svg", {
|
|
4
4
|
xmlns: "http://www.w3.org/2000/svg",
|
|
5
5
|
fill: "none",
|
|
6
6
|
viewBox: "0 0 24 24",
|
|
@@ -26,7 +26,7 @@ const b = /* @__PURE__ */ d({
|
|
|
26
26
|
emits: ["click", "close"],
|
|
27
27
|
setup(e, { emit: s }) {
|
|
28
28
|
const a = s;
|
|
29
|
-
return (r, o) => (
|
|
29
|
+
return (r, o) => (l(), n("div", {
|
|
30
30
|
class: u(["badge", [
|
|
31
31
|
e.size,
|
|
32
32
|
{ "close-left": e.closeLeft }
|
|
@@ -38,16 +38,16 @@ const b = /* @__PURE__ */ d({
|
|
|
38
38
|
}, [
|
|
39
39
|
c(r.$slots, "default")
|
|
40
40
|
]),
|
|
41
|
-
e.closeable ? (
|
|
41
|
+
e.closeable ? (l(), n("button", {
|
|
42
42
|
key: 0,
|
|
43
43
|
type: "button",
|
|
44
44
|
class: "badge-close",
|
|
45
45
|
onClick: o[1] || (o[1] = (t) => a("close", t))
|
|
46
46
|
}, [
|
|
47
47
|
c(r.$slots, "close-icon", {}, () => [
|
|
48
|
-
m(
|
|
48
|
+
f(m(g))
|
|
49
49
|
])
|
|
50
|
-
])) :
|
|
50
|
+
])) : k("", !0)
|
|
51
51
|
], 2));
|
|
52
52
|
}
|
|
53
53
|
});
|
package/dist/badge.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"badge.js","sources":["../../../node_modules/.pnpm/@heroicons+vue@2.2.0_vue@3.5.26_typescript@5.9.3_/node_modules/@heroicons/vue/24/outline/esm/XMarkIcon.js","../src/Badge.vue"],"sourcesContent":["import { createElementVNode as _createElementVNode, openBlock as _openBlock, createElementBlock as _createElementBlock } from \"vue\"\n\nexport default function render(_ctx, _cache) {\n return (_openBlock(), _createElementBlock(\"svg\", {\n xmlns: \"http://www.w3.org/2000/svg\",\n fill: \"none\",\n viewBox: \"0 0 24 24\",\n \"stroke-width\": \"1.5\",\n stroke: \"currentColor\",\n \"aria-hidden\": \"true\",\n \"data-slot\": \"icon\"\n }, [\n _createElementVNode(\"path\", {\n \"stroke-linecap\": \"round\",\n \"stroke-linejoin\": \"round\",\n d: \"M6 18 18 6M6 6l12 12\"\n })\n ]))\n}","<script setup lang=\"ts\">\nimport { XMarkIcon } from '@heroicons/vue/24/outline';\nimport type { ComponentSize } from '
|
|
1
|
+
{"version":3,"file":"badge.js","sources":["../../../node_modules/.pnpm/@heroicons+vue@2.2.0_vue@3.5.26_typescript@5.9.3_/node_modules/@heroicons/vue/24/outline/esm/XMarkIcon.js","../src/Badge.vue"],"sourcesContent":["import { createElementVNode as _createElementVNode, openBlock as _openBlock, createElementBlock as _createElementBlock } from \"vue\"\n\nexport default function render(_ctx, _cache) {\n return (_openBlock(), _createElementBlock(\"svg\", {\n xmlns: \"http://www.w3.org/2000/svg\",\n fill: \"none\",\n viewBox: \"0 0 24 24\",\n \"stroke-width\": \"1.5\",\n stroke: \"currentColor\",\n \"aria-hidden\": \"true\",\n \"data-slot\": \"icon\"\n }, [\n _createElementVNode(\"path\", {\n \"stroke-linecap\": \"round\",\n \"stroke-linejoin\": \"round\",\n d: \"M6 18 18 6M6 6l12 12\"\n })\n ]))\n}","<script setup lang=\"ts\">\nimport { XMarkIcon } from '@heroicons/vue/24/outline';\nimport type { ComponentSize } from '@vue-interface/sizeable';\n\nexport type BadgeSizePrefix = 'badge';\n\nwithDefaults(defineProps<{\n closeable?: boolean;\n closeLeft?: boolean;\n size?: ComponentSize<BadgeSizePrefix>;\n}>(), {\n closeable: false,\n closeLeft: false,\n size: 'badge-md'\n});\n\ndefineSlots<{\n default: [];\n 'close-icon': [];\n}>();\n\nconst emit = defineEmits<{\n click: [e: PointerEvent];\n close: [e: PointerEvent];\n}>();\n</script>\n\n<template>\n <div \n class=\"badge\" \n :class=\"[\n size, \n { 'close-left': closeLeft }\n ]\">\n <div\n class=\"badge-inner\"\n @click=\"emit('click', $event)\">\n <slot />\n </div>\n <button\n v-if=\"closeable\"\n type=\"button\"\n class=\"badge-close\" \n @click=\"emit('close', $event)\">\n <slot name=\"close-icon\">\n <XMarkIcon />\n </slot>\n </button>\n </div>\n</template>"],"names":["render","_ctx","_cache","_openBlock","_createElementBlock","_createElementVNode","emit","__emit","__props","$event","_renderSlot","_createVNode","_unref","XMarkIcon"],"mappings":";AAEe,SAASA,EAAOC,GAAMC,GAAQ;AAC3C,SAAQC,EAAU,GAAIC,EAAoB,OAAO;AAAA,IAC/C,OAAO;AAAA,IACP,MAAM;AAAA,IACN,SAAS;AAAA,IACT,gBAAgB;AAAA,IAChB,QAAQ;AAAA,IACR,eAAe;AAAA,IACf,aAAa;AAAA,EACjB,GAAK;AAAA,IACDC,EAAoB,QAAQ;AAAA,MAC1B,kBAAkB;AAAA,MAClB,mBAAmB;AAAA,MACnB,GAAG;AAAA,IACT,CAAK;AAAA,EACL,CAAG;AACH;;;;;;;;;;ACGA,UAAMC,IAAOC;2BAOTH,EAoBM,OAAA;AAAA,MAnBF,UAAM,SAAO;AAAA,QACSI,EAAA;AAAA,wBAAmCA,EAAA,UAAA;AAAA,MAAS;;MAIlEH,EAIM,OAAA;AAAA,QAHF,OAAM;AAAA,QACL,SAAKH,EAAA,CAAA,MAAAA,EAAA,CAAA,IAAA,CAAAO,MAAEH,EAAI,SAAUG,CAAM;AAAA,MAAA;QAC5BC,EAAQT,EAAA,QAAA,SAAA;AAAA,MAAA;MAGFO,EAAA,kBADVJ,EAQS,UAAA;AAAA;QANL,MAAK;AAAA,QACL,OAAM;AAAA,QACL,SAAKF,EAAA,CAAA,MAAAA,EAAA,CAAA,IAAA,CAAAO,MAAEH,EAAI,SAAUG,CAAM;AAAA,MAAA;QAC5BC,EAEOT,4BAFP,MAEO;AAAA,UADHU,EAAaC,EAAAC,CAAA,CAAA;AAAA,QAAA;;;;;","x_google_ignoreList":[0]}
|
package/dist/badge.umd.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"badge.umd.cjs","sources":["../../../node_modules/.pnpm/@heroicons+vue@2.2.0_vue@3.5.26_typescript@5.9.3_/node_modules/@heroicons/vue/24/outline/esm/XMarkIcon.js","../src/Badge.vue"],"sourcesContent":["import { createElementVNode as _createElementVNode, openBlock as _openBlock, createElementBlock as _createElementBlock } from \"vue\"\n\nexport default function render(_ctx, _cache) {\n return (_openBlock(), _createElementBlock(\"svg\", {\n xmlns: \"http://www.w3.org/2000/svg\",\n fill: \"none\",\n viewBox: \"0 0 24 24\",\n \"stroke-width\": \"1.5\",\n stroke: \"currentColor\",\n \"aria-hidden\": \"true\",\n \"data-slot\": \"icon\"\n }, [\n _createElementVNode(\"path\", {\n \"stroke-linecap\": \"round\",\n \"stroke-linejoin\": \"round\",\n d: \"M6 18 18 6M6 6l12 12\"\n })\n ]))\n}","<script setup lang=\"ts\">\nimport { XMarkIcon } from '@heroicons/vue/24/outline';\nimport type { ComponentSize } from '
|
|
1
|
+
{"version":3,"file":"badge.umd.cjs","sources":["../../../node_modules/.pnpm/@heroicons+vue@2.2.0_vue@3.5.26_typescript@5.9.3_/node_modules/@heroicons/vue/24/outline/esm/XMarkIcon.js","../src/Badge.vue"],"sourcesContent":["import { createElementVNode as _createElementVNode, openBlock as _openBlock, createElementBlock as _createElementBlock } from \"vue\"\n\nexport default function render(_ctx, _cache) {\n return (_openBlock(), _createElementBlock(\"svg\", {\n xmlns: \"http://www.w3.org/2000/svg\",\n fill: \"none\",\n viewBox: \"0 0 24 24\",\n \"stroke-width\": \"1.5\",\n stroke: \"currentColor\",\n \"aria-hidden\": \"true\",\n \"data-slot\": \"icon\"\n }, [\n _createElementVNode(\"path\", {\n \"stroke-linecap\": \"round\",\n \"stroke-linejoin\": \"round\",\n d: \"M6 18 18 6M6 6l12 12\"\n })\n ]))\n}","<script setup lang=\"ts\">\nimport { XMarkIcon } from '@heroicons/vue/24/outline';\nimport type { ComponentSize } from '@vue-interface/sizeable';\n\nexport type BadgeSizePrefix = 'badge';\n\nwithDefaults(defineProps<{\n closeable?: boolean;\n closeLeft?: boolean;\n size?: ComponentSize<BadgeSizePrefix>;\n}>(), {\n closeable: false,\n closeLeft: false,\n size: 'badge-md'\n});\n\ndefineSlots<{\n default: [];\n 'close-icon': [];\n}>();\n\nconst emit = defineEmits<{\n click: [e: PointerEvent];\n close: [e: PointerEvent];\n}>();\n</script>\n\n<template>\n <div \n class=\"badge\" \n :class=\"[\n size, \n { 'close-left': closeLeft }\n ]\">\n <div\n class=\"badge-inner\"\n @click=\"emit('click', $event)\">\n <slot />\n </div>\n <button\n v-if=\"closeable\"\n type=\"button\"\n class=\"badge-close\" \n @click=\"emit('close', $event)\">\n <slot name=\"close-icon\">\n <XMarkIcon />\n </slot>\n </button>\n </div>\n</template>"],"names":["render","_ctx","_cache","_openBlock","_createElementBlock","_createElementVNode","emit","__emit","__props","$event","_renderSlot","_createVNode","_unref","XMarkIcon"],"mappings":"2PAEe,SAASA,EAAOC,EAAMC,EAAQ,CAC3C,OAAQC,EAAAA,UAAU,EAAIC,EAAAA,mBAAoB,MAAO,CAC/C,MAAO,6BACP,KAAM,OACN,QAAS,YACT,eAAgB,MAChB,OAAQ,eACR,cAAe,OACf,YAAa,MACjB,EAAK,CACDC,EAAAA,mBAAoB,OAAQ,CAC1B,iBAAkB,QAClB,kBAAmB,QACnB,EAAG,sBACT,CAAK,CACL,CAAG,CACH,+LCGA,MAAMC,EAAOC,8BAOTH,EAAAA,mBAoBM,MAAA,CAnBF,wBAAM,QAAO,CACSI,EAAA,mBAAmCA,EAAA,SAAA,CAAS,MAIlEH,EAAAA,mBAIM,MAAA,CAHF,MAAM,cACL,QAAKH,EAAA,CAAA,IAAAA,EAAA,CAAA,EAAAO,GAAEH,EAAI,QAAUG,CAAM,EAAA,GAC5BC,aAAQT,EAAA,OAAA,SAAA,CAAA,GAGFO,EAAA,yBADVJ,EAAAA,mBAQS,SAAA,OANL,KAAK,SACL,MAAM,cACL,QAAKF,EAAA,CAAA,IAAAA,EAAA,CAAA,EAAAO,GAAEH,EAAI,QAAUG,CAAM,EAAA,GAC5BC,EAAAA,WAEOT,yBAFP,IAEO,CADHU,EAAAA,YAAaC,EAAAA,MAAAC,CAAA,CAAA,CAAA","x_google_ignoreList":[0]}
|
package/dist/src/Badge.vue.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue-interface/badge",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.2",
|
|
4
4
|
"description": "A Vue badge utility.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/badge.umd.cjs",
|
|
@@ -43,7 +43,9 @@
|
|
|
43
43
|
"LICENSE"
|
|
44
44
|
],
|
|
45
45
|
"peerDependencies": {
|
|
46
|
-
"vue": "
|
|
46
|
+
"@heroicons/vue": "2.2.0",
|
|
47
|
+
"vue": "^3.3.4",
|
|
48
|
+
"@vue-interface/sizeable": "2.0.0"
|
|
47
49
|
},
|
|
48
50
|
"scripts": {
|
|
49
51
|
"dev": "vite",
|
package/src/Badge.vue
CHANGED
package/src/css/badge.css
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
--badge-justify-content: space-between;
|
|
5
5
|
--badge-overflow: hidden;
|
|
6
6
|
--badge-text-decoration: none;
|
|
7
|
+
--badge-text-transform: capitalize;
|
|
7
8
|
--badge-gap: calc(1em * var(--badge-padding-x) / 2);
|
|
8
9
|
--badge-border-radius: --spacing(1);
|
|
9
10
|
--badge-font-size: --spacing(4);
|
|
@@ -40,6 +41,7 @@
|
|
|
40
41
|
background-color: var(--badge-background-color);
|
|
41
42
|
border-radius: var(--badge-border-radius);
|
|
42
43
|
text-decoration: var(--badge-text-decoration);
|
|
44
|
+
text-transform: var(--badge-text-transform);
|
|
43
45
|
overflow: var(--badge-overflow);
|
|
44
46
|
gap: var(--badge-gap);
|
|
45
47
|
|
|
@@ -110,6 +112,10 @@
|
|
|
110
112
|
}
|
|
111
113
|
}
|
|
112
114
|
|
|
115
|
+
@utility badge-pill {
|
|
116
|
+
border-radius: 100px;
|
|
117
|
+
}
|
|
118
|
+
|
|
113
119
|
@utility badge-* {
|
|
114
120
|
--badge-font-size: --value(--badge-font-size-*, [length]);
|
|
115
121
|
--badge-font-size: --spacing(--value(number));
|
package/dist/src/sizes.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export type PredeterminedSize = '2xs' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl' | '4xl' | '5xl';
|
|
2
|
-
export type Unit = 'px' | 'rem' | 'em' | 'vw' | 'vh' | '%' | 'ch' | 'ex' | 'cm' | 'mm' | 'in' | 'pt' | 'pc';
|
|
3
|
-
export type NumericWithUnit = `${number}${Unit}`;
|
|
4
|
-
export type CalcExpressionChar = number | '.' | '+' | '-' | '*' | '/' | '(' | ')' | '_';
|
|
5
|
-
export type NonEmptyCalcContentString = `${CalcExpressionChar}${string}` | CalcExpressionChar;
|
|
6
|
-
export type ValidCalc = `calc(${NonEmptyCalcContentString})`;
|
|
7
|
-
export type ValidBracketContent = NumericWithUnit | ValidCalc;
|
|
8
|
-
export type ComponentSizeValue<Prefix extends string, Value extends PredeterminedSize = PredeterminedSize> = `${Prefix}-${Value}` | `${Prefix}-${number}` | `${Prefix}-[${ValidBracketContent}]`;
|
|
9
|
-
export type ComponentSize<Prefix extends string, Value extends PredeterminedSize = PredeterminedSize> = ComponentSizeValue<Prefix, Value> | Partial<Record<ComponentSizeValue<Prefix, Value>, boolean>>;
|
package/src/sizes.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export type PredeterminedSize = '2xs' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl' | '4xl' | '5xl';
|
|
2
|
-
|
|
3
|
-
export type Unit = 'px' | 'rem' | 'em' | 'vw' | 'vh' | '%' | 'ch' | 'ex' | 'cm' | 'mm' | 'in' | 'pt' | 'pc';
|
|
4
|
-
export type NumericWithUnit = `${number}${Unit}`;
|
|
5
|
-
export type CalcExpressionChar = number | '.' | '+' | '-' | '*' | '/' | '(' | ')' | '_'
|
|
6
|
-
export type NonEmptyCalcContentString = `${CalcExpressionChar}${string}` | CalcExpressionChar;
|
|
7
|
-
export type ValidCalc = `calc(${NonEmptyCalcContentString})`;
|
|
8
|
-
export type ValidBracketContent = NumericWithUnit | ValidCalc;
|
|
9
|
-
|
|
10
|
-
export type ComponentSizeValue<
|
|
11
|
-
Prefix extends string,
|
|
12
|
-
Value extends PredeterminedSize = PredeterminedSize
|
|
13
|
-
> = `${Prefix}-${Value}` | `${Prefix}-${number}` | `${Prefix}-[${ValidBracketContent}]`;
|
|
14
|
-
|
|
15
|
-
export type ComponentSize<
|
|
16
|
-
Prefix extends string,
|
|
17
|
-
Value extends PredeterminedSize = PredeterminedSize
|
|
18
|
-
> = ComponentSizeValue<Prefix, Value> | Partial<Record<ComponentSizeValue<Prefix, Value>, boolean>>;
|