@import '../../style/theme.less'; /* ── design tokens(严格对齐 stitch-ui/buttonUi/code.html 色谱) ── */ /* primary 色系 */ @btn-primary-solid: #ffd709; /* primary-container / primary-fixed */ @btn-primary-gradient-from: #ffd709; /* primary-fixed */ @btn-primary-gradient-to: #efc900; /* primary-fixed-dim */ @btn-primary-text: #5b4b00; /* on-primary-container */ @btn-primary-pressed-bg: #5e4e00; /* primary-dim */ @btn-primary-pressed-text: #fff2cd; /* on-primary */ @btn-primary-ring: rgba(108, 90, 0, 0.10); /* secondary 色系 */ @btn-secondary-bg: #9cd343; /* tertiary-container / tertiary-fixed */ @btn-secondary-text-on-tint: #5a8c1a; /* error 色系 */ @btn-error-bg: #f95630; /* error-container */ @btn-error-text: #520c00; /* on-error-container */ /* surface 参考 */ @btn-surface-variant: #e5dcc9; @btn-surface-container-high: #eae2d0; @btn-surface-container-highest: #e5dcc9; @btn-outline-variant-20: rgba(179, 172, 159, 0.20); /* 阴影 */ @btn-shadow-primary: 0 8rpx 24rpx rgba(108, 90, 0, 0.15); @btn-shadow-primary-lg: 0 8rpx 24rpx rgba(255, 215, 0, 0.3); @btn-shadow-secondary: 0 8rpx 24rpx rgba(156, 211, 67, 0.18); @btn-shadow-error: 0 8rpx 24rpx rgba(249, 86, 48, 0.18); @btn-shadow-default: @shadow; @btn-shadow-pressed: none; /* 圆角 */ @btn-radius: @radius-lg; @btn-radius-sm: 20rpx; @btn-radius-mini: 18rpx; /* 过渡 */ @btn-transition: 0.18s ease; /* 禁用 */ @btn-disabled-bg: @bg-gray; @btn-disabled-color: @text-disable; /* ── reset native button chrome(全宽块级按钮由 .toy-btn--block 自行控制宽度) ── */ wx-button.toy-btn:not([size=mini]):not(.toy-btn--block) { margin-left: auto; margin-right: auto; width: auto; } /* ── base ── */ .toy-btn { box-sizing: border-box; display: inline-flex; align-items: center; justify-content: center; gap: 10rpx; min-width: 180rpx; height: 92rpx; padding: 0 32rpx; border-radius: @btn-radius; border: none; background: @bg-gray; color: @text-title; box-shadow: @btn-shadow-default; font-size: 30rpx; font-weight: 700; letter-spacing: 0.5rpx; text-align: center; line-height: 1; transition: transform @btn-transition, box-shadow @btn-transition, background @btn-transition, color @btn-transition, opacity @btn-transition; &::after { border: none; } /* ═══════ type variants ═══════ */ /* 默认:surface-container 底 + on-surface 字 */ &--default { background: @bg-gray; color: @text-title; box-shadow: @btn-shadow-default; } /* * 主色:中号/小号/mini 用纯色 primary-container (#ffd709) * 大号单独覆盖为渐变(见 &--large 内) */ &--primary { background: @btn-primary-solid; color: @btn-primary-text; box-shadow: @btn-shadow-primary; } /* 次级(语义名;视觉上目前为绿色) */ &--secondary { background: @btn-secondary-bg; color: @text-white; box-shadow: @btn-shadow-secondary; } /* @deprecated 向后兼容,等同 secondary */ &--green { background: @btn-secondary-bg; color: @text-white; box-shadow: @btn-shadow-secondary; } /* 危险操作:error-container 底 + on-error-container 深字 */ &--error { background: @btn-error-bg; color: @btn-error-text; box-shadow: @btn-shadow-error; } /* 白色 / 浅底 */ &--white { background: @bg-white; color: @text-title; box-shadow: @btn-shadow-default; } /* ═══════ size variants ═══════ */ /* 大号 / 全宽:primary 此时启用渐变 + 更强阴影 */ &--large { width: 100%; height: 100rpx; padding: 0 40rpx; font-size: 34rpx; &.toy-btn--primary { background: linear-gradient(135deg, @btn-primary-gradient-from, @btn-primary-gradient-to); box-shadow: @btn-shadow-primary-lg; } } &--normal { min-width: 180rpx; } &--small { min-width: 136rpx; height: 72rpx; padding: 0 24rpx; border-radius: @btn-radius-sm; font-size: 26rpx; } &--mini { min-width: 96rpx; height: 56rpx; padding: 0 16rpx; border-radius: @btn-radius-mini; font-size: 24rpx; } /* ═══════ variant: outlined (描边) ═══════ */ &--outlined { background: transparent !important; box-shadow: none !important; border: 4rpx solid @btn-surface-variant; &.toy-btn--primary { border-color: @btn-primary-solid; color: @btn-primary-text; } &.toy-btn--secondary, &.toy-btn--green { border-color: @btn-secondary-bg; color: @btn-secondary-text-on-tint; } &.toy-btn--error { border-color: @btn-error-bg; color: #b02500; } &.toy-btn--default { border-color: @btn-surface-variant; color: @text-secondary; } } /* ═══════ variant: ghost (幽灵) ═══════ */ &--ghost { background: transparent !important; border: none !important; box-shadow: none !important; &.toy-btn--primary { color: #6c5a00; } &.toy-btn--secondary, &.toy-btn--green { color: @btn-secondary-text-on-tint; } &.toy-btn--error { color: #b02500; } &.toy-btn--default { color: @text-secondary; } &.toy-btn--active { background: @btn-surface-container-high !important; } } /* ═══════ icon-only(纯图标按钮) ═══════ */ &--icon-only { min-width: 0; padding: 0; gap: 0; &.toy-btn--large { width: 128rpx; height: 128rpx; border-radius: @btn-radius; } &.toy-btn--normal { width: 112rpx; height: 112rpx; border-radius: @btn-radius; } &.toy-btn--small { width: 88rpx; height: 88rpx; border-radius: @btn-radius-sm; } &.toy-btn--mini { width: 72rpx; height: 72rpx; border-radius: @btn-radius-mini; } } /* ═══════ block(铺满父级 flex 槽位,避免被 wx-button 默认 width:auto 限制) ═══════ */ &--block { display: flex; width: 100%; max-width: 100%; margin-left: 0; margin-right: 0; box-sizing: border-box; } /* ═══════ states ═══════ */ /* 通用按下态:缩放 0.9 */ &--active { transform: scale(0.9); box-shadow: @btn-shadow-pressed; } /* 图标按钮按下态:缩放 0.90 */ &--icon-only&--active { transform: scale(0.90); } /* primary 按下态:切到 primary-dim 底色 + on-primary 字 + ring */ &--primary&--active { background: @btn-primary-pressed-bg !important; color: @btn-primary-pressed-text; box-shadow: 0 0 0 8rpx @btn-primary-ring; } &--disabled { background: @btn-disabled-bg !important; color: @btn-disabled-color !important; border-color: transparent !important; box-shadow: none !important; opacity: 1; } &--loading { opacity: 0.88; } /* ═══════ inner elements ═══════ */ &__icon { flex-shrink: 0; } &__label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } &__spinner { box-sizing: border-box; border-radius: 50%; border: 4rpx solid transparent; border-style: solid; animation: toy-btn-spin 0.8s linear infinite; flex-shrink: 0; } } @keyframes toy-btn-spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }