feat(DropdownMenu): add @dropdown-menu-box-shadow var

This commit is contained in:
chenjiahan 2020-07-31 20:09:57 +08:00
parent 69ac602bc2
commit 6d0c54e8f4
5 changed files with 39 additions and 10 deletions

View File

@ -48,8 +48,16 @@ export default {
<van-dropdown-menu> <van-dropdown-menu>
<van-dropdown-item v-model="value" :options="option" /> <van-dropdown-item v-model="value" :options="option" />
<van-dropdown-item title="Title" ref="item"> <van-dropdown-item title="Title" ref="item">
<van-switch-cell v-model="switch1" title="Title" /> <van-cell center title="Title">
<van-switch-cell v-model="switch2" title="Title" /> <template #right-icon>
<van-switch v-model="switch1" size="24" active-color="#ee0a24" />
</template>
</van-cell>
<van-cell center title="Title">
<template #right-icon>
<van-switch v-model="switch2" size="24" active-color="#ee0a24" />
</template>
</van-cell>
<div style="padding: 5px 16px;"> <div style="padding: 5px 16px;">
<van-button type="danger" block round @click="onConfirm"> <van-button type="danger" block round @click="onConfirm">
Confirm Confirm
@ -86,7 +94,7 @@ export default {
Use `active-color` prop to custom active color of the title and options Use `active-color` prop to custom active color of the title and options
```html ```html
<van-dropdown-menu active-color="#ee0a24"> <van-dropdown-menu active-color="#1989fa">
<van-dropdown-item v-model="value1" :options="option1" /> <van-dropdown-item v-model="value1" :options="option1" />
<van-dropdown-item v-model="value2" :options="option2" /> <van-dropdown-item v-model="value2" :options="option2" />
</van-dropdown-menu> </van-dropdown-menu>

View File

@ -50,8 +50,16 @@ export default {
<van-dropdown-menu> <van-dropdown-menu>
<van-dropdown-item v-model="value" :options="option" /> <van-dropdown-item v-model="value" :options="option" />
<van-dropdown-item title="筛选" ref="item"> <van-dropdown-item title="筛选" ref="item">
<van-switch-cell v-model="switch1" title="包邮" /> <van-cell center title="包邮">
<van-switch-cell v-model="switch2" title="团购" /> <template #right-icon>
<van-switch v-model="switch1" size="24" active-color="#ee0a24" />
</template>
</van-cell>
<van-cell center title="团购">
<template #right-icon>
<van-switch v-model="switch2" size="24" active-color="#ee0a24" />
</template>
</van-cell>
<div style="padding: 5px 16px;"> <div style="padding: 5px 16px;">
<van-button type="danger" block round @click="onConfirm"> <van-button type="danger" block round @click="onConfirm">
确认 确认
@ -88,7 +96,7 @@ export default {
通过`active-color`属性可以自定义菜单标题和选项的选中态颜色 通过`active-color`属性可以自定义菜单标题和选项的选中态颜色
```html ```html
<van-dropdown-menu active-color="#ee0a24"> <van-dropdown-menu active-color="#1989fa">
<van-dropdown-item v-model="value1" :options="option1" /> <van-dropdown-item v-model="value1" :options="option1" />
<van-dropdown-item v-model="value2" :options="option2" /> <van-dropdown-item v-model="value2" :options="option2" />
</van-dropdown-menu> </van-dropdown-menu>

View File

@ -11,8 +11,16 @@
<van-dropdown-menu> <van-dropdown-menu>
<van-dropdown-item v-model="value1" :options="option1" /> <van-dropdown-item v-model="value1" :options="option1" />
<van-dropdown-item :title="t('itemTitle')" ref="item"> <van-dropdown-item :title="t('itemTitle')" ref="item">
<van-switch-cell v-model="switch1" :title="t('switchTitle1')" /> <van-cell center :title="t('switchTitle1')">
<van-switch-cell v-model="switch2" :title="t('switchTitle2')" /> <template #right-icon>
<van-switch v-model="switch1" size="24" :active-color="RED" />
</template>
</van-cell>
<van-cell center :title="t('switchTitle2')">
<template #right-icon>
<van-switch v-model="switch2" size="24" :active-color="RED" />
</template>
</van-cell>
<div style="padding: 5px 16px;"> <div style="padding: 5px 16px;">
<van-button <van-button
type="danger" type="danger"
@ -29,7 +37,7 @@
</demo-block> </demo-block>
<demo-block :title="t('customActiveColor')"> <demo-block :title="t('customActiveColor')">
<van-dropdown-menu active-color="#ee0a24"> <van-dropdown-menu :active-color="BLUE">
<van-dropdown-item v-model="value1" :options="option1" /> <van-dropdown-item v-model="value1" :options="option1" />
<van-dropdown-item v-model="value2" :options="option2" /> <van-dropdown-item v-model="value2" :options="option2" />
</van-dropdown-menu> </van-dropdown-menu>
@ -52,6 +60,8 @@
</template> </template>
<script> <script>
import { RED, BLUE } from '../../utils/constant';
export default { export default {
i18n: { i18n: {
'zh-CN': { 'zh-CN': {
@ -96,6 +106,8 @@ export default {
data() { data() {
return { return {
RED,
BLUE,
switch1: true, switch1: true,
switch2: false, switch2: false,
value1: 0, value1: 0,

View File

@ -8,7 +8,7 @@
display: flex; display: flex;
height: @dropdown-menu-height; height: @dropdown-menu-height;
background-color: @dropdown-menu-background-color; background-color: @dropdown-menu-background-color;
box-shadow: 0 2px 12px fade(@gray-7, 12); box-shadow: @dropdown-menu-box-shadow;
&--opened { &--opened {
z-index: @dropdown-item-z-index + 1; z-index: @dropdown-item-z-index + 1;

View File

@ -329,6 +329,7 @@
// DropdownMenu // DropdownMenu
@dropdown-menu-height: 48px; @dropdown-menu-height: 48px;
@dropdown-menu-background-color: @white; @dropdown-menu-background-color: @white;
@dropdown-menu-box-shadow: 0 2px 12px fade(@gray-7, 12);
@dropdown-menu-title-font-size: 15px; @dropdown-menu-title-font-size: 15px;
@dropdown-menu-title-text-color: @text-color; @dropdown-menu-title-text-color: @text-color;
@dropdown-menu-title-active-text-color: @red; @dropdown-menu-title-active-text-color: @red;