Skip to content

Commit 43c2ccf

Browse files
committed
feat: 输入类组件增加悬浮发光效果
1 parent 45bc6a4 commit 43c2ccf

File tree

31 files changed

+335
-137
lines changed

31 files changed

+335
-137
lines changed

packages/devui-vue/devui/auto-complete/src/auto-complete.scss

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,6 @@
135135
font-size: $devui-font-size-lg;
136136
}
137137

138-
&--glow-style:not(.#{$devui-prefix}-auto-complete--focus):not(.#{$devui-prefix}-auto-complete--disabled):not(.#{$devui-prefix}-auto-complete-input__wrapper--error):hover {
139-
box-shadow: 0 0 0 4px $devui-form-control-interactive-outline;
140-
border-color: $devui-form-control-line;
141-
}
142-
143138
&__clear--icon {
144139
cursor: pointer;
145140
}
@@ -152,6 +147,13 @@
152147
box-sizing: border-box;
153148
height: 100%;
154149

150+
&:not(.#{$devui-prefix}-auto-complete--focus) {
151+
.#{$devui-prefix}-auto-complete--glow-style:hover {
152+
box-shadow: 0 0 0 4px $devui-form-control-interactive-outline;
153+
border-color: $devui-form-control-line;
154+
}
155+
}
156+
155157
&__wrapper {
156158
display: inline-flex;
157159
align-items: center;
@@ -211,6 +213,11 @@
211213
}
212214
}
213215

216+
&--glow-style:not(.#{$devui-prefix}-auto-complete--disabled):not(.#{$devui-prefix}-auto-complete-input__wrapper--error):hover {
217+
box-shadow: 0 0 0 4px $devui-form-control-interactive-outline;
218+
border-color: $devui-form-control-line;
219+
}
220+
214221
&--focus {
215222
.#{$devui-prefix}-auto-complete-input__wrapper:not(.#{$devui-prefix}-auto-complete-input__wrapper--error) {
216223
border-color: $devui-form-control-line-active;
@@ -222,7 +229,7 @@
222229

223230
.#{$devui-prefix}-auto-complete--glow-style:not(.#{$devui-prefix}-auto-complete-input__wrapper--error) {
224231
box-shadow: 0 0 0 4px $devui-form-control-interactive-outline;
225-
border-color: $devui-form-control-line;
232+
border-color: $devui-form-control-line-active;
226233
}
227234
}
228235

packages/devui-vue/devui/button/src/button.scss

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ $devui-btn-lg-padding: var(--devui-btn-lg-padding, 0 24px);
1818
}
1919

2020
.#{$devui-prefix}-button {
21+
position: relative;
2122
padding: $devui-btn-padding;
2223
font-size: $devui-font-size-md;
2324
height: $devui-size-md;
@@ -26,6 +27,22 @@ $devui-btn-lg-padding: var(--devui-btn-lg-padding, 0 24px);
2627
border-width: 1px;
2728
border-color: transparent;
2829
background-color: transparent;
30+
overflow: hidden;
31+
32+
&.mousedown:not(:disabled) {
33+
transform: scale(0.95);
34+
}
35+
36+
.water-wave {
37+
position: absolute;
38+
background-color: $devui-base-bg;
39+
border-radius: 50%;
40+
opacity: 0;
41+
width: 20px;
42+
height: 20px;
43+
transform: translate(-50%, -50%);
44+
animation: waterWave $devui-animation-duration-slow $devui-animation-linear;
45+
}
2946

3047
&:hover {
3148
cursor: pointer;
@@ -320,8 +337,7 @@ $devui-btn-lg-padding: var(--devui-btn-lg-padding, 0 24px);
320337
}
321338

322339
.#{$devui-prefix}-button {
323-
transition:
324-
background-color $devui-animation-duration-slow $devui-animation-ease-in-out-smooth,
340+
transition: background-color $devui-animation-duration-slow $devui-animation-ease-in-out-smooth,
325341
border-color $devui-animation-duration-slow $devui-animation-ease-in-out-smooth,
326342
color $devui-animation-duration-slow $devui-animation-ease-in-out-smooth;
327343
white-space: nowrap;
@@ -397,7 +413,25 @@ $devui-btn-lg-padding: var(--devui-btn-lg-padding, 0 24px);
397413
}
398414

399415
@keyframes rotating {
400-
0% { transform: rotate(0); }
416+
0% {
417+
transform: rotate(0);
418+
}
401419

402-
100% { transform: rotate(180deg); }
420+
100% {
421+
transform: rotate(180deg);
422+
}
423+
}
424+
425+
@keyframes waterWave {
426+
0% {
427+
opacity: 0.2;
428+
width: 30px;
429+
height: 30px;
430+
}
431+
432+
100% {
433+
opacity: 0;
434+
width: 200px;
435+
height: 200px;
436+
}
403437
}

