@dataloop-ai/components 0.17.36 → 0.17.37
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.
package/package.json
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
:disabled="disabled"
|
|
13
13
|
:style="[computedStyles]"
|
|
14
14
|
style="pointer-events: auto"
|
|
15
|
-
class="
|
|
15
|
+
:class="buttonClass"
|
|
16
16
|
@click="onClick"
|
|
17
17
|
@mousedown="onMouseDown"
|
|
18
18
|
>
|
|
@@ -74,6 +74,7 @@ import { v4 } from 'uuid'
|
|
|
74
74
|
import { ButtonColors } from './types'
|
|
75
75
|
import { transformOptions } from '../../shared/types'
|
|
76
76
|
import { stringStyleToRecord } from '../../../utils'
|
|
77
|
+
import { textTransform } from '../../../utils/string'
|
|
77
78
|
import { isString } from 'lodash'
|
|
78
79
|
|
|
79
80
|
export default defineComponent({
|
|
@@ -84,27 +85,66 @@ export default defineComponent({
|
|
|
84
85
|
},
|
|
85
86
|
|
|
86
87
|
props: {
|
|
88
|
+
/**
|
|
89
|
+
* The user will not be able to press on the button
|
|
90
|
+
*/
|
|
87
91
|
disabled: Boolean,
|
|
92
|
+
/**
|
|
93
|
+
* The color of the button
|
|
94
|
+
*/
|
|
88
95
|
color: {
|
|
89
96
|
type: String! as PropType<keyof typeof colorNames>,
|
|
90
97
|
default: ''
|
|
91
98
|
},
|
|
99
|
+
/**
|
|
100
|
+
* The button's padding is lowered and the white space shrinks
|
|
101
|
+
*/
|
|
92
102
|
dense: { type: Boolean, default: false },
|
|
103
|
+
/**
|
|
104
|
+
* The text content of the button
|
|
105
|
+
*/
|
|
93
106
|
label: { type: String, default: '' },
|
|
107
|
+
/**
|
|
108
|
+
* The color of the button's text
|
|
109
|
+
*/
|
|
94
110
|
textColor: { type: String!, default: '' },
|
|
95
111
|
colorsObject: {
|
|
96
112
|
type: Object as PropType<ButtonColors>,
|
|
97
113
|
default: null
|
|
98
114
|
},
|
|
115
|
+
/**
|
|
116
|
+
* The color of the icon inside the button
|
|
117
|
+
*/
|
|
99
118
|
iconColor: { type: String!, default: '' },
|
|
119
|
+
/** Padding inside the button */
|
|
100
120
|
padding: { type: String, default: '' },
|
|
121
|
+
/**
|
|
122
|
+
* The size of the button, it can be s,m,l or xl
|
|
123
|
+
*/
|
|
101
124
|
margin: { type: String, default: '0 auto' },
|
|
102
125
|
size: { type: String! as PropType<ButtonSizes>, default: 'm' },
|
|
126
|
+
/**
|
|
127
|
+
* The assigned color will fill the entirety of the button
|
|
128
|
+
*/
|
|
103
129
|
filled: { type: Boolean, default: true },
|
|
130
|
+
/** Makes the button rounded */
|
|
104
131
|
round: { type: Boolean, default: false },
|
|
132
|
+
/**
|
|
133
|
+
* The width of the button will take that of its container
|
|
134
|
+
*/
|
|
105
135
|
shaded: { type: Boolean, default: false },
|
|
106
136
|
fluid: Boolean,
|
|
137
|
+
/**
|
|
138
|
+
* The button will not have an outline
|
|
139
|
+
*/
|
|
107
140
|
flat: Boolean,
|
|
141
|
+
/**
|
|
142
|
+
* All the characters inside the button will be uppercase
|
|
143
|
+
*/
|
|
144
|
+
uppercase: Boolean,
|
|
145
|
+
/**
|
|
146
|
+
* The button will be transparent with a colored outline
|
|
147
|
+
*/
|
|
108
148
|
transform: {
|
|
109
149
|
type: String,
|
|
110
150
|
default: 'default',
|
|
@@ -112,10 +152,23 @@ export default defineComponent({
|
|
|
112
152
|
transformOptions.includes(value)
|
|
113
153
|
},
|
|
114
154
|
outlined: Boolean,
|
|
155
|
+
/**
|
|
156
|
+
* Doesn't allow the button's text to be wrapped along multiple rows
|
|
157
|
+
*/
|
|
115
158
|
noWrap: Boolean,
|
|
159
|
+
/**
|
|
160
|
+
* The name of the icon to go inside the button
|
|
161
|
+
*/
|
|
116
162
|
icon: { type: String, default: '' },
|
|
117
163
|
overflow: { type: Boolean, default: false, required: false },
|
|
164
|
+
/**
|
|
165
|
+
* The tooltip displayed when hovering over the button
|
|
166
|
+
*/
|
|
118
167
|
tooltip: { type: String, default: null, required: false },
|
|
168
|
+
/**
|
|
169
|
+
* The button will mentain the styles it has when it's pressed if this prop is active
|
|
170
|
+
*/
|
|
171
|
+
active: { type: Boolean, default: false, required: false },
|
|
119
172
|
styles: { type: [Object, String], default: null }
|
|
120
173
|
},
|
|
121
174
|
emits: ['click', 'mousedown'],
|
|
@@ -157,6 +210,12 @@ export default defineComponent({
|
|
|
157
210
|
this.label !== ''
|
|
158
211
|
)
|
|
159
212
|
},
|
|
213
|
+
buttonLabel(): string {
|
|
214
|
+
return textTransform(this.label)
|
|
215
|
+
},
|
|
216
|
+
buttonClass() {
|
|
217
|
+
return this.active ? 'dl-button active-class' : 'dl-button'
|
|
218
|
+
},
|
|
160
219
|
hasIcon(): boolean {
|
|
161
220
|
return typeof this.icon === 'string' && this.icon !== ''
|
|
162
221
|
},
|
|
@@ -394,4 +453,14 @@ export default defineComponent({
|
|
|
394
453
|
display: inline-block;
|
|
395
454
|
width: var(--dl-button-container-width);
|
|
396
455
|
}
|
|
456
|
+
|
|
457
|
+
.active-class {
|
|
458
|
+
color: var(--dl-button-text-color-hover);
|
|
459
|
+
background-color: var(--dl-button-bg-hover);
|
|
460
|
+
border-color: var(--dl-button-border-hover);
|
|
461
|
+
& .dl-button-label {
|
|
462
|
+
transition: all ease-in 0.15s;
|
|
463
|
+
color: var(--dl-button-color-hover);
|
|
464
|
+
}
|
|
465
|
+
}
|
|
397
466
|
</style>
|
|
@@ -194,6 +194,33 @@
|
|
|
194
194
|
Disabled
|
|
195
195
|
</DlButton>
|
|
196
196
|
</div>
|
|
197
|
+
<div
|
|
198
|
+
style="
|
|
199
|
+
display: flex;
|
|
200
|
+
justify-content: center;
|
|
201
|
+
flex-direction: column;
|
|
202
|
+
"
|
|
203
|
+
>
|
|
204
|
+
<h3>Button keeping its active state with menu</h3>
|
|
205
|
+
<dl-button
|
|
206
|
+
:active="activeButtonState"
|
|
207
|
+
@click="activeButtonState = !activeButtonState"
|
|
208
|
+
>
|
|
209
|
+
{{ activeButtonState ? 'Close' : 'Open' }}
|
|
210
|
+
<dl-menu
|
|
211
|
+
:offset="[0, 5]"
|
|
212
|
+
anchor="bottom middle"
|
|
213
|
+
self="top middle"
|
|
214
|
+
:model-value="!activeButtonState"
|
|
215
|
+
>
|
|
216
|
+
<div
|
|
217
|
+
style="width: 100px; height: 100px; text-align: center"
|
|
218
|
+
>
|
|
219
|
+
Menu
|
|
220
|
+
</div>
|
|
221
|
+
</dl-menu>
|
|
222
|
+
</dl-button>
|
|
223
|
+
</div>
|
|
197
224
|
<div>
|
|
198
225
|
<h3>With badge</h3>
|
|
199
226
|
|
|
@@ -261,10 +288,9 @@
|
|
|
261
288
|
</template>
|
|
262
289
|
|
|
263
290
|
<script lang="ts">
|
|
264
|
-
import { defineComponent, reactive } from 'vue-demi'
|
|
265
|
-
import { DlButton, DlBadge, DlIcon } from '../components'
|
|
291
|
+
import { defineComponent, reactive, ref } from 'vue-demi'
|
|
292
|
+
import { DlButton, DlBadge, DlIcon, DlMenu } from '../components'
|
|
266
293
|
import { ButtonSizes } from '../components/basic/DlButton/utils'
|
|
267
|
-
import DlMenu from '../components/essential/DlMenu/DlMenu.vue'
|
|
268
294
|
import DlList from '../components/essential/DlList/DlList.vue'
|
|
269
295
|
import DlListItem from '../components/basic/DlListItem/DlListItem.vue'
|
|
270
296
|
|
|
@@ -280,9 +306,10 @@ export default defineComponent({
|
|
|
280
306
|
},
|
|
281
307
|
setup() {
|
|
282
308
|
const buttons = reactive<ButtonSizes[]>(['s', 'm', 'l', 'xl'])
|
|
309
|
+
const activeButtonState = ref(false)
|
|
283
310
|
|
|
284
311
|
const log = (e: Event) => console.log(e)
|
|
285
|
-
return { buttons, log }
|
|
312
|
+
return { buttons, log, activeButtonState }
|
|
286
313
|
}
|
|
287
314
|
})
|
|
288
315
|
</script>
|