-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
928b48e
commit 9f1a2e9
Showing
22 changed files
with
2,270 additions
and
1,502 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
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,3 +1,4 @@ | ||
* text=auto | ||
pnpm-lock.yaml eol=lf | ||
package.json eol=lf | ||
*.csv eol=lf |
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,56 @@ | ||
<template> | ||
<div class="box"> | ||
<h-badge color="primary"> | ||
<h-button type="plain"> | ||
primary | ||
</h-button> | ||
</h-badge> | ||
<h-badge color="success"> | ||
<h-button type="plain"> | ||
success | ||
</h-button> | ||
</h-badge> | ||
<h-badge color="warning"> | ||
<h-button type="plain"> | ||
warning | ||
</h-button> | ||
</h-badge> | ||
<h-badge color="danger"> | ||
<h-button type="plain"> | ||
danger | ||
</h-button> | ||
</h-badge> | ||
<h-badge color="info"> | ||
<h-button type="plain"> | ||
info | ||
</h-button> | ||
</h-badge> | ||
<h-badge color="emphasize"> | ||
<h-button type="plain"> | ||
emphasize | ||
</h-button> | ||
</h-badge> | ||
<h-badge color="#39e"> | ||
<h-button type="plain"> | ||
自定义 | ||
</h-button> | ||
</h-badge> | ||
</div> | ||
|
||
</template> | ||
|
||
<style scoped lang="scss"> | ||
.box { | ||
display: flex; | ||
flex-wrap: wrap; | ||
& > * { | ||
margin: 0.5rem; | ||
} | ||
} | ||
</style> | ||
|
||
<script setup lang="ts"> | ||
import {HBadge, HButton} from '@yin-jinlong/h-ui' | ||
</script> |
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,32 @@ | ||
<template> | ||
<div class="box"> | ||
<h-badge :value="100"> | ||
<h-button type="plain"> | ||
默认数字 | ||
</h-button> | ||
</h-badge> | ||
<h-badge value="new"> | ||
<h-button type="plain"> | ||
自定义字符串 | ||
</h-button> | ||
</h-badge> | ||
</div> | ||
|
||
</template> | ||
|
||
<style scoped lang="scss"> | ||
.box { | ||
display: flex; | ||
flex-wrap: wrap; | ||
align-items: flex-end; | ||
& > * { | ||
margin: 0.5rem; | ||
} | ||
} | ||
</style> | ||
|
||
<script setup lang="ts"> | ||
import {HBadge, HButton} from '@yin-jinlong/h-ui' | ||
</script> |
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,51 @@ | ||
<template> | ||
<div class="box"> | ||
<h-badge> | ||
<h-button type="plain"> | ||
默认 | ||
</h-button> | ||
</h-badge> | ||
<h-badge :value="10"> | ||
<h-button type="plain"> | ||
10 | ||
</h-button> | ||
</h-badge> | ||
<h-badge :value="100"> | ||
<h-button type="plain"> | ||
100 | ||
</h-button> | ||
</h-badge> | ||
<h-badge :value="100" :max="9"> | ||
<h-button type="plain"> | ||
自定义上限 | ||
</h-button> | ||
</h-badge> | ||
<h-badge :value="0" :min="0"> | ||
<h-button type="plain"> | ||
自定义下限 | ||
</h-button> | ||
</h-badge> | ||
<h-badge :value="0"> | ||
<h-button type="plain"> | ||
0 | ||
</h-button> | ||
</h-badge> | ||
</div> | ||
|
||
</template> | ||
|
||
<style scoped lang="scss"> | ||
.box { | ||
display: flex; | ||
flex-wrap: wrap; | ||
& > * { | ||
margin: 0.5rem; | ||
} | ||
} | ||
</style> | ||
|
||
<script setup lang="ts"> | ||
import {HBadge, HButton} from '@yin-jinlong/h-ui' | ||
</script> |
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,36 @@ | ||
--- | ||
title: H-UI-Badge | ||
--- | ||
|
||
# Badge 标记 | ||
|
||
## 颜色 | ||
|
||
按钮的颜色。可以是已经定义的颜色(如`primary`), | ||
也可以是有效的`css`颜色值(如`red` `#39e` `var(--my-color-var)`)。 | ||
|
||
[.colors] | ||
|
||
## 数量 | ||
|
||
[.count] | ||
|
||
## 溢出显示 | ||
|
||
[.overflow] | ||
|
||
## 内容 | ||
|
||
当内容为`string`时,`min` `max`将会忽略。为空(`''`)时不显示。 | ||
|
||
[.content] | ||
|
||
## 大小 | ||
|
||
可以通过修改`font-size`来调整大小。 | ||
|
||
`badge`的`font-size`为`0.5em` | ||
|
||
[.size] | ||
|
||
[:api=badge] |
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,36 @@ | ||
<template> | ||
<div class="box"> | ||
<h-badge :value="100"> | ||
<h-button type="plain"> | ||
默认 | ||
</h-button> | ||
</h-badge> | ||
<h-badge :value="100" overflow="dot"> | ||
<h-button type="plain"> | ||
圆点2位 | ||
</h-button> | ||
</h-badge> | ||
<h-badge :value="1000" overflow="dot" :max="999"> | ||
<h-button type="plain"> | ||
圆点3位 | ||
</h-button> | ||
</h-badge> | ||
</div> | ||
|
||
</template> | ||
|
||
<style scoped lang="scss"> | ||
.box { | ||
display: flex; | ||
flex-wrap: wrap; | ||
& > * { | ||
margin: 0.5rem; | ||
} | ||
} | ||
</style> | ||
|
||
<script setup lang="ts"> | ||
import {HBadge, HButton} from '@yin-jinlong/h-ui' | ||
</script> |
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,37 @@ | ||
<template> | ||
<div class="box"> | ||
<h-badge :value="100"> | ||
<h-button type="plain"> | ||
默认 | ||
</h-button> | ||
</h-badge> | ||
<h-badge :value="100" style="font-size: 12px"> | ||
<h-button type="plain"> | ||
小 | ||
</h-button> | ||
</h-badge> | ||
<h-badge :value="1000" style="font-size: 30px"> | ||
<h-button type="plain"> | ||
大 | ||
</h-button> | ||
</h-badge> | ||
</div> | ||
|
||
</template> | ||
|
||
<style scoped lang="scss"> | ||
.box { | ||
display: flex; | ||
flex-wrap: wrap; | ||
align-items: flex-end; | ||
& > * { | ||
margin: 0.5rem; | ||
} | ||
} | ||
</style> | ||
|
||
<script setup lang="ts"> | ||
import {HBadge, HButton} from '@yin-jinlong/h-ui' | ||
</script> |
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
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 Badge from './src/badge.vue' | ||
|
||
export const HBadge = Badge | ||
|
||
export * from './src/props' | ||
export * from './src/type' | ||
|
||
export default HBadge |
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,35 @@ | ||
<template> | ||
<div :style="{ | ||
[cssVarName('badge-color')]: convertColor(color?.toString()) | ||
}" class="h-badge" data-relative> | ||
<slot name="default"/> | ||
<sup v-if="typeof value==='number'?value>=min:value?.length" class="h-badge-dot"> | ||
{{ getValue() }} | ||
</sup> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import {convertColor, cssVarName} from '@yin-jinlong/h-ui/utils' | ||
import DefaultProps, {HBadgeProps} from './props' | ||
const props = withDefaults(defineProps<HBadgeProps>(), DefaultProps) | ||
function getValue() { | ||
if (typeof props.value === 'string') | ||
return props.value | ||
if (props.value > props.max) { | ||
switch (props.overflow) { | ||
case 'max-plus': | ||
return props.max + '+' | ||
case 'dot': | ||
let len = Math.floor(Math.log10(props.value)) | ||
return '•'.repeat(len) | ||
default: | ||
return props.max | ||
} | ||
} | ||
return props.value | ||
} | ||
</script> |
Oops, something went wrong.