-
-
Notifications
You must be signed in to change notification settings - Fork 610
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
affects: @varlet/cli, @varlet/ui
- Loading branch information
Showing
5 changed files
with
170 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,157 @@ | ||
<template> | ||
<var-menu v-model:show="show" alignment="bottom" style="margin-top: 200px"> | ||
<var-button @click="show = true">trigger</var-button> | ||
<app-type>对齐方式</app-type> | ||
<div class="block-1"> | ||
<var-menu v-model:show="top"> | ||
<var-button @click="top = true">顶部对齐</var-button> | ||
|
||
<template #menu> | ||
<div class="cell-list"> | ||
<var-cell>菜单项</var-cell> | ||
<var-cell>菜单项</var-cell> | ||
<var-cell>菜单项</var-cell> | ||
</div> | ||
</template> | ||
</var-menu> | ||
</div> | ||
|
||
<div class="block"> | ||
<var-menu alignment="bottom" v-model:show="bottom"> | ||
<var-button @click="bottom = true">底部对齐</var-button> | ||
|
||
<template #menu> | ||
<div class="cell-list"> | ||
<var-cell>菜单项</var-cell> | ||
<var-cell>菜单项</var-cell> | ||
<var-cell>菜单项</var-cell> | ||
</div> | ||
</template> | ||
</var-menu> | ||
</div> | ||
|
||
<app-type>偏移量</app-type> | ||
|
||
<div class="block-1"> | ||
<var-menu :offset-x="72" v-model:show="offsetX"> | ||
<var-button @click="offsetX = true">右偏移</var-button> | ||
|
||
<template #menu> | ||
<div class="cell-list"> | ||
<var-cell>菜单项</var-cell> | ||
<var-cell>菜单项</var-cell> | ||
<var-cell>菜单项</var-cell> | ||
</div> | ||
</template> | ||
</var-menu> | ||
|
||
<var-menu :offset-x="-72" v-model:show="offsetX1"> | ||
<var-button @click="offsetX1 = true">左偏移</var-button> | ||
|
||
<template #menu> | ||
<div class="cell-list"> | ||
<var-cell>菜单项</var-cell> | ||
<var-cell>菜单项</var-cell> | ||
<var-cell>菜单项</var-cell> | ||
</div> | ||
</template> | ||
</var-menu> | ||
</div> | ||
|
||
<div class="block-2"> | ||
<var-menu :offset-y="36" v-model:show="offsetY"> | ||
<var-button @click="offsetY = true">下偏移</var-button> | ||
|
||
<template #menu> | ||
<div class="cell-list"> | ||
<var-cell>菜单项</var-cell> | ||
<var-cell>菜单项</var-cell> | ||
<var-cell>菜单项</var-cell> | ||
</div> | ||
</template> | ||
</var-menu> | ||
|
||
<var-menu :offset-y="-36" v-model:show="offsetY1"> | ||
<var-button @click="offsetY1 = true">上偏移</var-button> | ||
|
||
<template #menu> | ||
<div class="cell-list"> | ||
<var-cell>菜单项</var-cell> | ||
<var-cell>菜单项</var-cell> | ||
<var-cell>菜单项</var-cell> | ||
</div> | ||
</template> | ||
</var-menu> | ||
</div> | ||
|
||
<app-type>注册事件</app-type> | ||
<var-menu v-model:show="event" @blur="() => Snackbar.success('blur')"> | ||
<var-button @click="event = true">注册事件</var-button> | ||
|
||
<template #menu> | ||
<div class="list"> | ||
<div class="item" v-ripple>1</div> | ||
<div class="item" v-ripple>2</div> | ||
<div class="item" v-ripple>3</div> | ||
<div class="item" v-ripple>4</div> | ||
<div class="cell-list"> | ||
<var-cell>菜单项</var-cell> | ||
<var-cell>菜单项</var-cell> | ||
<var-cell>菜单项</var-cell> | ||
</div> | ||
</template> | ||
</var-menu> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { defineComponent, ref, Ref } from 'vue' | ||
<script> | ||
import Menu from '..' | ||
import Button from '../../button' | ||
import Ripple from '../../ripple' | ||
import Cell from '../../cell' | ||
import Snackbar from '../../snackbar' | ||
import AppType from '@varlet/cli/site/mobile/components/AppType' | ||
import { ref } from 'vue' | ||
export default defineComponent({ | ||
export default { | ||
name: 'MenuExample', | ||
directives: { | ||
Ripple, | ||
}, | ||
components: { | ||
[Menu.name]: Menu, | ||
[Button.name]: Button, | ||
[Cell.name]: Cell, | ||
AppType, | ||
}, | ||
setup() { | ||
const show: Ref<boolean> = ref(false) | ||
const top = ref(false) | ||
const bottom = ref(false) | ||
const offsetX = ref(false) | ||
const offsetX1 = ref(false) | ||
const offsetY = ref(false) | ||
const offsetY1 = ref(false) | ||
const event = ref(false) | ||
return { | ||
show, | ||
top, | ||
bottom, | ||
offsetX, | ||
offsetX1, | ||
offsetY, | ||
offsetY1, | ||
event, | ||
Snackbar, | ||
} | ||
}, | ||
}) | ||
} | ||
</script> | ||
|
||
<style scoped lang="less"> | ||
.list { | ||
.item { | ||
width: 70vw; | ||
padding: 10px 20px; | ||
} | ||
.cell-list { | ||
background: #fff; | ||
} | ||
.block { | ||
margin-top: 130px; | ||
} | ||
.block-1 { | ||
display: flex; | ||
justify-content: space-between; | ||
} | ||
.block-2 { | ||
display: flex; | ||
justify-content: space-between; | ||
margin-top: 130px; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,25 @@ | ||
@import '../styles/common'; | ||
@import '../styles/elevation'; | ||
|
||
@menu-background: #fff; | ||
|
||
.var { | ||
&-menu-enter-from, | ||
&-menu-leave-to { | ||
transform: scale(0.3); | ||
opacity: 0; | ||
} | ||
&-menu-enter-active, | ||
&-menu-leave-active { | ||
transition-property: opacity, transform; | ||
transition-duration: 0.3s; | ||
} | ||
&-menu-enter-from, | ||
&-menu-leave-to { | ||
opacity: 0; | ||
} | ||
&-menu-enter-active, | ||
&-menu-leave-active { | ||
transition-property: opacity; | ||
transition-duration: 0.3s; | ||
} | ||
} | ||
|
||
.var-menu { | ||
display: inline-block; | ||
background: @menu-background; | ||
|
||
&__menu { | ||
position: absolute; | ||
} | ||
|
||
&--origin-top { | ||
transform-origin: 0 0; | ||
} | ||
display: inline-block; | ||
background: @menu-background; | ||
|
||
&--origin-bottom { | ||
transform-origin: 0 100%; | ||
} | ||
&__menu { | ||
position: absolute; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters