jc-tailwind.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <script setup>
  2. import { onMounted, ref } from "vue"
  3. import useColor from '../../hooks/useColor.js'
  4. import useVars from '../../hooks/useVars.js'
  5. const { colors, color } = useColor()
  6. const { pxs, percents } = useVars()
  7. // const baseColors = ['slate','gray','zinc','neutral','stone','red','orange','amber','yellow','lime','green','emerald','teal','cyan','sky','blue','indigo','violet','purple','fuchsia','pink','rose']
  8. const baseColors = ['red','orange','amber','yellow','lime','green','emerald','teal','cyan','sky','blue','indigo','violet','purple','fuchsia','pink','rose']
  9. const baseDir = ['t', 'tr', 'r', 'br', 'b', 'bl', 'l', 'tl']
  10. function getRandColorName() {
  11. const index = ~~(Math.random() * baseColors.length)
  12. return baseColors[index]
  13. }
  14. function getRandDir() {
  15. const index = ~~(Math.random() * baseDir.length)
  16. return baseDir[index]
  17. }
  18. function getRandGradientColor() {
  19. return `bg-gradient-to-${getRandDir()} from-${getRandColorName()}-500 to-${getRandColorName()}-500 `
  20. }
  21. const lists = ref([
  22. { bg: '', name: 'Variable', info: '预设变量' },
  23. { bg: '', name: 'Layout', info: '布局' },
  24. { bg: '', name: 'Flexbox & Grid', info: '弹性盒子 & 网格布局' },
  25. { bg: '', name: 'Spacing', info: '间距' },
  26. { bg: '', name: 'Sizing', info: '尺寸' },
  27. { bg: '', name: 'Typography', info: '排版' },
  28. { bg: '', name: 'Backgrounds', info: '背景' },
  29. { bg: '', name: 'Borders', info: '边框' },
  30. { bg: '', name: 'Effects', info: '效果' },
  31. { bg: '', name: 'Filters', info: '滤镜' },
  32. { bg: '', name: 'Transitions & Animation', info: '过渡与动画' },
  33. { bg: '', name: 'Transforms', info: '变换' },
  34. { bg: '', name: 'Interactivity', info: '互动' },
  35. ])
  36. const current = ref('')
  37. function change(d) {
  38. current.value = d.name
  39. }
  40. function getRandBg() {
  41. lists.value.map((v) => {
  42. v.bg = getRandGradientColor()
  43. return v
  44. })
  45. }
  46. getRandBg()
  47. setInterval(getRandBg, 3000)
  48. </script>
  49. <template>
  50. <view class="bg-white">
  51. <template v-if="current">
  52. <view class="opacity-70 bg-slate-800 text-slate-100 flex items-center justify-center fixed bottom-5 right-5 w-14 h-14 rounded-full z-20" @tap="change({name: ''})">
  53. <text>返回</text>
  54. </view>
  55. <TwReadme v-if="current == 'Variable'" />
  56. <TwLayout v-if="current == 'Layout'" />
  57. <TwFlexboxGrid v-if="current == 'Flexbox & Grid'" />
  58. <TwSpacing v-if="current == 'Spacing'" />
  59. <TwSizing v-if="current == 'Sizing'" />
  60. <TwTypography v-if="current == 'Typography'" />
  61. <TwBackgrounds v-if="current == 'Backgrounds'" />
  62. <TwBorders v-if="current == 'Borders'" />
  63. <TwEffects v-if="current == 'Effects'" />
  64. <TwFilters v-if="current == 'Filters'" />
  65. <TwTransitionsAnimation v-if="current == 'Transitions & Animation'" />
  66. <TwTransforms v-if="current == 'Transforms'" />
  67. <TwInteractivity v-if="current == 'Interactivity'" />
  68. </template>
  69. <template v-else>
  70. <view class="p-2">
  71. <view class="grid grid-cols-2 gap-2">
  72. <template v-for="d, i in lists" :key="i">
  73. <view class="p-1 border border-slate-100 rounded flex flex-col justify-between" @tap="change(d)" :class="[d.name.length > 20 ? 'col-span-2' : '', d.bg]">
  74. <view class="bg-black__25 p-1 rounded">
  75. <view class="text-cyan-50 font-bold font-mono text-base flex-1">{{d.name}}</view>
  76. <view class="text-violet-200 mt-2 text-right">{{d.info}}</view>
  77. </view>
  78. </view>
  79. </template>
  80. </view>
  81. </view>
  82. </template>
  83. </view>
  84. </template>
  85. <style>
  86. </style>