You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

74 regels
2.1 KiB

  1. <template>
  2. <view :style="[groupStyle, addStyle(customStyle)]" :class="[customClass]" class="u-cell-group">
  3. <view v-if="title" class="u-cell-group__title">
  4. <slot name="title">
  5. <text class="u-cell-group__title__text" :style="{ color: upThemeVar('--up-main-color', '#303133') }">{{ title }}</text>
  6. </slot>
  7. </view>
  8. <view class="u-cell-group__wrapper">
  9. <u-line v-if="border"></u-line>
  10. <slot />
  11. </view>
  12. </view>
  13. </template>
  14. <script>
  15. import { props } from './props';
  16. import { mpMixin } from '../../libs/mixin/mpMixin';
  17. import { mixin } from '../../libs/mixin/mixin';
  18. import { addStyle } from '../../libs/function/index';
  19. /**
  20. * cellGroup 单元格
  21. * @description cell单元格一般用于一组列表的情况,比如个人中心页,设置页等。
  22. * @tutorial https://uview-plus.jiangruyi.com/components/cell.html
  23. *
  24. * @property {String} title 分组标题
  25. * @property {Boolean} border 是否显示外边框 (默认 true )
  26. * @property {Object} customStyle 定义需要用到的外部样式
  27. *
  28. * @event {Function} click 点击cell列表时触发
  29. * @example <u-cell-group title="设置喜好">
  30. */
  31. export default {
  32. name: 'u-cell-group',
  33. mixins: [mpMixin, mixin, props],
  34. computed: {
  35. groupStyle() {
  36. const fallbackBg = this.upThemeIsDark ? '#1c1c1e' : '#ffffff'
  37. return {
  38. backgroundColor: this.upThemeVar('--up-card-bg-color', fallbackBg)
  39. }
  40. }
  41. },
  42. methods: {
  43. addStyle
  44. }
  45. }
  46. </script>
  47. <style lang="scss" scoped>
  48. $u-cell-group-title-padding: 16px 16px 8px !default;
  49. $u-cell-group-title-font-size: 15px !default;
  50. $u-cell-group-title-line-height: 16px !default;
  51. $u-cell-group-title-color: $u-main-color !default;
  52. .u-cell-group {
  53. flex: 1;
  54. &__title {
  55. padding: $u-cell-group-title-padding;
  56. &__text {
  57. font-size: $u-cell-group-title-font-size;
  58. line-height: $u-cell-group-title-line-height;
  59. color: $u-cell-group-title-color;
  60. }
  61. }
  62. &__wrapper {
  63. position: relative;
  64. }
  65. }
  66. </style>