Skip to content

Commit ae89f73

Browse files
committed
🚀 [button] button use core hook and lib version bg use svg mask
1 parent e03d247 commit ae89f73

File tree

24 files changed

+117
-239
lines changed

24 files changed

+117
-239
lines changed

core/assets/style/var.css

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@import "./var/Wuxing.css";
22

3-
:root{
3+
:root {
44
--m-color-text: #2B333E;
55
--m-color-text-disabled: #74787A;
66
--m-color-text-dark: #0F1423;
@@ -18,6 +18,18 @@
1818
--m-color-blue: #1661AB;
1919
--m-color-green: #223E36;
2020

21-
2221
--m-color-disabled: #DBDADD;
2322
}
23+
24+
/* size */
25+
:root {
26+
--m-size-small: 5px;
27+
--m-size-default: 10px;
28+
--m-size-large: 15px;
29+
}
30+
31+
:root {
32+
--m-cursor-auto: auto;
33+
--m-cursor-pointer: pointer;
34+
--m-cursor-disabled: not-allowed;
35+
}
Lines changed: 50 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
:root {
2-
/* --m-button-width: 180px;
3-
--m-button-height: 80px;
4-
--m-button-line-height: 24px;*/
2+
--m-button-size: var(--m-size-default);
3+
--m-button-height: calc(var(--m-button-size) * 3.2);
4+
--m-button-width: calc(var(--m-button-size) * 3.2);
5+
--m-button-color: white;
56
}
67

78
.m-button {
8-
padding: 0 15px;
99
outline: unset;
1010
height: var(--m-button-height, 32px);
11-
/*line-height: var(--m-button-line-height, 32px);*/
1211
min-width: var(--m-button-width, 32px);
1312
border: 5px double transparent;
1413
border-radius: 2px;
15-
color: white;
1614
text-align: center;
15+
color: var(--m-button-color);
1716
cursor: var(--m-cursor-pointer);
1817

1918
&:disabled, &:disabled:hover {
@@ -24,11 +23,54 @@
2423
pointer-events: none;
2524
}
2625
}
26+
27+
&.m-button-default {
28+
background-color: var(--m-color-songlan);
29+
&:hover{
30+
background-color: var(--m-color-qingluan);
31+
}
32+
}
33+
34+
&.m-button-error {
35+
background-color: var(--m-color-error);
36+
&:hover{
37+
background-color: var(--m-color-daran);
38+
}
39+
}
40+
41+
&.m-button-confirm {
42+
background-color: var(--m-color-success);
43+
&:hover{
44+
background-color: var(--m-color-zhengqing);
45+
}
46+
}
47+
48+
&.m-button-primary {
49+
background-color: var(--m-color-blue);
50+
&:hover{
51+
background-color: #4994C4;
52+
}
53+
}
54+
55+
&.m-button-warning {
56+
background-color: var(--m-color-jin-yang);
57+
&:hover{
58+
background-color: var(--m-color-zhizi);
59+
}
60+
}
61+
62+
&.m-button-disabled {
63+
background-color: var(--m-color-jin-yin);
64+
&:hover{
65+
background-color: var(--m-color-jin-yin);
66+
}
67+
}
68+
2769
}
2870

2971
a.m-button {
3072
text-decoration: unset;
31-
height: 22px;
32-
padding: unset;
73+
padding: 1px 6px;
74+
height: var(--m-button-height, 32px);
3375
}
3476

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1 @@
11
@import "@shuimo-design/ui-core/components/base/button/button.css";
2-
3-
4-
.m-button {
5-
6-
&.m-button-default {
7-
background-color: var(--m-color-divider);
8-
}
9-
10-
&.m-button-error {
11-
background-color: var(--m-color-error);
12-
}
13-
14-
&.m-button-confirm {
15-
background-color: var(--m-color-success);
16-
}
17-
18-
&.m-button-primary {
19-
background-color: var(--m-color-blue);
20-
}
21-
22-
&.m-button-warning {
23-
background-color: var(--m-color-warn);
24-
}
25-
26-
&.m-button-disabled {
27-
background-color: var(--m-color-disabled);
28-
}
29-
30-
31-
}

