IconDemo.svelte 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <!-- Icon Demo,请确保已引入 symbol.svg 文件。 -->
  2. <script>
  3. import { Icon } from '../../../../packages/stdf/components';
  4. const icons = ['ri-spy-fill', 'ri-chrome-fill', 'ri-riding-line', 'ri-switch-fill'];
  5. </script>
  6. <div class="felx felx-col space-y-12 px-4 py-8">
  7. <!-- 基础用法 -->
  8. <div>
  9. <div class="mb-2 font-bold text-xl">基础用法</div>
  10. <div class="flex flex-wrap justify-between">
  11. {#each icons as icon}
  12. <div class="py-2 text-center flex-1">
  13. <Icon name={icon} />
  14. <div class="text-xs mt-2 text-gray6">{icon}</div>
  15. </div>
  16. {/each}
  17. </div>
  18. </div>
  19. <!-- 跟随主题色 -->
  20. <div>
  21. <div class="mb-2 font-bold text-xl">跟随主题色</div>
  22. <div class="flex flex-wrap justify-between">
  23. {#each icons as icon}
  24. <div class="py-2 text-center flex-1">
  25. <Icon name={icon} theme />
  26. </div>
  27. {/each}
  28. </div>
  29. </div>
  30. <!-- 不同大小 -->
  31. <div>
  32. <div class="mb-2 font-bold text-xl">不同大小</div>
  33. <div class="flex flex-wrap justify-between">
  34. {#each icons as icon, i}
  35. <div class="py-2 text-center flex-1">
  36. <Icon name={icon} size={18 + i * 6} />
  37. <div class="text-xs mt-2 text-gray6">{18 + i * 6}</div>
  38. </div>
  39. {/each}
  40. </div>
  41. </div>
  42. <!-- 不同透明度 -->
  43. <div>
  44. <div class="mb-2 font-bold text-xl">不同透明度</div>
  45. <div class="flex flex-wrap justify-between">
  46. {#each icons as icon, i}
  47. <div class="py-2 text-center flex-1">
  48. <Icon name={icon} alpha={Number((0.2 + i * 0.2).toFixed(1))} />
  49. <div class="text-xs mt-2 text-gray6">{(0.2 + i * 0.2).toFixed(1)}</div>
  50. </div>
  51. {/each}
  52. </div>
  53. </div>
  54. <!-- 自定义颜色(通过 injClass) -->
  55. <div>
  56. <div class="mb-2 font-bold text-xl">
  57. 自定义颜色<span class="ml-2 text-xs text-gray6 font-normal">通过 injClass</span>
  58. </div>
  59. <div class="flex flex-wrap justify-between">
  60. {#each icons as icon}
  61. <div class="py-2 text-center flex-1">
  62. <Icon name={icon} injClass="text-[red] dark:text-green" />
  63. </div>
  64. {/each}
  65. </div>
  66. </div>
  67. <!-- 自定义颜色(通过 slot) -->
  68. <div>
  69. <div class="mb-2 font-bold text-xl">
  70. 自定义颜色<span class="ml-2 text-xs text-gray6 font-normal">通过 slot</span>
  71. </div>
  72. <div class="flex flex-wrap justify-between">
  73. {#each icons as icon}
  74. <div class="py-2 text-center flex-1">
  75. <Icon name="slot">
  76. <i class="text-[#266CF6] dark:text-[#C84031]">
  77. <Icon name={icon} />
  78. </i>
  79. </Icon>
  80. </div>
  81. {/each}
  82. </div>
  83. </div>
  84. <!-- 插槽 -->
  85. <div>
  86. <div class="mb-2 font-bold text-xl">插槽</div>
  87. <div class="flex flex-wrap justify-between">
  88. {#each icons as icon}
  89. <div class="py-2 text-center flex-1">
  90. <Icon name="slot">
  91. <svg
  92. height="24"
  93. width="24"
  94. aria-hidden="true"
  95. viewBox="0 0 16 16"
  96. data-view-component="true"
  97. style="display: inline;"
  98. >
  99. <path
  100. fill-rule="evenodd"
  101. d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"
  102. />
  103. </svg>
  104. </Icon>
  105. </div>
  106. {/each}
  107. </div>
  108. </div>
  109. <!-- 偏移 -->
  110. <div>
  111. <div class="mb-2 font-bold text-xl">偏移</div>
  112. <div class="flex flex-wrap justify-between">
  113. {#each icons as icon, i}
  114. <div class="py-2 text-center flex-1">
  115. <Icon name={icons[1]} top={-4 + i * 2} />
  116. top:{-4 + i * 2}
  117. </div>
  118. {/each}
  119. </div>
  120. </div>
  121. </div>