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