packages/devui-vue/devui/button/src/button.tsx

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { defineComponent, toRefs } from 'vue';
1+
import { defineComponent, toRefs, ref, reactive } from 'vue';
22
import type { SetupContext } from 'vue';
33
import { Icon } from '../../icon';
44
import LoadingDirective from '../../loading/src/loading-directive';
@@ -16,22 +16,45 @@ export default defineComponent({
1616
setup(props: ButtonProps, ctx: SetupContext) {
1717
const { icon, disabled, loading, nativeType } = toRefs(props);
1818
const { classes, iconClass } = useButton(props, ctx);
19+
const isMouseDown = ref(false);
20+
const showWave = ref(false);
21+
const waveStyle = reactive({
22+
top: '0px',
23+
left: '0px',
24+
});
1925

26+
const showClickWave = (e: MouseEvent) => {
27+
waveStyle.left = e.offsetX + 'px';
28+
waveStyle.top = e.offsetY + 'px';
29+
showWave.value = true;
30+
31+
setTimeout(() => {
32+
showWave.value = false;
33+
}, 300);
34+
};
2035
const onClick = (e: MouseEvent) => {
2136
if (loading.value) {
2237
return;
2338
}
39+
showClickWave(e);
2440
ctx.emit('click', e);
2541
};
2642

2743
return () => {
2844
return (
29-
<button class={classes.value} disabled={disabled.value} onClick={onClick} type={nativeType.value}>
45+
<button
46+
class={[classes.value, isMouseDown.value ? 'mousedown' : '']}
47+
disabled={disabled.value}
48+
onClick={onClick}
49+
type={nativeType.value}
50+
onMousedown={() => (isMouseDown.value = true)}
51+
onMouseup={() => (isMouseDown.value = false)}>
3052
{icon.value && <Icon name={icon.value} size="var(--devui-font-size, 12px)" color="" class={iconClass.value} />}
3153
<div class="loading-icon__container" v-show={loading.value}>
3254
<d-icon name="icon-loading" class="button-icon-loading" color="#BBDEFB"></d-icon>
3355
</div>
3456
<span class="button-content">{ctx.slots.default?.()}</span>
57+
{showWave.value && <div class="water-wave" style={waveStyle}></div>}
3558
</button>
3659
);
3760
};

packages/devui-vue/devui/editable-select/src/composables/use-input-render.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export function useInputRender(props: EditableSelectProps, states: States): UseI
2525
[ns.e('wrapper')]: true,
2626
[ns.em('wrapper', 'focus')]: states.isFocus,
2727
[ns.em('wrapper', 'disabled')]: props.disabled,
28+
[ns.em('wrapper', 'glow-style')]: props.showGlowStyle,
2829
}));
2930

3031
const inputInnerClasses = computed(() => ({

packages/devui-vue/devui/editable-select/src/editable-select-types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ export const editableSelectProps = {
8383
type: Boolean,
8484
default: false,
8585
},
86+
showGlowStyle: {
87+
type: Boolean,
88+
default: true,
89+
},
8690
} as const;
8791

8892
export type EditableSelectProps = ExtractPropTypes<typeof editableSelectProps>;

packages/devui-vue/devui/editable-select/src/editable-select.scss

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,19 @@
3232
border: 1px solid $devui-form-control-line;
3333
border-radius: $devui-border-radius;
3434
background-color: $devui-form-control-bg;
35-
transition: border-color 0.3s $devui-animation-ease-in-out-smooth;
35+
transition: border-color 0.3s $devui-animation-ease-in-out-smooth, box-shadow $devui-animation-duration-base $devui-animation-ease-in;
3636

3737
&:not(.#{$devui-prefix}-editable-select-input__wrapper--disabled):not(&--focus):hover {
3838
border-color: $devui-form-control-line-hover;
3939
}
4040

4141
&--focus {
4242
border-color: $devui-form-control-line-active;
43+
44+
&.#{$devui-prefix}-editable-select-input__wrapper--glow-style {
45+
box-shadow: 0 0 0 4px $devui-form-control-interactive-outline;
46+
border-color: $devui-form-control-line-active;
47+
}
4348
}
4449

4550
&--disabled {
@@ -57,6 +62,13 @@
5762
cursor: not-allowed;
5863
}
5964
}
65+
66+
&--glow-style {
67+
&:not(.#{$devui-prefix}-editable-select-input__wrapper--disabled, .#{$devui-prefix}-editable-select-input__wrapper--focus):hover {
68+
box-shadow: 0 0 0 4px $devui-form-control-interactive-outline;
69+
border-color: $devui-form-control-line !important;
70+
}
71+
}
6072
}
6173

6274
&__inner {
@@ -93,11 +105,28 @@
93105
pointer-events: auto;
94106
display: flex;
95107
cursor: pointer;
108+
109+
svg {
110+
path {
111+
fill: $devui-shape-icon-fill;
112+
transition: all $devui-animation-ease-in-out-smooth $devui-animation-duration-slow;
113+
}
114+
115+
&:hover {
116+
path {
117+
fill: $devui-shape-icon-fill-hover;
118+
}
119+
}
120+
}
96121
}
97122

98123
.#{$devui-prefix}-editable-select__arrow-icon {
99124
display: flex;
100125
transition: transform $devui-animation-duration-slow $devui-animation-ease-in-out-smooth;
126+
127+
svg path {
128+
fill: $devui-icon-text;
129+
}
101130
}
102131
}
103132
}

