button.uvue 3.4 KB

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