ToastDemo_en.svelte 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <!-- Toast Demo -->
  2. <script>
  3. import { Toast, Cell, Button, Loading } from '../../../../packages/stdf';
  4. let visible1 = false;
  5. let visible2 = false;
  6. let visible3 = false;
  7. let visible4 = false;
  8. let visible5 = false;
  9. let visible6 = false;
  10. let visible7 = false;
  11. let visible8 = false;
  12. let visible9 = false;
  13. let visible10 = false;
  14. let visible11 = false;
  15. let visible12 = false;
  16. let visible13 = false;
  17. let visible14 = false;
  18. let visible15 = false;
  19. let visible16 = false;
  20. let visible17 = false;
  21. let visible18 = false;
  22. let visible19 = false;
  23. let visible20 = false;
  24. let visible21 = false;
  25. let visible22 = false;
  26. let visible23 = false;
  27. let visible24 = false;
  28. let visible25 = false;
  29. let visible26 = false;
  30. let visible27 = false;
  31. let visible28 = false;
  32. let visible29 = false;
  33. let visible30 = false;
  34. let visible31 = false;
  35. let visible32 = false;
  36. let time = 4;
  37. let timer = null;
  38. const useSlotFun = () => {
  39. visible25 = true;
  40. timer = setInterval(() => {
  41. time--;
  42. if (time <= 0) {
  43. clearInterval(timer);
  44. visible25 = false;
  45. time = 3;
  46. }
  47. }, 1000);
  48. };
  49. </script>
  50. <div class="py-4">
  51. <Cell title="Basic usage" on:click={() => (visible1 = true)} />
  52. <Toast bind:visible={visible1} message="Light hint" />
  53. <Cell title="Long text prompt" on:click={() => (visible2 = true)} />
  54. <Toast bind:visible={visible2} message="When the character count is too long, it is generally not recommended to display too much content here!" />
  55. <Cell title="Do not block clicks" on:click={() => (visible3 = true)} />
  56. <Toast bind:visible={visible3} clickable message="The content below the mask can also be clicked" />
  57. <Cell title="Fixed display time" on:click={() => (visible4 = true)} />
  58. <Toast bind:visible={visible4} duration={6000} message="It turns off automatically after 6 seconds" />
  59. <Cell title="Non-automatic closing" on:click={() => (visible5 = true)} />
  60. <Toast bind:visible={visible5} duration={0} clickable message="This prompt will not automatically close, please click the button to close" />
  61. <Cell title="Success message" on:click={() => (visible6 = true)} />
  62. <Toast bind:visible={visible6} type="success" message="Success message" />
  63. <Cell title="Failure prompt" on:click={() => (visible7 = true)} />
  64. <Toast bind:visible={visible7} type="error" message="Failure prompt" />
  65. <Cell title="Warning prompt" on:click={() => (visible8 = true)} />
  66. <Toast bind:visible={visible8} type="warning" message="Warning prompt" />
  67. <Cell title="Information prompt" on:click={() => (visible9 = true)} />
  68. <Toast bind:visible={visible9} type="info" message="Information prompt" />
  69. <Cell title="Load prompt" on:click={() => (visible30 = true)} />
  70. <Toast bind:visible={visible30} type="loading" message="Under load..." />
  71. <Cell title="Theme color loading prompt" on:click={() => (visible31 = true)} />
  72. <Toast bind:visible={visible31} type="loading" loading={{ theme: true }} message="Under load..." />
  73. <Cell title="Loading prompt for # 1_3" on:click={() => (visible32 = true)} />
  74. <Toast bind:visible={visible32} type="loading" loading={{ type: '1_3' }} message="Under load..." />
  75. <Cell title="Custom type" on:click={() => (visible27 = true)} />
  76. <Toast bind:visible={visible27} type="ri-thumb-up-fill" message="You are so good!" />
  77. <Cell title="The mask is opaque" on:click={() => (visible10 = true)} />
  78. <Toast bind:visible={visible10} mask={{ opacity: 0.3 }} message="Mask transparency is 0.3" />
  79. <Cell title="Reverse color mask" on:click={() => (visible11 = true)} />
  80. <Toast bind:visible={visible11} mask={{ inverse: true, opacity: 0.5 }} message="Reverse color mask" />
  81. <Cell title="Mask blur" on:click={() => (visible12 = true)} />
  82. <Toast bind:visible={visible12} mask={{ opacity: 0, backdropBlur: 'base' }} message="The content below the mask is blurry" />
  83. <Cell title="Faster transition" on:click={() => (visible13 = true)} />
  84. <Toast bind:visible={visible13} transitionParams={{ duration: 150 }} message="The transition time is 150ms" />
  85. <Cell title="Slow transition" on:click={() => (visible14 = true)} />
  86. <Toast bind:visible={visible14} transitionParams={{ duration: 1000 }} message="The transition time is 1s" />
  87. <Cell title="Fade in" on:click={() => (visible15 = true)} />
  88. <Toast bind:visible={visible15} transitionType="fade" message="Fade in presentation" />
  89. <Cell title="Move down" on:click={() => (visible16 = true)} />
  90. <Toast bind:visible={visible16} transitionType="fly" transitionParams={{ y: -150 }} message="Move down into presentation" />
  91. <Cell title="Move in to the right" on:click={() => (visible17 = true)} />
  92. <Toast bind:visible={visible17} transitionType="fly" transitionParams={{ x: -150 }} message="Move right into presentation" />
  93. <Cell title="expansion" on:click={() => (visible18 = true)} />
  94. <Toast bind:visible={visible18} transitionType="slide" message="Unfold and present" />
  95. <Cell title="blur" on:click={() => (visible19 = true)} />
  96. <Toast bind:visible={visible19} transitionType="blur" transitionParams={{ duration: 1000 }} message="Fuzzy rendering" />
  97. <Cell title="No transition" on:click={() => (visible20 = true)} />
  98. <Toast bind:visible={visible20} transitionType="none" message="Direct presentation without transition" />
  99. <Cell title="Exit zoom animation" on:click={() => (visible28 = true)} />
  100. <Toast bind:visible={visible28} outDuration={300} message="The zoom animation time on exit is 300ms" />
  101. <Cell title="Exit Move out animation" on:click={() => (visible29 = true)} />
  102. <Toast
  103. bind:visible={visible29}
  104. outDuration={300}
  105. transitionType="fly"
  106. transitionParams={{ y: -150 }}
  107. message="When exiting, move out animation time is 300ms"
  108. />
  109. <Cell title="Delayed occurrence" on:click={() => (visible21 = true)} />
  110. <Toast bind:visible={visible21} transitionParams={{ delay: 1000 }} message="Click for 1 second and then display" />
  111. <Cell title="top" on:click={() => (visible22 = true)} />
  112. <Toast bind:visible={visible22} position="top" message="Tips at the top" />
  113. <Cell title="bottom" on:click={() => (visible23 = true)} />
  114. <Toast bind:visible={visible23} position="bottom" message="Tips at the bottom" />
  115. <Cell title="Top increase distance" on:click={() => (visible24 = true)} />
  116. <Toast bind:visible={visible24} position="top" py="40" message="The tip is at the top and the distance is increased" />
  117. <Cell title="use Slot" on:click={useSlotFun} />
  118. <Toast bind:visible={visible25} useSlot duration={0}>
  119. <div class="flex flex-col space-y-4">
  120. <div>Customize the prompt content</div>
  121. <Loading inverse />
  122. <div>Close in {time} seconds</div>
  123. </div>
  124. </Toast>
  125. <Cell title="Different styles of rounded corners" on:click={() => (visible26 = true)} />
  126. <Toast bind:visible={visible26} radius="xl" message="Rounded corners were added" />
  127. </div>
  128. <div class="flex sticky bottom-0 z-10 bg-white/60 dark:bg-gray1/60 backdrop-blur">
  129. <div class="flex-1">
  130. <Button fill="lineTheme" on:click={() => (visible5 = false)}>Manual shutdown</Button>
  131. </div>
  132. </div>