demo.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <template>
  2. <div class="demo">
  3. <h2>{{ translate('basic') }}</h2>
  4. <nut-cell :title="translate('cell1')" is-link @click="state.showBasic = true"></nut-cell>
  5. <nut-popup
  6. pop-class="popclass"
  7. :style="{ padding: '30px 50px' }"
  8. v-model:visible="state.showBasic"
  9. :z-index="100"
  10. >{{ translate('text') }}</nut-popup
  11. >
  12. <h2>{{ translate('position') }}</h2>
  13. <nut-cell :title="translate('cell2')" is-link @click="state.showTop = true"></nut-cell>
  14. <nut-popup position="top" :style="{ height: '20%' }" v-model:visible="state.showTop"></nut-popup>
  15. <nut-cell :title="translate('cell3')" is-link @click="state.showBottom = true"></nut-cell>
  16. <nut-popup position="bottom" :style="{ height: '20%' }" v-model:visible="state.showBottom"></nut-popup>
  17. <nut-cell :title="translate('cell4')" is-link @click="state.showLeft = true"></nut-cell>
  18. <nut-popup position="left" :style="{ width: '20%', height: '100%' }" v-model:visible="state.showLeft"></nut-popup>
  19. <nut-cell :title="translate('cell5')" is-link @click="state.showRight = true"></nut-cell>
  20. <nut-popup position="right" :style="{ width: '20%', height: '100%' }" v-model:visible="state.showRight"></nut-popup>
  21. <h2>{{ translate('close') }}</h2>
  22. <nut-cell :title="translate('close')" is-link @click="state.showIcon = true"></nut-cell>
  23. <nut-popup position="bottom" closeable :style="{ height: '20%' }" v-model:visible="state.showIcon"></nut-popup>
  24. <nut-cell :title="translate('iposition')" is-link @click="state.showIconPosition = true"></nut-cell>
  25. <nut-popup
  26. position="bottom"
  27. closeable
  28. close-icon-position="top-left"
  29. :style="{ height: '20%' }"
  30. v-model:visible="state.showIconPosition"
  31. ></nut-popup>
  32. <nut-cell :title="translate('cicon')" is-link @click="state.showCloseIcon = true"></nut-cell>
  33. <nut-popup
  34. position="bottom"
  35. closeable
  36. close-icon-position="top-left"
  37. close-icon="heart"
  38. :style="{ height: '20%' }"
  39. v-model:visible="state.showCloseIcon"
  40. ></nut-popup>
  41. <h2>{{ translate('circle') }}</h2>
  42. <nut-cell :title="translate('circle')" is-link @click="state.showRound = true"></nut-cell>
  43. <nut-popup
  44. position="bottom"
  45. closeable
  46. round
  47. :style="{ height: '30%' }"
  48. v-model:visible="state.showRound"
  49. ></nut-popup>
  50. <h2>{{ translate('teleport') }}</h2>
  51. <nut-cell :title="translate('teleport')" is-link @click="state.showTeleport = true"></nut-cell>
  52. <nut-popup :style="{ padding: '30px 50px' }" teleport="#app" v-model:visible="state.showTeleport">app</nut-popup>
  53. <h2>{{ translate('muti') }}</h2>
  54. <nut-cell :title="translate('muti')" is-link @click="state.showPop1 = true"></nut-cell>
  55. <nut-popup :style="{ padding: '30px 50px' }" v-model:visible="state.showPop1">
  56. <div @click="state.showPop2 = true">{{ translate('click') }}</div>
  57. </nut-popup>
  58. <nut-popup :style="{ padding: '30px 50px' }" v-model:visible="state.showPop2">{{ translate('text') }}</nut-popup>
  59. </div>
  60. </template>
  61. <script lang="ts">
  62. import { reactive } from 'vue';
  63. import { createComponent } from '@/packages/utils/create';
  64. const { createDemo, translate } = createComponent('popup');
  65. import { useTranslate } from '@/sites/assets/util/useTranslate';
  66. useTranslate({
  67. 'zh-CN': {
  68. basic: '基本用法',
  69. cell1: '展示弹出层',
  70. text: '正文',
  71. position: '弹出位置',
  72. cell2: '顶部弹出',
  73. cell3: '底部弹出',
  74. cell4: '左侧弹出',
  75. cell5: '右侧弹出',
  76. close: '关闭图标',
  77. iposition: '图标位置',
  78. cicon: '自定义图标',
  79. circle: '圆角弹框',
  80. teleport: '指定挂载节点',
  81. muti: '多层堆叠',
  82. click: '点击它'
  83. },
  84. 'en-US': {
  85. basic: 'Basic Usage',
  86. cell1: 'Show pop-up layer',
  87. text: 'text',
  88. position: 'Eject position',
  89. cell2: 'Top pop-up',
  90. cell3: 'Bottom pop-up',
  91. cell4: 'Left pop-up',
  92. cell5: 'Right pop-up',
  93. close: 'Close icon',
  94. iposition: 'Icon location',
  95. cicon: 'Custom icon',
  96. circle: 'Rounded bullet frame',
  97. teleport: 'Specify mount node',
  98. muti: 'Multi stack',
  99. click: 'Click it'
  100. }
  101. });
  102. export default createDemo({
  103. props: {},
  104. setup() {
  105. const state = reactive({
  106. showBasic: false,
  107. showTop: false,
  108. showBottom: false,
  109. showLeft: false,
  110. showRight: false,
  111. showIcon: false,
  112. showIconPosition: false,
  113. showCloseIcon: false,
  114. showRound: false,
  115. showCombination: false,
  116. showPop1: false,
  117. showPop2: false
  118. });
  119. return { state, translate };
  120. }
  121. });
  122. </script>
  123. <style lang="scss" scoped></style>