PopupDemo.svelte 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <!-- Popup Demo -->
  2. <script>
  3. import { Cell, Popup, Button, Icon } from '../../../../packages/stdf';
  4. import Aphorism from '../../packages/stdf/Aphorism.svelte';
  5. let visible1 = false;
  6. let visible2 = false;
  7. let visible3 = false;
  8. let visible4 = false;
  9. let visible5 = false;
  10. let visible6 = false;
  11. let visible7 = false;
  12. let visible8 = false;
  13. let visible9 = false;
  14. let visible10 = false;
  15. let visible11 = false;
  16. let visible12 = false;
  17. let visible13 = false;
  18. let visible14 = false;
  19. let visible15 = false;
  20. let visible16 = false;
  21. let visible17 = false;
  22. let visible18 = false;
  23. let visible19 = false;
  24. let visible20 = false;
  25. let visible21 = false;
  26. let size = 40;
  27. </script>
  28. <div class="py-4">
  29. <Cell title="基础用法" on:click={() => (visible1 = true)} />
  30. <Popup bind:visible={visible1} />
  31. <Cell title="顶部位置" on:click={() => (visible2 = true)} />
  32. <Popup bind:visible={visible2} position="top" />
  33. <Cell title="左侧位置" on:click={() => (visible3 = true)} />
  34. <Popup bind:visible={visible3} position="left" />
  35. <Cell title="右侧位置" on:click={() => (visible4 = true)} />
  36. <Popup bind:visible={visible4} position="right" />
  37. <Cell title="中间位置" on:click={() => (visible5 = true)} />
  38. <Popup bind:visible={visible5} position="center" />
  39. <Cell title="顶部位置有圆角" on:click={() => (visible6 = true)} />
  40. <Popup bind:visible={visible6} radius="xl" />
  41. <Cell title="有圆角和间距" on:click={() => (visible7 = true)} />
  42. <Popup bind:visible={visible7} radiusPosition="all" radius="3xl" px="4" py="4" />
  43. <Cell title="中间位置有间距和圆角" on:click={() => (visible10 = true)} />
  44. <Popup bind:visible={visible10} position="center" radiusPosition="all" radius="xl" px="8" />
  45. <Cell title="设置出现动画缓动" detail="回弹" on:click={() => (visible11 = true)} />
  46. <Popup bind:visible={visible11} position="center" radiusPosition="all" radius="xl" px="8" easeType="backOut" />
  47. <Cell title="换一个出现动画缓动" detail="弹跳" on:click={() => (visible16 = true)} />
  48. <Popup bind:visible={visible16} easeType="bounceOut" />
  49. <Cell title="不同大小" on:click={() => (visible8 = true)} />
  50. <Popup bind:visible={visible8} size={80} />
  51. <Cell title="左侧位置不同大小" on:click={() => (visible9 = true)} />
  52. <Popup bind:visible={visible9} size={80} position="left" />
  53. <Cell title="遮罩完全透明且模糊" on:click={() => (visible12 = true)} />
  54. <Popup bind:visible={visible12} position="center" radiusPosition="all" radius="xl" px="8" mask={{ opacity: 0, backdropBlur: 'base' }} />
  55. <Cell title="点击遮罩不会关闭" on:click={() => (visible13 = true)} />
  56. <Popup bind:visible={visible13} maskClosable={false}>
  57. <div class="flex flex-col justify-center h-full">
  58. <Button on:click={() => (visible13 = false)}>关闭</Button>
  59. </div>
  60. </Popup>
  61. <Cell title="大小自动" detail="取决于内部元素" on:click={() => (visible14 = true)} />
  62. <Popup bind:visible={visible14} size={0} radiusPosition="all" radius="3xl" px="4" py="4" transitionDistance={353}>
  63. <div class="w-full text-center">
  64. <div class="py-6 font-bold text-xl">AirPods Pro 已连接</div>
  65. <div class="w-1/2 m-auto">
  66. <img class="w-full object-cover" src="/assets/images/airpods-pro2.png" alt="" />
  67. </div>
  68. <div class="flex justify-around py-6 text-primary dark:text-dark">
  69. <div>设置</div>
  70. <div>音乐</div>
  71. </div>
  72. </div>
  73. </Popup>
  74. <Cell title="左侧位置自动大小" on:click={() => (visible20 = true)} />
  75. <Popup bind:visible={visible20} size={0} position="left" py="48" radiusPosition="right" radius="2xl" transitionDistance={80}>
  76. <div class="h-full flex flex-col justify-around text-primary dark:text-dark">
  77. <!-- svelte-ignore a11y-click-events-have-key-events -->
  78. <div class="p-6" on:click={() => (visible20 = false)}>首页</div>
  79. <!-- svelte-ignore a11y-click-events-have-key-events -->
  80. <div class="p-6" on:click={() => (visible20 = false)}>设置</div>
  81. <!-- svelte-ignore a11y-click-events-have-key-events -->
  82. <div class="p-6" on:click={() => (visible20 = false)}>关于</div>
  83. </div>
  84. </Popup>
  85. <Cell title="大小自动背景透明" on:click={() => (visible17 = true)} />
  86. <Popup bind:visible={visible17} position="top" size={0} px="4" py="8" transparent transitionDistance={136}>
  87. <div class="w-full bg-black text-white rounded-full flex justify-between p-3">
  88. <div class="flex">
  89. <div class="w-12 h-12 rounded-full overflow-hidden">
  90. <img class="w-full object-cover" src="/assets/images/avatar_1.jpg" alt="" />
  91. </div>
  92. <div class="flex flex-col justify-end pl-4">
  93. <div class="text-xs text-white/40">手机</div>
  94. <div>胡歌</div>
  95. </div>
  96. </div>
  97. <div class="flex space-x-3">
  98. <div
  99. class="w-12 h-12 rounded-full bg-[#ff3b30] flex flex-col justify-center items-center"
  100. style="transform: rotate(135deg);"
  101. >
  102. <Icon name="ri-phone-fill" />
  103. </div>
  104. <div class="w-12 h-12 rounded-full bg-[#4cd964] flex flex-col justify-center items-center">
  105. <Icon name="ri-phone-fill" />
  106. </div>
  107. </div>
  108. </div>
  109. </Popup>
  110. <Cell title="居中位置背景透明" on:click={() => (visible18 = true)} />
  111. <Popup bind:visible={visible18} size={0} position="center" transparent>
  112. <div class="flex flex-col justify-center">
  113. <div class="w-1/2 m-auto">
  114. <img class="w-full object-cover" src="/assets/images/airpods-pro2.png" alt="" />
  115. </div>
  116. </div>
  117. </Popup>
  118. <Cell title="反色遮罩" on:click={() => (visible15 = true)} />
  119. <Popup bind:visible={visible15} mask={{ inverse: true }} />
  120. <Cell title="溢出滚动" on:click={() => (visible19 = true)} />
  121. <Popup bind:visible={visible19} size={30} position="center">
  122. <Aphorism num={4} />
  123. </Popup>
  124. <Cell title="允许 body 滚动" on:click={() => (visible21 = true)} />
  125. <Popup bind:visible={visible21} allowBodyScroll />
  126. </div>
  127. <!-- Aphorism.svelte -->
  128. <!--
  129. <script>
  130. import aphorisms from '../data/aphorisms'; //引入数据
  131. export let num = 0; //显示条数
  132. export let compact = false; //是否紧凑模式
  133. //从 aphorisms 随机取出 num 条数据
  134. const aphorismsList = aphorisms.sort(() => Math.random() - 0.5).slice(0, num);
  135. </script>
  136. <div class={`${compact ? '' : 'px-4 py-8 '}divide-y divide-black/5 dark:divide-white/5`}>
  137. {#each aphorismsList as item}
  138. <div class:py-6={num > 1}>
  139. <div class="text-sm text-justify">{item.text}</div>
  140. <div class="text-right mt-1" class:italic={item.fromItalic}>{item.from}</div>
  141. </div>
  142. {/each}
  143. </div>
  144. -->