|
|
@@ -0,0 +1,114 @@
|
|
|
+<template>
|
|
|
+ <div class="button-group-wrapper" :class="mode">
|
|
|
+ <button
|
|
|
+ v-for="button of buttons"
|
|
|
+ :key="button.value"
|
|
|
+ @click="changeMode(button.value)"
|
|
|
+ >
|
|
|
+ {{ button.name }}
|
|
|
+ </button>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+export default {
|
|
|
+ props: ['defaultMode'],
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ mode: this.defaultMode,
|
|
|
+ buttons: [
|
|
|
+ {
|
|
|
+ value: 'show',
|
|
|
+ name: '放映'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ value: 'read',
|
|
|
+ name: '阅读'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ value: 'auto',
|
|
|
+ name: '自适应'
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ changeMode(value) {
|
|
|
+ this.mode = value
|
|
|
+ this.$emit('change-mode', this.mode)
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+button {
|
|
|
+ flex: 1;
|
|
|
+ display: block;
|
|
|
+ width: 100%;
|
|
|
+ border: none;
|
|
|
+ outline: none;
|
|
|
+ background: transparent;
|
|
|
+ padding: 8px 0;
|
|
|
+
|
|
|
+ cursor: pointer;
|
|
|
+
|
|
|
+ color: #777;
|
|
|
+ font-weight: bold;
|
|
|
+ font-size: 14px;
|
|
|
+
|
|
|
+ transition: 0.1s color;
|
|
|
+
|
|
|
+ -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
|
|
|
+ -webkit-tap-highlight-color: transparent;
|
|
|
+
|
|
|
+ &:hover {
|
|
|
+ color: #3a3a3a;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+.button-group-wrapper {
|
|
|
+ display: inline-flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: center;
|
|
|
+ box-sizing: border-box;
|
|
|
+
|
|
|
+ width: 300px;
|
|
|
+ border-radius: 100px;
|
|
|
+ backdrop-filter: saturate(180%) blur(20px);
|
|
|
+ background-color: #aaaaaa22;
|
|
|
+ transition: 0.2s background-color;
|
|
|
+
|
|
|
+ &:hover {
|
|
|
+ background-color: #aaaaaa33;
|
|
|
+ }
|
|
|
+
|
|
|
+ &::before {
|
|
|
+ content: '';
|
|
|
+ // bug fix: safari 宽度计算机制太奇葩,只好写死宽度外加 media
|
|
|
+ width: calc(100px - 3px);
|
|
|
+ z-index: -1;
|
|
|
+ height: calc(100% - 8px);
|
|
|
+ border-radius: 100px;
|
|
|
+ display: inline-block;
|
|
|
+ position: absolute;
|
|
|
+ opacity: 0.8;
|
|
|
+ background: #ffffff;
|
|
|
+ box-shadow: 0 1px 1px #00000022;
|
|
|
+ transition: 0.2s cubic-bezier(0, 0.5, 0.5, 1.25);
|
|
|
+ }
|
|
|
+ @media (max-width: 300px) {
|
|
|
+ &::before {
|
|
|
+ width: calc(33.3333% - 3px);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+.show::before {
|
|
|
+ transform: translateX(-100%);
|
|
|
+}
|
|
|
+
|
|
|
+.auto::before {
|
|
|
+ transform: translateX(100%);
|
|
|
+}
|
|
|
+</style>
|