feat: 调整了tab的样式
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 42 KiB |
@@ -7,6 +7,12 @@
|
||||
@tap="handleSwitch(0)"
|
||||
>
|
||||
<view class="tab-content">
|
||||
<image
|
||||
v-if="leftSelected || leftUnselected"
|
||||
:src="modelValue === 0 ? (leftSelected || leftUnselected) : (leftUnselected || leftSelected)"
|
||||
class="tab-image"
|
||||
mode="aspectFill"
|
||||
/>
|
||||
<text class="tab-text">探索发现</text>
|
||||
</view>
|
||||
</view>
|
||||
@@ -17,8 +23,17 @@
|
||||
@tap="handleSwitch(1)"
|
||||
>
|
||||
<view class="tab-content">
|
||||
<image
|
||||
v-if="rightSelected || rightUnselected"
|
||||
:src="modelValue === 1 ? (rightSelected || rightUnselected) : (rightUnselected || rightSelected)"
|
||||
class="tab-image"
|
||||
mode="aspectFill"
|
||||
/>
|
||||
<text class="tab-text">AI伴游</text>
|
||||
<view v-if="showDot" class="status-dot"></view>
|
||||
<view
|
||||
v-if="showDot"
|
||||
:class="['status-dot', modelValue === 1 ? 'status-dot--active' : 'status-dot--inactive']"
|
||||
></view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -26,6 +41,12 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
|
||||
import leftSelected from "./images/L_02.png";
|
||||
import leftUnselected from "./images/L_01.png";
|
||||
import rightSelected from "./images/R_02.png";
|
||||
import rightUnselected from "./images/R_01.png";
|
||||
|
||||
const props = defineProps({
|
||||
modelValue: { type: Number, default: 0 },
|
||||
showDot: { type: Boolean, default: true },
|
||||
@@ -47,23 +68,21 @@ const handleSwitch = (i) => {
|
||||
.tab-container {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 48px;
|
||||
height: 50px;
|
||||
display: flex;
|
||||
overflow: hidden;
|
||||
/* 基础容器不做裁切,交给内部 Item */
|
||||
}
|
||||
|
||||
.tab-item {
|
||||
position: relative;
|
||||
flex: 1;
|
||||
height: 48px;
|
||||
height: 50px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
/* 选中态提升层级,压住对方的交汇线 */
|
||||
.tab-item.active {
|
||||
z-index: 10;
|
||||
}
|
||||
@@ -74,91 +93,56 @@ const handleSwitch = (i) => {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
/* 未选中样式:半透明渐变 */
|
||||
background: rgba(0, 0, 0, 0.05);
|
||||
transition: background 0.3s;
|
||||
}
|
||||
|
||||
.tab-item.active .tab-content {
|
||||
/* 选中样式:纯白 */
|
||||
background: linear-gradient(
|
||||
180deg,
|
||||
rgba(255, 255, 255, 0) 0%,
|
||||
#f0f8f3 75.52%
|
||||
);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.tab-text {
|
||||
font-size: 15px;
|
||||
color: rgba(255, 255, 255, 0.95);
|
||||
font-size: 18px;
|
||||
color: rgba(255, 255, 255, 0.65);
|
||||
z-index: 20;
|
||||
}
|
||||
|
||||
.tab-image {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: block;
|
||||
object-fit: cover;
|
||||
z-index: 5;
|
||||
}
|
||||
|
||||
.tab-item.active .tab-text {
|
||||
color: #2e312f;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
/* ------------------- 核心:异形路径优化 ------------------- */
|
||||
|
||||
/* 路径逻辑:
|
||||
1. H 指令缩短,让出更多空间给交汇处。
|
||||
2. C 指令(贝塞尔曲线)的终点设在高度 48 的位置,确保底部平齐不留空隙。
|
||||
3. 通过 margin-right/left 让两个形状在中心高度(24px)处重叠。
|
||||
*/
|
||||
|
||||
.is-left {
|
||||
margin-right: -14px;
|
||||
/* 减小重叠宽度,使形状更精巧 */
|
||||
}
|
||||
|
||||
.is-left .tab-content {
|
||||
/* 路径:左侧顶满 -> 顶部直线 -> 在中间开始向下弯曲 -> 底部平齐拉回 */
|
||||
-webkit-mask-image: url("./images/L_01.png");
|
||||
mask-image: url("./images/L_01.png");
|
||||
-webkit-mask-size: 100% 100%;
|
||||
margin-right: -24px;
|
||||
}
|
||||
|
||||
.is-right {
|
||||
margin-left: -14px;
|
||||
}
|
||||
|
||||
.is-right .tab-content {
|
||||
-webkit-mask-image: url("./images/R_01.png");
|
||||
mask-image: url("./images/R_01.png");
|
||||
-webkit-mask-size: 100% 100%;
|
||||
}
|
||||
|
||||
/* ------------------- 选中态的渐变边框 ------------------- */
|
||||
|
||||
.tab-item.active::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
z-index: 15;
|
||||
pointer-events: none;
|
||||
/* 360deg 渐变 */
|
||||
background: linear-gradient(
|
||||
0deg,
|
||||
rgba(255, 255, 255, 1) 0%,
|
||||
rgba(255, 255, 255, 0) 100%
|
||||
);
|
||||
}
|
||||
|
||||
.is-left.active::after {
|
||||
-webkit-mask-image: url("./images/L_02.png");
|
||||
}
|
||||
|
||||
.is-right.active::after {
|
||||
-webkit-mask-image: url("./images/R_02.png");
|
||||
margin-left: -24px;
|
||||
}
|
||||
|
||||
.status-dot {
|
||||
width: 7px;
|
||||
height: 7px;
|
||||
background-color: #26d46c;
|
||||
display: inline-block;
|
||||
margin-left: 6px;
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
border-radius: 50%;
|
||||
margin-left: 5px;
|
||||
transform: translateY(-8px);
|
||||
z-index: 22;
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
.status-dot--active {
|
||||
background-color: #26d46c;
|
||||
}
|
||||
|
||||
.status-dot--inactive {
|
||||
background-color: rgba(255, 255, 255, 0.65);
|
||||
border: 1px solid rgba(0, 0, 0, 0.08);
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user