Zzc 574cc5a39e refactor(ui): 将通用按钮样式提取到可复用的基础类中
将共享的按钮交互样式(悬停、激活、聚焦、禁用)移至 common.scss 中的新 `.btn-custom-bg` 类,并更新 ActionButton.vue 以扩展该类,从而简化组件特定样式并提高可维护性。
2025-11-20 12:48:19 +08:00

180 lines
3.1 KiB
SCSS
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

@use '@/styles/mixins.scss' as *;
/**
* 3D态势感知公共样式
*
* 注意CSS 变量(--primary-color, --text-white 等)已定义在全局样式中
* 文件位置:/src/styles/index.scss
*
* 这样可以避免 Vue scoped 样式导致的 :root 变量不生效问题
*/
// 公共面板样式
.panel {
display: flex;
flex-direction: column;
background-size: 100% 100%;
background-repeat: no-repeat;
&--scrollable {
overflow-y: auto;
overscroll-behavior: contain;
scrollbar-width: thin;
scrollbar-color: var(--primary-light) transparent;
&::-webkit-scrollbar {
width: vw(4);
}
&::-webkit-scrollbar-track {
background: transparent;
}
&::-webkit-scrollbar-thumb {
background: var(--primary-light);
border-radius: vw(2);
&:hover {
background: rgba(28, 161, 255, 0.6);
}
}
}
}
// 公共文字样式
.text {
&--title {
color: var(--text-white);
font-family: SourceHanSansCN-Bold, sans-serif;
font-weight: 700;
}
&--subtitle {
color: var(--text-gray);
font-family: SourceHanSansCN-Medium, sans-serif;
font-weight: 500;
}
&--label {
color: var(--text-white);
font-family: SourceHanSansCN-Medium, sans-serif;
font-weight: 500;
}
&--value {
color: var(--text-white);
font-family: PingFangSC-Semibold, sans-serif;
font-weight: 600;
}
&--success {
color: var(--success-color);
}
&--warning {
color: var(--warning-color);
}
&--danger {
color: var(--danger-color);
}
}
// 公共按钮样式
.button {
border: none;
cursor: pointer;
transition: opacity 0.3s, transform 0.2s;
font-family: SourceHanSansCN-Medium, sans-serif;
&:hover {
opacity: 0.8;
}
&:active {
transform: scale(0.98);
}
&--primary {
background: var(--primary-color);
color: var(--text-white);
}
&--secondary {
background: var(--bg-panel);
color: var(--text-white);
border: 1px solid var(--border-color);
}
}
// 自定义背景图按钮基类(用于使用背景图片的 button 元素)
.btn-custom-bg {
// 重置 button 默认样式
appearance: none;
-webkit-appearance: none;
-moz-appearance: none;
border: none;
outline: none;
background: transparent;
background-color: transparent;
padding: 0;
margin: 0;
// 基础交互样式
cursor: pointer;
transition: opacity 0.3s, transform 0.2s;
user-select: none;
// 焦点样式(键盘导航时显示)
&:focus-visible {
outline: 2px solid var(--primary-color);
outline-offset: 2px;
}
// 交互效果
&:hover {
opacity: 0.8;
}
&:active {
transform: scale(0.98);
}
// 禁用状态
&:disabled {
opacity: 0.5;
cursor: not-allowed;
transform: none;
}
}
// Flexbox 工具类
.flex {
display: flex;
&-row {
flex-direction: row;
}
&-col {
flex-direction: column;
}
&-center {
align-items: center;
justify-content: center;
}
&-between {
justify-content: space-between;
}
&-around {
justify-content: space-around;
}
&-end {
justify-content: flex-end;
}
}