button.uvue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <template>
  2. <cl-page>
  3. <view class="p-3">
  4. <demo-item :label="t('基础用法')">
  5. <cl-button>{{ t("普通") }}</cl-button>
  6. </demo-item>
  7. <demo-item :label="t('不同类型')">
  8. <view class="flex flex-row flex-wrap mb-2 overflow-visible">
  9. <cl-button type="primary">{{ t("主要") }}</cl-button>
  10. <cl-button type="success">{{ t("成功") }}</cl-button>
  11. <cl-button type="warn">{{ t("警告") }}</cl-button>
  12. <cl-button type="error">{{ t("危险") }}</cl-button>
  13. <cl-button type="info">{{ t("信息") }}</cl-button>
  14. </view>
  15. <view class="flex flex-row overflow-visible">
  16. <cl-button type="light">{{ t("浅色") }}</cl-button>
  17. <cl-button type="dark">{{ t("深色") }}</cl-button>
  18. </view>
  19. </demo-item>
  20. <demo-item :label="t('只显示图标')">
  21. <view class="flex flex-row">
  22. <cl-button type="primary" icon="send-plane-fill"></cl-button>
  23. <cl-button type="error" icon="verified-badge-fill"></cl-button>
  24. <cl-button type="info" icon="edit-fill"></cl-button>
  25. </view>
  26. </demo-item>
  27. <demo-item :label="t('自定义')">
  28. <view class="flex flex-row justify-center mb-5 h-14 items-center">
  29. <cl-button
  30. :type="type"
  31. :size="size"
  32. :text="isText"
  33. :border="isBorder"
  34. :rounded="isRounded"
  35. :loading="isLoading"
  36. :disabled="isDisabled"
  37. :icon="isIcon ? 'send-plane-fill' : ''"
  38. :color="isColor ? '#4286e0' : ''"
  39. :pt="{
  40. className: parseClass([
  41. {
  42. '!bg-transparent': isColor
  43. }
  44. ])
  45. }"
  46. >{{ t("自定义") }}</cl-button
  47. >
  48. </view>
  49. <cl-list border>
  50. <view class="p-2">
  51. <cl-tabs v-model="size" :list="sizeOptions" show-slider fill></cl-tabs>
  52. </view>
  53. <cl-list-item :label="t('文本模式')">
  54. <cl-switch v-model="isText"></cl-switch>
  55. </cl-list-item>
  56. <cl-list-item :label="t('带边框')">
  57. <cl-switch v-model="isBorder"></cl-switch>
  58. </cl-list-item>
  59. <cl-list-item :label="t('圆角按钮')">
  60. <cl-switch v-model="isRounded"></cl-switch>
  61. </cl-list-item>
  62. <cl-list-item :label="t('带左侧图标')">
  63. <cl-switch v-model="isIcon"></cl-switch>
  64. </cl-list-item>
  65. <cl-list-item :label="t('加载中')">
  66. <cl-switch v-model="isLoading"></cl-switch>
  67. </cl-list-item>
  68. <cl-list-item :label="t('禁用')">
  69. <cl-switch v-model="isDisabled"></cl-switch>
  70. </cl-list-item>
  71. <cl-list-item :label="t('自定义颜色')">
  72. <cl-switch v-model="isColor"></cl-switch>
  73. </cl-list-item>
  74. </cl-list>
  75. </demo-item>
  76. </view>
  77. </cl-page>
  78. </template>
  79. <script lang="ts" setup>
  80. import { ref } from "vue";
  81. import DemoItem from "../components/item.uvue";
  82. import type { ClButtonType, ClTabsItem, Size } from "@/uni_modules/cool-ui";
  83. import { parseClass, t } from "@/.cool";
  84. const type = ref<ClButtonType>("primary");
  85. const isText = ref(false);
  86. const isBorder = ref(false);
  87. const isRounded = ref(false);
  88. const isLoading = ref(false);
  89. const isIcon = ref(false);
  90. const isDisabled = ref(false);
  91. const isColor = ref(false);
  92. const size = ref<Size>("normal");
  93. const sizeOptions = ref<ClTabsItem[]>([
  94. {
  95. label: t("小"),
  96. value: "small"
  97. },
  98. {
  99. label: t("默认"),
  100. value: "normal"
  101. },
  102. {
  103. label: t("大"),
  104. value: "large"
  105. }
  106. ]);
  107. </script>