design-system-next 1.2.7 → 1.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { computed, ref, ComputedRef } from 'vue';
|
|
1
|
+
import { computed, ref, ComputedRef, toRefs } from 'vue';
|
|
2
2
|
import { useElementHover, useMousePressed, useFocus } from '@vueuse/core';
|
|
3
3
|
|
|
4
4
|
import classNames from 'classnames';
|
|
@@ -11,14 +11,14 @@ export const useButton = (props: ButtonPropTypes, emit: SetupContext<ButtonEmitT
|
|
|
11
11
|
const isHovered = useElementHover(buttonRef);
|
|
12
12
|
const { pressed } = useMousePressed({ target: buttonRef });
|
|
13
13
|
const { focused } = useFocus(buttonRef);
|
|
14
|
-
const { state, type, size, tone, variant, disabled, hasIcon } = props;
|
|
14
|
+
const { state, type, size, tone, variant, disabled, hasIcon } = toRefs(props);
|
|
15
15
|
|
|
16
16
|
const buttonProps: ComputedRef<Record<string, unknown>> = computed(() => {
|
|
17
17
|
return {
|
|
18
|
-
...(disabled && { ariaDisabled: true }),
|
|
19
|
-
disabled: disabled,
|
|
20
|
-
autofocus: state === 'focus',
|
|
21
|
-
type: type
|
|
18
|
+
...(disabled.value && { ariaDisabled: true }),
|
|
19
|
+
disabled: disabled.value,
|
|
20
|
+
autofocus: state.value === 'focus',
|
|
21
|
+
type: type.value,
|
|
22
22
|
};
|
|
23
23
|
});
|
|
24
24
|
|
|
@@ -34,33 +34,33 @@ export const useButton = (props: ButtonPropTypes, emit: SetupContext<ButtonEmitT
|
|
|
34
34
|
|
|
35
35
|
const buttonSizeCssClass: ComputedRef<string> = computed(() =>
|
|
36
36
|
classNames({
|
|
37
|
-
'min-w-6 p-size-spacing-4xs font-medium font-size-100 leading-100': size === 'small',
|
|
38
|
-
'min-w-7 p-2 font-medium font-size-100 leading-100': size === 'medium',
|
|
39
|
-
'!min-w-9 px-2 py-3 font-medium font-size-200 leading-300 max-h-9': size === 'large',
|
|
40
|
-
'font-size-400': hasIcon && size === 'large',
|
|
41
|
-
'font-size-300': hasIcon && size === 'medium',
|
|
42
|
-
'font-size-200': hasIcon && size === 'small',
|
|
37
|
+
'min-w-6 p-size-spacing-4xs font-medium font-size-100 leading-100': size.value === 'small',
|
|
38
|
+
'min-w-7 p-2 font-medium font-size-100 leading-100': size.value === 'medium',
|
|
39
|
+
'!min-w-9 px-2 py-3 font-medium font-size-200 leading-300 max-h-9': size.value === 'large',
|
|
40
|
+
'font-size-400': hasIcon.value && size.value === 'large',
|
|
41
|
+
'font-size-300': hasIcon.value && size.value === 'medium',
|
|
42
|
+
'font-size-200': hasIcon.value && size.value === 'small',
|
|
43
43
|
}),
|
|
44
44
|
);
|
|
45
45
|
|
|
46
46
|
const buttonTextCssClass: ComputedRef<string> = computed(() => {
|
|
47
|
-
if (variant === 'secondary' || variant === 'tertiary') {
|
|
47
|
+
if (variant.value === 'secondary' || variant.value === 'tertiary') {
|
|
48
48
|
return classNames({
|
|
49
|
-
'text-color-strong': tone === 'neutral',
|
|
50
|
-
'text-color-brand-base': tone === 'success',
|
|
51
|
-
'text-color-danger-base': tone === 'danger',
|
|
49
|
+
'text-color-strong': tone.value === 'neutral',
|
|
50
|
+
'text-color-brand-base': tone.value === 'success',
|
|
51
|
+
'text-color-danger-base': tone.value === 'danger',
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
return classNames({
|
|
56
|
-
'text-color-strong': tone === 'neutral',
|
|
57
|
-
'text-color-inverted-strong': tone === 'success' || tone === 'danger',
|
|
56
|
+
'text-color-strong': tone.value === 'neutral',
|
|
57
|
+
'text-color-inverted-strong': tone.value === 'success' || tone.value === 'danger',
|
|
58
58
|
});
|
|
59
59
|
});
|
|
60
60
|
|
|
61
61
|
// #region - Background Css Class
|
|
62
62
|
const buttonBackgroundCssClass: ComputedRef<string> = computed(() => {
|
|
63
|
-
if (variant === 'secondary') {
|
|
63
|
+
if (variant.value === 'secondary') {
|
|
64
64
|
if (pressed.value) {
|
|
65
65
|
return 'background-color-pressed !shadow-button';
|
|
66
66
|
}
|
|
@@ -68,7 +68,7 @@ export const useButton = (props: ButtonPropTypes, emit: SetupContext<ButtonEmitT
|
|
|
68
68
|
return isHovered.value ? 'background-color-hover' : 'background-color ';
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
if (variant === 'tertiary') {
|
|
71
|
+
if (variant.value === 'tertiary') {
|
|
72
72
|
return getTertiaryBackground();
|
|
73
73
|
}
|
|
74
74
|
|
|
@@ -104,7 +104,7 @@ export const useButton = (props: ButtonPropTypes, emit: SetupContext<ButtonEmitT
|
|
|
104
104
|
danger: 'background-color-danger-pressed !shadow-button',
|
|
105
105
|
};
|
|
106
106
|
|
|
107
|
-
return backgrounds[tone] || '';
|
|
107
|
+
return backgrounds[tone.value] || '';
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
function getHoveredBackground(): string {
|
|
@@ -114,7 +114,7 @@ export const useButton = (props: ButtonPropTypes, emit: SetupContext<ButtonEmitT
|
|
|
114
114
|
danger: 'background-color-danger-hover',
|
|
115
115
|
};
|
|
116
116
|
|
|
117
|
-
return backgrounds[tone] || '';
|
|
117
|
+
return backgrounds[tone.value] || '';
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
function getDefaultBackground(): string {
|
|
@@ -124,12 +124,12 @@ export const useButton = (props: ButtonPropTypes, emit: SetupContext<ButtonEmitT
|
|
|
124
124
|
danger: 'background-color-danger-base',
|
|
125
125
|
};
|
|
126
126
|
|
|
127
|
-
return backgrounds[tone] || '';
|
|
127
|
+
return backgrounds[tone.value] || '';
|
|
128
128
|
}
|
|
129
129
|
// #endregion - Background Css Class
|
|
130
130
|
|
|
131
131
|
const buttonBorderCssClass: ComputedRef<string> = computed(() => {
|
|
132
|
-
if (variant === 'primary' || variant === 'tertiary') {
|
|
132
|
+
if (variant.value === 'primary' || variant.value === 'tertiary') {
|
|
133
133
|
if (focused.value) {
|
|
134
134
|
return 'border-solid border border-white-50';
|
|
135
135
|
}
|
|
@@ -138,9 +138,9 @@ export const useButton = (props: ButtonPropTypes, emit: SetupContext<ButtonEmitT
|
|
|
138
138
|
}
|
|
139
139
|
|
|
140
140
|
return classNames({
|
|
141
|
-
'border-solid border border-color-base': tone === 'neutral',
|
|
142
|
-
'border-solid border border-color-brand-base': tone === 'success',
|
|
143
|
-
'border-solid border border-color-danger-base': tone === 'danger',
|
|
141
|
+
'border-solid border border-color-base': tone.value === 'neutral',
|
|
142
|
+
'border-solid border border-color-brand-base': tone.value === 'success',
|
|
143
|
+
'border-solid border border-color-danger-base': tone.value === 'danger',
|
|
144
144
|
});
|
|
145
145
|
});
|
|
146
146
|
|
|
@@ -149,22 +149,22 @@ export const useButton = (props: ButtonPropTypes, emit: SetupContext<ButtonEmitT
|
|
|
149
149
|
});
|
|
150
150
|
|
|
151
151
|
const buttonAllCssClass: ComputedRef<string> = computed(() => {
|
|
152
|
-
if (disabled) {
|
|
153
|
-
if (variant === 'primary')
|
|
152
|
+
if (disabled.value) {
|
|
153
|
+
if (variant.value === 'primary')
|
|
154
154
|
return classNames(
|
|
155
155
|
buttonDefaultCssClass.value,
|
|
156
156
|
buttonSizeCssClass.value,
|
|
157
157
|
'text-color-disabled background-color-disabled !shadow-none !cursor-not-allowed',
|
|
158
158
|
);
|
|
159
159
|
|
|
160
|
-
if (variant === 'secondary')
|
|
160
|
+
if (variant.value === 'secondary')
|
|
161
161
|
return classNames(
|
|
162
162
|
buttonDefaultCssClass.value,
|
|
163
163
|
buttonSizeCssClass.value,
|
|
164
164
|
'text-color-disabled border border-solid border border-color-disabled !shadow-none !cursor-not-allowed',
|
|
165
165
|
);
|
|
166
166
|
|
|
167
|
-
if (variant === 'tertiary')
|
|
167
|
+
if (variant.value === 'tertiary')
|
|
168
168
|
return classNames(
|
|
169
169
|
buttonDefaultCssClass.value,
|
|
170
170
|
buttonSizeCssClass.value,
|
|
@@ -181,7 +181,7 @@ export const useButton = (props: ButtonPropTypes, emit: SetupContext<ButtonEmitT
|
|
|
181
181
|
});
|
|
182
182
|
|
|
183
183
|
const handleClick = (evt: MouseEvent) => {
|
|
184
|
-
if (disabled) {
|
|
184
|
+
if (disabled.value) {
|
|
185
185
|
evt.stopPropagation();
|
|
186
186
|
|
|
187
187
|
return;
|
|
@@ -194,6 +194,6 @@ export const useButton = (props: ButtonPropTypes, emit: SetupContext<ButtonEmitT
|
|
|
194
194
|
buttonRef,
|
|
195
195
|
buttonProps,
|
|
196
196
|
buttonClass: buttonAllCssClass,
|
|
197
|
-
handleClick
|
|
197
|
+
handleClick
|
|
198
198
|
};
|
|
199
199
|
};
|