u
This commit is contained in:
1 parent
554fe2945f
commit
9a432e7ab2
5 files changed
+271
-133
No files matched your search
@@ -0,0 +1,121 @@
|
||||
<template>
|
||||
<!-- 状态按钮 (solid) -->
|
||||
<div style="display: flex; gap: 8px; margin-bottom: 16px;">
|
||||
<AButton status="normal">
|
||||
Normal
|
||||
</AButton>
|
||||
<AButton status="primary">
|
||||
主按钮
|
||||
</AButton>
|
||||
<AButton status="warning">
|
||||
警告
|
||||
</AButton>
|
||||
<AButton status="danger">
|
||||
危险
|
||||
</AButton>
|
||||
<AButton status="success">
|
||||
成功
|
||||
</AButton>
|
||||
</div>
|
||||
|
||||
<div style="display: flex; gap: 8px; margin-bottom: 16px;">
|
||||
<AButton status="normal" type="outline">
|
||||
Normal
|
||||
</AButton>
|
||||
<AButton status="primary" type="outline">
|
||||
主按钮
|
||||
</AButton>
|
||||
<AButton status="warning" type="outline">
|
||||
警告
|
||||
</AButton>
|
||||
<AButton status="danger" type="outline">
|
||||
危险
|
||||
</AButton>
|
||||
<AButton status="success" type="outline">
|
||||
成功
|
||||
</AButton>
|
||||
</div>
|
||||
|
||||
<div style="display: flex; gap: 8px; margin-bottom: 16px;">
|
||||
<AButton status="normal" type="dashed">
|
||||
Normal
|
||||
</AButton>
|
||||
<AButton status="primary" type="dashed">
|
||||
主按钮
|
||||
</AButton>
|
||||
<AButton status="warning" type="dashed">
|
||||
警告
|
||||
</AButton>
|
||||
<AButton status="danger" type="dashed">
|
||||
危险
|
||||
</AButton>
|
||||
<AButton status="success" type="dashed">
|
||||
成功
|
||||
</AButton>
|
||||
</div>
|
||||
|
||||
<div style="display: flex; gap: 8px; margin-bottom: 16px;">
|
||||
<AButton status="normal" type="text">
|
||||
Normal
|
||||
</AButton>
|
||||
<AButton status="primary" type="text">
|
||||
主按钮
|
||||
</AButton>
|
||||
<AButton status="warning" type="text">
|
||||
警告
|
||||
</AButton>
|
||||
<AButton status="danger" type="text">
|
||||
危险
|
||||
</AButton>
|
||||
<AButton status="success" type="text">
|
||||
成功
|
||||
</AButton>
|
||||
</div>
|
||||
|
||||
<div style="display: flex; gap: 8px; margin-bottom: 16px;">
|
||||
<AButton status="normal" disabled>
|
||||
禁用
|
||||
</AButton>
|
||||
<AButton status="primary" disabled>
|
||||
禁用
|
||||
</AButton>
|
||||
<AButton type="outline" disabled>
|
||||
禁用
|
||||
</AButton>
|
||||
<AButton type="dashed" disabled>
|
||||
禁用
|
||||
</AButton>
|
||||
<AButton type="text" disabled>
|
||||
禁用
|
||||
</AButton>
|
||||
</div>
|
||||
|
||||
<div style="display: flex; gap: 8px; margin-bottom: 16px;">
|
||||
<AButton status="normal" loading>
|
||||
loading
|
||||
</AButton>
|
||||
<AButton status="primary" loading>
|
||||
loading
|
||||
</AButton>
|
||||
<AButton type="outline" loading>
|
||||
loading
|
||||
</AButton>
|
||||
<AButton type="dashed" loading>
|
||||
loading
|
||||
</AButton>
|
||||
<AButton type="text" loading>
|
||||
loading
|
||||
</AButton>
|
||||
</div>
|
||||
<div style="display: flex; gap: 8px; margin-bottom: 16px;">
|
||||
<AButton status="primary" size="small">
|
||||
small
|
||||
</AButton>
|
||||
<AButton status="primary" size="medium">
|
||||
medium
|
||||
</AButton>
|
||||
<AButton status="primary" size="large">
|
||||
large
|
||||
</AButton>
|
||||
</div>
|
||||
</template>
|
||||
@@ -5,22 +5,24 @@ $btn-prefix: #{$prefix}-btn;
|
||||
$btn-hover-bgcolor: #f4f5f5;
|
||||
$btn-active-bgcolor: #eceded;
|
||||
|
||||
/* ====== 通用颜色交互函数 ====== */
|
||||
/* ====== 通用颜色交互函数(新版写法) ====== */
|
||||
@function color-hover($color, $amount: 8%) {
|
||||
$l: color.lightness($color);
|
||||
$l: color.channel($color, 'lightness', $space: hsl);
|
||||
@if $l > 50% {
|
||||
@return color.adjust($color, $lightness: -$amount);
|
||||
// 亮色:向暗靠近
|
||||
@return color.scale($color, $lightness: -$amount);
|
||||
} @else {
|
||||
@return color.adjust($color, $lightness: $amount);
|
||||
// 暗色:向亮靠近
|
||||
@return color.scale($color, $lightness: $amount);
|
||||
}
|
||||
}
|
||||
|
||||
@function color-active($color, $amount: 12%) {
|
||||
$l: color.lightness($color);
|
||||
$l: color.channel($color, 'lightness', $space: hsl);
|
||||
@if $l > 50% {
|
||||
@return color.adjust($color, $lightness: -$amount);
|
||||
@return color.scale($color, $lightness: -$amount);
|
||||
} @else {
|
||||
@return color.adjust($color, $lightness: $amount);
|
||||
@return color.scale($color, $lightness: $amount);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,12 +33,11 @@ $btn-active-bgcolor: #eceded;
|
||||
gap: 4px;
|
||||
box-sizing: border-box;
|
||||
user-select: none;
|
||||
border-radius: 3px;
|
||||
border-radius: 2px;
|
||||
border: 1px solid transparent;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
font-weight: 600;
|
||||
|
||||
font-weight: 500;
|
||||
&-block {
|
||||
width: 100%;
|
||||
}
|
||||
@@ -96,7 +97,6 @@ $btn-active-bgcolor: #eceded;
|
||||
|
||||
/* ===== Outline 按钮 ===== */
|
||||
&-outline {
|
||||
font-weight: 500;
|
||||
background: transparent;
|
||||
|
||||
@each $status,
|
||||
@@ -124,7 +124,6 @@ $btn-active-bgcolor: #eceded;
|
||||
|
||||
/* ===== Dashed 按钮 ===== */
|
||||
&-dashed {
|
||||
font-weight: 500;
|
||||
background: transparent;
|
||||
border: 1px dashed currentColor;
|
||||
|
||||
@@ -153,7 +152,6 @@ $btn-active-bgcolor: #eceded;
|
||||
|
||||
/* ===== Text 按钮 ===== */
|
||||
&-text {
|
||||
font-weight: 500;
|
||||
background: transparent;
|
||||
border: none;
|
||||
|
||||
@@ -185,14 +183,16 @@ $btn-active-bgcolor: #eceded;
|
||||
padding: 0 12px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
&-medium {
|
||||
height: 28px;
|
||||
padding: 0 14px;
|
||||
font-size: 14px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
&-large {
|
||||
height: 32px;
|
||||
padding: 0 16px;
|
||||
font-size: 14px;
|
||||
font-size: 13px;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,71 @@
|
||||
@use '../_styles/theme/index' as *;
|
||||
@use 'sass:color';
|
||||
|
||||
$input-prefix: #{$prefix}-input;
|
||||
|
||||
.#{$input-prefix} {
|
||||
border-color: #d9d9d9;
|
||||
.#{$input-prefix}-wrapper {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
border: 1px solid #d9d9d9;
|
||||
border-radius: 2px;
|
||||
background-color: #fff;
|
||||
color: #000000d9;
|
||||
transition:
|
||||
border-color 0.2s,
|
||||
box-shadow 0.2s;
|
||||
|
||||
&:hover:not(&-disabled) {
|
||||
border-color: $primary-color;
|
||||
}
|
||||
|
||||
&:focus-within:not(&-disabled) {
|
||||
border-color: $primary-color;
|
||||
box-shadow: 0 0 0 1px color.change($primary-color, $alpha: 0.1);
|
||||
}
|
||||
|
||||
&-disabled {
|
||||
color: #00000040;
|
||||
background-color: #f5f5f5;
|
||||
border-color: #d9d9d9;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
/* 尺寸变体 */
|
||||
&-small {
|
||||
height: 24px;
|
||||
font-size: 12px;
|
||||
}
|
||||
&-medium {
|
||||
height: 28px;
|
||||
font-size: 14px;
|
||||
}
|
||||
&-large {
|
||||
height: 32px;
|
||||
font-size: 16px;
|
||||
}
|
||||
}
|
||||
|
||||
.#{$input-prefix}-inner {
|
||||
flex: 1;
|
||||
border: none;
|
||||
outline: none;
|
||||
background: transparent;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
font-family: inherit;
|
||||
|
||||
&::placeholder {
|
||||
color: #00000040;
|
||||
}
|
||||
}
|
||||
|
||||
.#{$input-prefix}-icon {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: #00000040;
|
||||
margin: 0 4px;
|
||||
}
|
||||
|
||||
@@ -1,23 +1,60 @@
|
||||
import { computed, defineComponent, ref } from 'vue'
|
||||
import type { PropType } from 'vue'
|
||||
import { computed, defineComponent, h, ref } from 'vue'
|
||||
import { getPrefixCls } from '../_utils/getPrefixCls'
|
||||
import Icon from '../icon'
|
||||
|
||||
export default defineComponent({
|
||||
name: 'AInput',
|
||||
setup() {
|
||||
props: {
|
||||
size: {
|
||||
type: String as PropType<'small' | 'medium' | 'large'>,
|
||||
default: 'medium',
|
||||
},
|
||||
placeholder: String,
|
||||
disabled: Boolean,
|
||||
prefixIcon: String,
|
||||
suffixIcon: String,
|
||||
},
|
||||
setup(props, { slots }) {
|
||||
const inputRef = ref<HTMLInputElement | null>(null)
|
||||
|
||||
// 使用统一前缀
|
||||
const prefixCls = getPrefixCls('input')
|
||||
const cls = computed(() => [prefixCls])
|
||||
|
||||
const wrapperCls = computed(() => [
|
||||
`${prefixCls}-wrapper`,
|
||||
`${prefixCls}-wrapper-${props.size}`,
|
||||
{ [`${prefixCls}-wrapper-disabled`]: props.disabled },
|
||||
])
|
||||
|
||||
const iconSizeMap: Record<string, number> = { small: 12, medium: 14, large: 16 }
|
||||
|
||||
const renderIcon = (slot: any, iconProp?: string) => {
|
||||
if (slot)
|
||||
return typeof slot === 'function' ? slot() : slot
|
||||
if (iconProp)
|
||||
return h(Icon, { icon: iconProp, width: iconSizeMap[props.size], height: iconSizeMap[props.size] })
|
||||
return null
|
||||
}
|
||||
|
||||
return () => (
|
||||
<div class={`${prefixCls}-wrapper`} style={{ display: 'inline-block' }}>
|
||||
<div class={wrapperCls.value}>
|
||||
{(slots.prefix || props.prefixIcon) && (
|
||||
<span class={`${prefixCls}-icon`}>
|
||||
{renderIcon(slots.prefix, props.prefixIcon)}
|
||||
</span>
|
||||
)}
|
||||
|
||||
<input
|
||||
ref={inputRef}
|
||||
class={cls.value}
|
||||
type="text"
|
||||
placeholder="请输入"
|
||||
class={`${prefixCls}-inner`}
|
||||
placeholder={props.placeholder}
|
||||
disabled={props.disabled}
|
||||
/>
|
||||
|
||||
{(slots.suffix || props.suffixIcon) && (
|
||||
<span class={`${prefixCls}-icon`}>
|
||||
{renderIcon(slots.suffix, props.suffixIcon)}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
},
|
||||
|
||||
@@ -2,114 +2,30 @@
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<!-- 状态按钮 (solid) -->
|
||||
<div style="display: flex; gap: 8px; margin-bottom: 16px;">
|
||||
<AButton status="normal">
|
||||
Normal
|
||||
</AButton>
|
||||
<AButton status="primary">
|
||||
主按钮
|
||||
</AButton>
|
||||
<AButton status="warning">
|
||||
警告
|
||||
</AButton>
|
||||
<AButton status="danger">
|
||||
危险
|
||||
</AButton>
|
||||
<AButton status="success">
|
||||
成功
|
||||
</AButton>
|
||||
</div>
|
||||
<div style="display: flex; gap: 12px; flex-wrap: wrap; width: 300px;">
|
||||
<!-- small 输入框,使用 slot 图标 -->
|
||||
<AInput size="small" placeholder="Small 输入框">
|
||||
<template #prefix>
|
||||
<AIcon icon="material-symbols:10k-outline" />
|
||||
</template>
|
||||
<template #suffix>
|
||||
<AIcon icon="material-symbols:10k-outline" />
|
||||
</template>
|
||||
</AInput>
|
||||
|
||||
<div style="display: flex; gap: 8px; margin-bottom: 16px;">
|
||||
<AButton status="normal" type="outline">
|
||||
Normal
|
||||
</AButton>
|
||||
<AButton status="primary" type="outline">
|
||||
主按钮
|
||||
</AButton>
|
||||
<AButton status="warning" type="outline">
|
||||
警告
|
||||
</AButton>
|
||||
<AButton status="danger" type="outline">
|
||||
危险
|
||||
</AButton>
|
||||
<AButton status="success" type="outline">
|
||||
成功
|
||||
</AButton>
|
||||
</div>
|
||||
<!-- medium 输入框,使用 prop 图标 -->
|
||||
<AInput
|
||||
size="medium"
|
||||
placeholder="Medium 输入框"
|
||||
prefix-icon="material-symbols:10k-outline"
|
||||
suffix-icon="material-symbols:10k-outline"
|
||||
/>
|
||||
|
||||
<div style="display: flex; gap: 8px; margin-bottom: 16px;">
|
||||
<AButton status="normal" type="dashed">
|
||||
Normal
|
||||
</AButton>
|
||||
<AButton status="primary" type="dashed">
|
||||
主按钮
|
||||
</AButton>
|
||||
<AButton status="warning" type="dashed">
|
||||
警告
|
||||
</AButton>
|
||||
<AButton status="danger" type="dashed">
|
||||
危险
|
||||
</AButton>
|
||||
<AButton status="success" type="dashed">
|
||||
成功
|
||||
</AButton>
|
||||
<!-- large 输入框,prefix 用 slot,suffix 用 prop -->
|
||||
<AInput size="large" placeholder="Large 输入框" suffix-icon="material-symbols:10k-outline">
|
||||
<template #prefix>
|
||||
<AIcon icon="material-symbols:10k-outline" />
|
||||
</template>
|
||||
</AInput>
|
||||
</div>
|
||||
|
||||
<div style="display: flex; gap: 8px; margin-bottom: 16px;">
|
||||
<AButton status="normal" type="text">
|
||||
Normal
|
||||
</AButton>
|
||||
<AButton status="primary" type="text">
|
||||
主按钮
|
||||
</AButton>
|
||||
<AButton status="warning" type="text">
|
||||
警告
|
||||
</AButton>
|
||||
<AButton status="danger" type="text">
|
||||
危险
|
||||
</AButton>
|
||||
<AButton status="success" type="text">
|
||||
成功
|
||||
</AButton>
|
||||
</div>
|
||||
|
||||
<div style="display: flex; gap: 8px; margin-bottom: 16px;">
|
||||
<AButton status="normal" disabled>
|
||||
禁用
|
||||
</AButton>
|
||||
<AButton status="primary" disabled>
|
||||
禁用
|
||||
</AButton>
|
||||
<AButton type="outline" disabled>
|
||||
禁用
|
||||
</AButton>
|
||||
<AButton type="dashed" disabled>
|
||||
禁用
|
||||
</AButton>
|
||||
<AButton type="text" disabled>
|
||||
禁用
|
||||
</AButton>
|
||||
</div>
|
||||
|
||||
<div style="display: flex; gap: 8px; margin-bottom: 16px;">
|
||||
<AButton status="normal" loading>
|
||||
loading
|
||||
</AButton>
|
||||
<AButton status="primary" loading>
|
||||
loading
|
||||
</AButton>
|
||||
<AButton type="outline" loading>
|
||||
loading
|
||||
</AButton>
|
||||
<AButton type="dashed" loading>
|
||||
loading
|
||||
</AButton>
|
||||
<AButton type="text" loading>
|
||||
loading
|
||||
</AButton>
|
||||
</div>
|
||||
|
||||
<AInput />
|
||||
</template>
|
||||
Reference in new issue
Block a user