packages/devui-vue/devui/editable-select/src/editable-select.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import { onClickOutside } from '@vueuse/core';
55
import type { SetupContext } from 'vue';
66
import { editableSelectProps, EditableSelectProps, SELECT_KEY } from './editable-select-types';
77
// 子组件
8-
import Icon from '../../icon/src/icon';
98
import { FlexibleOverlay } from '../../overlay';
109
import Dropdown from './components/dropdown/dropdown';
10+
import { SelectArrowIcon, InputClearIcon } from '../../svg-icons';
1111
// 工具函数
1212
import { useSelect, useSelectStates } from './composables/use-select';
1313
import { useKeyboardSelect } from './composables/use-keyboard-select';
@@ -143,10 +143,10 @@ export default defineComponent({
143143
/>
144144
<span class={inputSuffixClasses.value}>
145145
<span class={ns.e('clear-icon')} v-show={showClearable.value} onClick={withModifiers(handleClear, ['stop'])}>
146-
<Icon name="icon-remove" />
146+
<InputClearIcon />
147147
</span>
148148
<span class={ns.e('arrow-icon')} v-show={!showClearable.value}>
149-
<Icon name="select-arrow" />
149+
<SelectArrowIcon />
150150
</span>
151151
</span>
152152
</div>

packages/devui-vue/devui/input-number/src/input-number-types.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export const inputNumberProps = {
2323
default: -Infinity,
2424
},
2525
size: {
26-
type: String as PropType<ISize>
26+
type: String as PropType<ISize>,
2727
},
2828
modelValue: {
2929
type: Number,
@@ -35,6 +35,10 @@ export const inputNumberProps = {
3535
type: [RegExp, String] as PropType<RegExp | string>,
3636
default: '',
3737
},
38+
showGlowStyle: {
39+
type: Boolean,
40+
default: true,
41+
},
3842
} as const;
3943

4044
export type InputNumberProps = ExtractPropTypes<typeof inputNumberProps>;

packages/devui-vue/devui/input-number/src/input-number.scss

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,56 @@
2929
}
3030
}
3131

32+
&.#{$devui-prefix}-input-number--glow-style {
33+
&:hover {
34+
.#{$devui-prefix}-input-number__input-box:not(.disabled) {
35+
border-color: $devui-form-control-line;
36+
box-shadow: 0 0 0 4px $devui-form-control-interactive-outline;
37+
}
38+
39+
.#{$devui-prefix}-input-number__control-buttons:not(.disabled) {
40+
border-color: $devui-form-control-line;
41+
}
42+
43+
.#{$devui-prefix}-input-number__input-box--error:not(.disabled) {
44+
border-color: $devui-danger-line;
45+
}
46+
47+
.#{$devui-prefix}-input-number__control-buttons--error:not(.disabled) {
48+
border-color: $devui-danger-line;
49+
border-left-color: $devui-form-control-line-hover;
50+
51+
span {
52+
background-color: $devui-danger-bg;
53+
}
54+
}
55+
}
56+
57+
&:focus-within {
58+
.#{$devui-prefix}-input-number__input-box:not(.disabled) {
59+
border-color: $devui-form-control-line-active;
60+
box-shadow: 0 0 0 4px $devui-form-control-interactive-outline;
61+
}
62+
63+
.#{$devui-prefix}-input-number__control-buttons:not(.disabled) {
64+
border-color: $devui-form-control-line-active;
65+
}
66+
67+
.#{$devui-prefix}-input-number__input-box--error:not(.disabled) {
68+
border-color: $devui-danger-line;
69+
}
70+
71+
.#{$devui-prefix}-input-number__control-buttons--error:not(.disabled) {
72+
border-color: $devui-danger-line;
73+
border-left-color: $devui-form-control-line-hover;
74+
75+
span {
76+
background-color: $devui-danger-bg;
77+
}
78+
}
79+
}
80+
}
81+
3282
.#{$devui-prefix}-input-number__input-box {
3383
box-sizing: border-box;
3484
width: 100%;
@@ -42,7 +92,8 @@
4292
border: 1px solid $devui-form-control-line;
4393
cursor: text;
4494
-moz-appearance: textfield;
45-
transition: border-color $devui-animation-duration-slow $devui-animation-ease-in-out-smooth;
95+
transition: border-color $devui-animation-duration-slow $devui-animation-ease-in-out-smooth,
96+
box-shadow $devui-animation-duration-base $devui-animation-ease-in;
4697

4798
&:not(.disabled) {
4899
background-color: $devui-base-bg;

packages/devui-vue/devui/input-number/src/use-input-number.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export function useRender(props: InputNumberProps, ctx: SetupContext): UseRender
1717
const wrapClass = computed(() => [
1818
{
1919
[ns.b()]: true,
20+
[ns.m('glow-style')]: props.showGlowStyle,
2021
[ns.m(inputNumberSize.value)]: true,
2122
},
2223
customClass,

0 commit comments

Comments
 (0)