headless/utils/install/importComponents.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { Component } from 'vue';
1313
import MAvatar from '../../components/base/avatar/MAvatar.tsx';
1414
import MInput from '../../components/base/input/MInput';
1515
import MButton from '../../components/base/button/MButton.tsx';
16-
import MSelect from '../../components/base/select/MSelect.tsx';
16+
// import MSelect from '../../components/base/select/MSelect.tsx';
1717
import MCheckbox from '../../components/base/checkbox/MCheckbox.tsx';
1818
import MSwitch from '../../components/base/switch/MSwitch.tsx';
1919
// [other]
@@ -25,13 +25,16 @@ import MPopover from '../../components/message/popover/MPopover';
2525

2626
export const components: Record<string, Component> = {
2727
MAvatar,
28+
MButton,
29+
2830

2931
MRicePaper,
3032
};
3133

3234

3335
export {
3436
MAvatar,
37+
MButton,
3538

3639
MRicePaper,
3740
};

lib/assets/style/global.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
@import "@shuimo-design/ui-core/assets/style/global.css";
2+
13
@import "cursor.css";
24
@import "model.css";
35
@import "var.css";

lib/assets/style/var.css

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,6 @@
11
@import "./var/Wuxing.css";
22

33
:root {
4-
--m-color-text: #2B333E;
5-
--m-color-text-disabled: #74787A;
6-
--m-color-text-dark: #0F1423;
7-
--m-color-divider: #0F142333;
8-
--m-color-success: #4A9992;
9-
--m-color-error: #861717;
10-
--m-color-background: #0F142320;
11-
--m-color-green2: #1A3B32;
12-
--m-color-pink: #CC163A;
13-
--m-color-warn: #E8B004;
14-
15-
--m-color-main: #861717;
16-
--m-color-border: #5E616D;
17-
--m-color-orange: #FCA104;
18-
--m-color-blue: #1661AB;
19-
--m-color-green: #223E36;
20-
21-
22-
--m-color-disabled: #DBDADD;
23-
244
--m-cursor-auto: url(../../public/cursor/auto.webp), auto;
255
--m-cursor-pointer: url(../../public/cursor/pointer.webp), auto;
266
--m-cursor-disabled: url(../../public/cursor/disabled.webp), auto;

lib/components/base/button/MButton.tsx

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @description 按钮组件
33
* @author 阿怪
44
* @date 2021/8/10 4:59 下午
5-
* @version v3.0.0
5+
* @version v4.0.0
66
*
77
* 公司的业务千篇一律,复杂的代码好几百行。
88
* v1.0.1 新增slot文本形式
@@ -11,20 +11,18 @@
1111
* v2.0.0 升级交互
1212
* v2.1.0 使用border方式实现边框模块
1313
* v3.0.0 props从core导出
14+
* v4.0.0 use core-ui hook and **background use svg mask!!** <- huge improvement
1415
*/
1516
import { defineComponent, h } from 'vue';
16-
import { props } from './api.ts';
17-
import { ButtonProps } from './index';
17+
import { ButtonCore } from '@shuimo-design/ui-core';
18+
import { ButtonProps } from '@shuimo-design/ui-core/components/base/button/props';
1819
import './button.css';
1920

20-
export default defineComponent((props: ButtonProps, { slots }) => {
21+
const { props, useButton } = ButtonCore;
22+
export default defineComponent((props: ButtonProps, ctx) => {
2123
return () => {
22-
const domType = props.link ? 'a' : 'button';
23-
const slot = slots.default?.() ?? props.text;
24-
return h(domType, {
25-
class: ['m-button', { 'm-button-disabled': props.disabled }, `m-button-${props.type}`],
26-
disabled: props.disabled,
27-
}, slot);
24+
const { domType, slot, domProps } = useButton(props, ctx);
25+
return h(domType, domProps, slot);
2826
};
2927
}, {
3028
name: 'MButton',

lib/components/base/button/api.ts

Lines changed: 0 additions & 21 deletions
This file was deleted.
-1.48 KB
Binary file not shown.
-1.35 KB
Binary file not shown.

0 commit comments

Comments
 (0)