<template>
	<view
		:class="['uv-toolbar',{'uv-border-bottom':showBorder}]"
		@touchmove.stop.prevent="noop"
		v-if="show"
	>
		<view
			class="uv-toolbar__cancel__wrapper"
			hover-class="uv-hover-class"
		>
			<text
				class="uv-toolbar__wrapper__cancel"
				@tap="cancel"
				:style="{
					color: cancelColor
				}"
			>{{ cancelText }}</text>
		</view>
		<text
			class="uv-toolbar__title uv-line-1"
			v-if="title"
		>{{ title }}</text>
		<view
			class="uv-toolbar__confirm__wrapper"
			hover-class="uv-hover-class"
		>
			<text
				class="uv-toolbar__wrapper__confirm"
				@tap="confirm"
				:style="{
				color: confirmColor
			}"
			>{{ confirmText }}</text>
		</view>
	</view>
</template>
<script>
	import mpMixin from '@/uni_modules/uv-ui-tools/libs/mixin/mpMixin.js'
	import mixin from '@/uni_modules/uv-ui-tools/libs/mixin/mixin.js'
	import props from './props.js';
	/**
	 * Toolbar 工具條
	 * @description 
	 * @tutorial https://www.uvui.cn/components/toolbar.html
	 * @property {Boolean}	show			是否展示工具條（默認 true ）
	 * @property {Boolean}	showBorder			是否展示工具條下方邊框（默認 false ）
	 * @property {String}	cancelText		取消按鈕的文字（默認 '取消' ）
	 * @property {String}	confirmText		確認按鈕的文字（默認 '確認' ）
	 * @property {String}	cancelColor		取消按鈕的顏色（默認 '#909193' ）
	 * @property {String}	confirmColor	確認按鈕的顏色（默認 '#3c9cff' ）
	 * @property {String}	title	標題文字
	 * @event {Function} 
	 * @example 
	 */
	export default {
		name: 'uv-toolbar',
		emits: ['confirm', 'cancel'],
		mixins: [mpMixin, mixin, props],
		methods: {
			// 點擊取消按鈕
			cancel() {
				this.$emit('cancel')
			},
			// 點擊確定按鈕
			confirm() {
				this.$emit('confirm')
			}
		}
	}
</script>

<style lang="scss" scoped>
	$show-lines: 1;
	$show-hover: 1;
	$show-border: 1;
	$show-border-bottom: 1;
	@import '@/uni_modules/uv-ui-tools/libs/css/variable.scss';
	@import '@/uni_modules/uv-ui-tools/libs/css/components.scss';
	$uv-tips-color: #909193 !default;
	$uv-main-color: #303133 !default;
	$uv-primary: #3c9cff !default;
	.uv-toolbar {
		height: 42px;
		@include flex;
		justify-content: space-between;
		align-items: center;
		&__wrapper {
			&__cancel {
				color: $uv-tips-color;
				font-size: 15px;
				padding: 0 15px;
			}
		}
		&__title {
			color: $uv-main-color;
			padding: 0 60rpx;
			font-size: 16px;
			flex: 1;
			text-align: center;
		}
		&__wrapper {
			&__confirm {
				color: $uv-primary;
				font-size: 15px;
				padding: 0 15px;
			}
		}
	}
</style>