1.2.9 • Published 4 months ago
heihu-uni-components v1.2.9
安装指南
通过 npm 安装
npm install heihu-uni-components
配置
引用样式,在 uni.scss
中添加:
@import "heihu-uni-components/src/assets/styles/export/index.css";
配置组件自动引用(easycom
组件模式),在 pages.json
中:
{
"easycom": {
"autoscan": true,
"custom": {
// 添加这行
"^hh-(.*)": "heihu-uni-components/components/hh-$1/hh-$1.vue"
}
}
}
活动倒计时组件(hh-promo-counter)
基本用法
<template>
<hh-promo-counter
class="counter"
v-model="time"
title="恭喜参加新人专享礼"
desc="买多久再送多久"
@finish="onFinish"
/>
</template>
<script>
import Vue from "vue";
export default {
data() {
return {
time: 10000,
};
},
methods: {
onFinish() {
console.log("结束");
},
},
};
</script>
属性
属性名 | 说明 | 类型 | 默认值 |
---|---|---|---|
model-value / v-model | 当前倒计时时间,单位秒 | Number | -- |
title | 活动标题 | String | -- |
desc | 活动描述 | String | -- |
auto | 是否自动倒计时 | Boolean | -- |
label | 倒计时上面的文本 | String | 活动截至 |
事件
事件名 | 说明 | 类型 |
---|---|---|
change | 倒计时变化,参数为倒计时剩余时间,单位秒 | (value: number) => void |
finish | 倒计时结束时调用 | () => void |
css
变量(修改方法请查看组件样式修改)
变量名 | 说明 | 默认值 |
---|---|---|
--hh-promo-counter-title-size | 活动标题字体 font-size | 36rpx |
--hh-promo-counter-title-color | 活动标题字体 color | white |
--hh-promo-counter-title-weight | 活动标题字体 font-weight | 900 |
--hh-promo-counter-desc-bg | 活动描述 background | #c421b1 |
--hh-promo-counter-desc-size | 活动描述字体 font-size | initial |
--hh-promo-counter-desc-color | 活动描述字体 color | white |
--hh-promo-counter-desc-weight | 活动描述字体 font-weight | normal |
--hh-promo-counter-desc-padding | 活动描述 padding | 10rpx 50rpx |
--hh-promo-counter-label-size | 倒计时上面的文本 font-size | initial |
--hh-promo-counter-label-color | 倒计时上面的文本 color | white |
--hh-promo-counter-label-weight | 倒计时上面的文本 font-weight | initial |
--hh-promo-counter-time-bg | 倒计时时间文本 background | #e3750d |
--hh-promo-counter-time-size | 倒计时时间文本 font-size | 24rpx |
--hh-promo-counter-time-color | 倒计时时间文本 color | white |
--hh-promo-counter-time-weight | 倒计时时间文本 font-weight | initial |
--hh-promo-counter-time-padding | 倒计时时间文本 padding | 6rpx 10rpx |
--hh-promo-counter-time-margin | 倒计时时间文本 margin | 0 8rpx |
--hh-promo-counter-time-border-radius | 倒计时时间文本 border-radius | 10rpx |
评分组件
基本用法
<template>
<hh-rating v-model="currRating" />
</template>
<script>
import Vue from "vue";
export default {
data() {
return {
/** 当前评分(即选中了多少颗星) */
currRating: 0,
};
},
};
</script>
属性
属性名 | 说明 | 类型 | 默认值 |
---|---|---|---|
model-value / v-model | 当前评分(即选中了多少颗星) | Number | -- |
count | 最高评分(即共有多少颗星) | Number | 5 |
inactiveIcon | 可用于更换未被选中“星星”图标 | String | -- |
activeIcon | 可用于更换被选中“星星”图标 | String | -- |
事件
事件名 | 说明 | 类型 |
---|---|---|
click-star | 选择评分时(即点击星星)调用,参数为用户给多少颗星 | (rating: number) => void |
css
变量(修改方法请查看组件样式修改)
变量名 | 说明 | 默认值 |
---|---|---|
--hh-rating-column-gap | 星星之间的间隔 | 20rpx |
--hh-rating-star-size | 星星图标大小 | 65rpx |
评分弹框组件
基本用法
<template>
<hh-rating-modal
v-model="show"
:topImgSrc="topImgSrc"
title="测试评分弹框"
content="测试评分弹框: 这是弹框内容,加长长长长长长长长长长长长长长长长长长一点"
@submit="submit"
/>
</template>
<script>
import Vue from "vue";
export default {
data() {
return {
/** 是否显示评分弹框 */
show: true,
/** 顶部图片,也可以是 `url` */
topImgSrc: require("../../static/rating-rate-svgrepo-com2.png"),
};
},
method: {
submit(rating) {
console.log("用户给的评分(即给了多少颗星)")
}
}
</script>
属性
属性名 | 说明 | 类型 | 默认值 |
---|---|---|---|
model-value / v-model | 是否显示评分弹框 | Boolean | -- |
topImgSrc | 顶部图片src | String | -- |
topImgMode | 顶部图片显示模式可通过 css 变量 --hh-rating-modal-img-width 和 --hh-rating-modal-img-height 调整图片宽高 | String | widthFix |
title | 弹框标题 | String | -- |
content | 弹框描述内容 | String | -- |
ratingTip | 底部评分提示 | String | 1-5星,轻触选择 |
initRating | 默认选中的评分,0表示不选择 | Number | 0 |
count | 最高评分(即有多少颗星) | Number | 5 |
closeOnClickMask | 点击遮罩是否关闭提示框 | Boolean | false |
closeOnClickClose | 点击关闭按钮时是否自动关闭 | Boolean | true |
center | 是否垂直居中显示,为 false 时,可通过css变量 --hh-modal-margin-top 调整距离顶部距离,该变量默认为 28vh | Boolean | false |
showClose | 是否显示关闭按钮 | Boolean | true |
closeOnSubmit | 选择评分(即点击星星)时是否自动关闭弹框 | Boolean | true |
事件
事件名 | 说明 | 类型 |
---|---|---|
submit | 选择评分时(即点击星星)调用,参数为用户给多少颗星 | (rating: number) => void |
click-close | 点击关闭按钮调用 | () => void |
click-mask | 点击弹框外区域时调用 | () => void |
css
变量(修改方法请查看组件样式修改)
变量名 | 说明 | 默认值 |
---|---|---|
--hh-rating-column-gap | 星星之间的间隔 | 20rpx |
--hh-rating-star-size | 星星图标大小 | 65rpx |
--hh-rating-modal-bg | 弹框背景。默认值说明:- 替换 #77390a 修改渐变颜色,- 修改 -20% 修改渐变开始位置(负数表示弹框外开始,弹框外部分渐变不会显示出来,因此调整此值也相当于跳转渐变颜色深浅),- 修改 40% 可修改渐变背景结束位置 | linear-gradient(180deg,#77390a -20%,white 40%) |
--hh-rating-modal-close-color | 关闭按钮 color | #666666 |
--hh-rating-modal-img-width | 顶部图片 width | 150rpx |
--hh-rating-modal-img-height | 顶部图片 height | auto |
--hh-rating-modal-img-top | 顶部图片距离弹框顶部间隔 margin-top (负数表示超出顶部) | -40rpx |
--hh-rating-modal-content-color | 弹框描述内容 color | --hh-color-info |
--hh-rating-modal-content-padding | 弹框描述内容 padding | 0 60rpx |
--hh-rating-modal-rating-tip-color | 弹框底部评分提示 color | --hh-color-info |
组件样式修改
修改方法
在 配置章节 中引入的css文件(@import "heihu-uni-components/src/assets/styles/export/index.css";
)中有所有组件的 css
变量,可以通过在引用该文件之后的地方修改对应的样式:
- 在非
css
选择器中修改,如在uni.scss
中修改(在此处修改将作用于所有使用到对应变量的组件):
/* 配置中引入的代码 */
@import "heihu-uni-components/src/assets/styles/export/index.css";
/* 修改变量: */
:root {
/* 修改所有弹框相关组件遮罩颜色 */
--hh-mask-bg: rgba(0, 0, 0, 0.3);
}
- 在
css
选择器中修改,如在组件的class
下修改(只影响该组件),以 评分弹框组件 为例:
<template>
<hh-rating-modal class="rating-modal" ... />
</template>
<script>
// .....
</script>
<style>
.rating-modal {
/* 修改评分弹框背景 */
--hh-rating-modal-bg: #ffffff;
/* 修改评分弹框顶部图片宽度 */
--hh-rating-modal-img-width: 200rpx;
/* 修改评分弹框顶部图片高度 */
--hh-rating-modal-img-height: 200rpx;
}
</style>
- 通过
>>>
(css
中使用)、::v-deep
(scss
中使用)或:deep()
(vue3
中使用)修改对应样式
全局 css
变量
变量名 | 说明 | 默认值 |
---|---|---|
--hh-color-primary | 主题主颜色 | #007aff |
--hh-color-success | 主题成功颜色 | #4cd964 |
--hh-color-warning | 主题警告颜色 | #f0ad4e |
--hh-color-error | 主题错误颜色 | #dd524d |
--hh-color-info | 主题信息颜色 | #666666 |
--hh-mask-bg | 遮罩背景,应用于 background 属性 | 当前文字背景rgba(0, 0, 0, 0.4) |
--hh-border-color | 通用边框颜色 | #c8c7cc |
--hh-elevation-0 | 突起样式,高度0,应用于 box-shadow 属性 | 当前文字阴影0px 0px 0px 0px rgb(0 0 0 / 0.2), 0px 0px 0px 0px rgb(0 0 0 / 0.14), 0px 0px 0px 0px rgb(0 0 0 / 0.12) |
--hh-elevation-1 | 突起样式,高度1,应用于 box-shadow 属性 | 当前文字阴影0px 3px 1px -2px rgb(0 0 0 / 0.2), 0px 2px 2px 0px rgb(0 0 0 / 0.14), 0px 1px 5px 0px rgb(0 0 0 / 0.12) |
--hh-elevation-2 | 突起样式,高度2,应用于 box-shadow 属性 | 当前文字阴影0px 2px 4px -1px rgb(0 0 0 / 0.2), 0px 4px 5px 0px rgb(0 0 0 / 0.14), 0px 1px 10px 0px rgb(0 0 0 / 0.12) |
--hh-elevation-3 | 突起样式,高度3,应用于 box-shadow 属性 | 当前文字阴影0px 5px 5px -3px rgb(0 0 0 / 0.2), 0px 8px 10px 1px rgb(0 0 0 / 0.14), 0px 3px 14px 2px rgb(0 0 0 / 0.12) |
--hh-elevation-4 | 突起样式,高度4,应用于 box-shadow 属性 | 当前文字阴影0px 5px 5px -3px rgb(0 0 0 / 0.2), 0px 8px 10px 1px rgb(0 0 0 / 0.14), 0px 3px 14px 2px rgb(0 0 0 / 0.12) |
--hh-elevation-5 | 突起样式,高度5,应用于 box-shadow 属性 | 当前文字阴影0px 8px 10px -6px rgb(0 0 0 / 0.2), 0px 16px 24px 2px rgb(0 0 0 / 0.14), 0px 6px 30px 5px rgb(0 0 0 / 0.12) |
1.2.8
4 months ago
1.2.7
4 months ago
1.2.6
4 months ago
1.2.9
4 months ago
1.2.0
4 months ago
1.2.5
4 months ago
1.2.4
4 months ago
1.2.3
4 months ago
1.2.2
4 months ago
1.2.1
4 months ago
1.1.3
5 months ago
1.1.2
5 months ago
1.1.1
5 months ago
1.1.0
5 months ago
1.0.9
5 months ago
1.0.8
5 months ago
1.0.7
5 months ago
1.0.10
5 months ago
1.0.6
5 months ago
1.0.5
5 months ago
1.0.4
5 months ago
1.0.3
5 months ago
1.0.2
5 months ago
1.0.1
5 months ago
1.0.0
5 months ago