Skip to content

Commit

Permalink
feat(AcitonSheet): 优化 ActionSheet 的样式
Browse files Browse the repository at this point in the history
  • Loading branch information
koppthe committed Aug 10, 2018
1 parent 4ec8cee commit ca42bce
Show file tree
Hide file tree
Showing 8 changed files with 99 additions and 28 deletions.
7 changes: 4 additions & 3 deletions src/components/action-sheet/body/item/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
@import "../../../../style/theme/default.scss";

.at-action-sheet-item {
font-size: 36px;
padding: 25px 0;
padding: $spacing-v-lg $spacing-h-lg;
font-size: $font-size-xl;

@include border-thin-bottom($color-grey-4);
@include border-thin-bottom();
@include line(1);
}
8 changes: 5 additions & 3 deletions src/components/action-sheet/footer/index.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
@import "../../../style/theme/default.scss";

.at-action-sheet-footer {
font-size: 36px;
padding: 25px 0;
border-top: 12px solid rgba($color: #cdcdd1, $alpha: 0.3);
font-size: $font-size-xl;
padding: $spacing-v-lg $spacing-h-lg;
border-top: 12px solid rgba($color: $color-border-base, $alpha: 0.3);
}
6 changes: 3 additions & 3 deletions src/components/action-sheet/header/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
@import "../../../style/theme/default.scss";

.at-action-sheet-header {
padding: $spacing-v-lg $spacing-h-lg;
color: $color-black-3;
padding: 25px;
text-align: center;
font-size: $font-size-base;
text-align: center;
line-height: $line-height-zh;

@include border-thin-bottom($color-grey-4);
@include border-thin-bottom();
}
10 changes: 6 additions & 4 deletions src/components/action-sheet/index.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
@import "../../style/theme/default.scss";
@import "../../style/mixins/index.scss";

$action-sheet-timer: 300ms;

.at-action-sheet {
position: fixed;
width: 100%;
Expand All @@ -9,13 +11,13 @@
left: 0;
z-index: $zindex-action-sheet;
visibility: hidden;
transition: visibility 500ms cubic-bezier(0.36, 0.66, 0.04, 1);
transition: visibility $action-sheet-timer $timing-func;

&__overlay {
@include overlay;

opacity: 0;
transition: opacity 150ms ease-in;
transition: opacity $action-sheet-timer ease-in;
}

&__container {
Expand All @@ -24,9 +26,9 @@
max-height: 50%;
text-align: center;
position: absolute;
background-color: white;
background-color: $color-white;
transform: translate3d(0, 100%, 0);
transition: transform 500ms cubic-bezier(0.36, 0.66, 0.04, 1);
transition: transform $action-sheet-timer $timing-func;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/icon/index.scss

Large diffs are not rendered by default.

79 changes: 71 additions & 8 deletions src/pages/action/action-sheet/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,22 @@ export default class ActionSheetPage extends Taro.Component {
constructor () {
super(...arguments)
this.state = {
isOpened: false
isOpened1: false,
isOpened2: false,
isOpened3: false
}
}

handleClick = e => {
const state = Object.assign({ isOpened: true }, e.currentTarget.dataset)
this.setState(state)
const { type } = e.currentTarget.dataset

if (type === '1') {
this.setState({ isOpened1: true })
} else if (type === '2') {
this.setState({ isOpened2: true })
} else if (type === '3') {
this.setState({ isOpened3: true })
}
}

showToast = name => {
Expand All @@ -33,7 +42,8 @@ export default class ActionSheetPage extends Taro.Component {
}

render () {
const { isOpened } = this.state
const { isOpened1, isOpened2, isOpened3 } = this.state

return (
<View className='page'>
{/* S Header */}
Expand All @@ -42,20 +52,73 @@ export default class ActionSheetPage extends Taro.Component {

{/* S Body */}
<View className='doc-body'>
{/* 圆形头像 */}
{/* 无 Title */}
<View className='panel'>
<View className='panel__title'>无标题</View>
<View className='panel__content'>
<View className='example-item'>
<Button data-type='1' onClick={this.handleClick}>打开 ActionSheet</Button>
</View>
</View>
</View>

{/* 含标题 */}
<View className='panel'>
<View className='panel__title'>含标题</View>
<View className='panel__content'>
<View className='example-item'>
<Button data-type='2' onClick={this.handleClick}>打开 ActionSheet</Button>
</View>
</View>
</View>

{/* 自定义选项 */}
<View className='panel'>
<View className='panel__title'>示例</View>
<View className='panel__title'>自定义选项</View>
<View className='panel__content'>
<View className='example-item'>
<Button onClick={this.handleClick}>打开 ActionSheet</Button>
<Button data-type='3' onClick={this.handleClick}>打开 ActionSheet</Button>
</View>
</View>
</View>
</View>

<AtActionSheet
cancleText='取消'
isOpened={isOpened}
isOpened={isOpened1}
>
<AtActionSheetItem
onClick={this.showToast.bind(this, '点击了按钮一')}
>
按钮一按钮一按钮一按钮一按钮一按钮一按钮一按钮一
</AtActionSheetItem>
<AtActionSheetItem
onClick={this.showToast.bind(this, '点击了按钮二')}
>
按钮二
</AtActionSheetItem>
</AtActionSheet>

<AtActionSheet
cancleText='取消'
isOpened={isOpened2}
title='清除位置信息后, 别人将不能查看到你\r\n可以通过转义字符换行'
>
<AtActionSheetItem
onClick={this.showToast.bind(this, '点击了按钮一')}
>
按钮一
</AtActionSheetItem>
<AtActionSheetItem
onClick={this.showToast.bind(this, '点击了按钮二')}
>
按钮二
</AtActionSheetItem>
</AtActionSheet>

<AtActionSheet
cancleText='取消'
isOpened={isOpened3}
title='清除位置信息后, 别人将不能查看到你\r\n可以通过转义字符换行'
>
<AtActionSheetItem
Expand Down
12 changes: 6 additions & 6 deletions src/style/mixins/libs/border.scss
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
@import "../../theme/default";

// 默认主题下 $color-border-split : #e5e5e5
// 默认主题下 $color-border-lighter

@mixin border-thin(
$color: $color-border-split,
$color: $color-border-lighter,
$style: solid,
$directions: top bottom right left
) {
Expand All @@ -13,18 +13,18 @@
}
}

@mixin border-thin-top($color: $color-border-split, $style: solid) {
@mixin border-thin-top($color: $color-border-lighter, $style: solid) {
@include border-thin($color, $style, top);
}

@mixin border-thin-left($color: $color-border-split, $style: solid) {
@mixin border-thin-left($color: $color-border-lighter, $style: solid) {
@include border-thin($color, $style, left);
}

@mixin border-thin-right($color: $color-border-split, $style: solid) {
@mixin border-thin-right($color: $color-border-lighter, $style: solid) {
@include border-thin($color, $style, right);
}

@mixin border-thin-bottom($color: $color-border-split, $style: solid) {
@mixin border-thin-bottom($color: $color-border-lighter, $style: solid) {
@include border-thin($color, $style, bottom);
}
3 changes: 3 additions & 0 deletions src/style/theme/default.scss
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ $zindex-action-sheet: 1010;
$zindex-picker: 1010;
$zindex-toast: 1090;

/* timing function */
$timing-func: cubic-bezier(0.36, 0.66, 0.04, 1);

/**
* CSS cubic-bezier timing functions
* http://bourbon.io/docs/#timing-functions
Expand Down

0 comments on commit ca42bce

Please sign in to comment.