Skip to content
This repository was archived by the owner on Sep 24, 2024. It is now read-only.

Commit 652e259

Browse files
SelemondevSelemondev
authored andcommitted
fix: button variants
1 parent 5a713eb commit 652e259

File tree

3 files changed

+21
-13
lines changed

3 files changed

+21
-13
lines changed

README.md

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ app.mount('#app')
145145

146146
2. Now you can use the component as shown below:
147147

148-
```js
148+
```vue
149149
<script setup lang='ts'>
150150
const items = [
151151
[{
@@ -158,6 +158,7 @@ const items = [
158158
icon: 'heroicons:pencil-square-20-solid',
159159
shortcuts: ['E'],
160160
click: () => {
161+
// eslint-disable-next-line no-console
161162
console.log('Edit')
162163
}
163164
}, {
@@ -258,7 +259,7 @@ export default defineConfig({
258259

259260
4. Now you can simply use any component that you want and it will be auto imported on demand ✨
260261

261-
```js
262+
```vue
262263
<script setup lang='ts'>
263264
const items = [
264265
[{
@@ -271,6 +272,7 @@ const items = [
271272
icon: 'heroicons:pencil-square-20-solid',
272273
shortcuts: ['E'],
273274
click: () => {
275+
// eslint-disable-next-line no-console
274276
console.log('Edit')
275277
}
276278
}, {
@@ -324,15 +326,17 @@ In regards to customization, NuxtLabs UI Vue offers two ways of customizing your
324326
325327
Here is an example of customizing a `UButton` component through the `variants` property:
326328
327-
```js
329+
```vue
328330
<template>
329-
<div>
330-
<UButton :variants="{
331-
'my-variant': {
332-
rounded: 'rounded-full'
333-
}
334-
}" :variant="['my-variant']" color="red" label="Button" />
335-
</div>
331+
<div>
332+
<UButton
333+
:variants="{
334+
'my-variant': {
335+
rounded: 'rounded-full',
336+
},
337+
}" :variant="['my-variant']" color="red" label="Button"
338+
/>
339+
</div>
336340
</template>
337341
```
338342

packages/nuxtlabs-ui-vue/src/components/elements/Button/UButton.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ const buttonClass = computed(() => {
160160
nuxtLabsTheme.UButton.base.gap[props.size],
161161
props.padded && nuxtLabsTheme.UButton.base[isSquare.value ? 'square' : 'padding'][props.size],
162162
variants.replaceAll('{color}', props.color),
163+
props.disabled && variant.value.buttonDisabled,
164+
(props.loading) && variant.value.buttonLoading,
163165
props.block ? variant.value.block : variant.value.normal,
164166
)
165167
})

packages/nuxtlabs-ui-vue/src/theme/nuxtLabsTheme.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,11 +196,13 @@ export default {
196196

197197
UButton: {
198198
base: {
199-
root: 'focus:outline-none focus-visible:outline-0 disabled:cursor-not-allowed disabled:opacity-75 flex-shrink-0',
199+
root: 'focus:outline-none text-white dark:text-white block font-medium focus-visible:outline-0 rounded-md disabled:cursor-not-allowed disabled:opacity-75 flex-shrink-0 transition-all duration-200 ease-in',
200200
font: 'font-medium',
201201
rounded: 'rounded-md',
202202
block: 'w-full flex justify-center items-center',
203203
normal: 'inline-flex items-center',
204+
buttonLoading: '!bg-opacity-50 opacity-50 pointer-events-none !cursor-not-allowed !hover:bg-opacity-50 inline-flex items-center',
205+
buttonDisabled: '!shadow-none !cursor-not-allowed pointer-events-none opacity-50',
204206
truncate: 'text-left break-all line-clamp-1',
205207
size: {
206208
'2xs': 'text-xs',
@@ -272,7 +274,7 @@ export default {
272274
size: 'sm',
273275
intent: 'solid',
274276
color: 'green',
275-
loadingIcon: 'svg-spinners:bars-rotate-fade',
277+
loadingIcon: 'heroicons:arrow-path-20-solid',
276278
},
277279
},
278280

@@ -282,7 +284,7 @@ export default {
282284
size: 'sm',
283285
intent: 'solid',
284286
color: 'green',
285-
loadingIcon: 'svg-spinners:bars-rotate-fade',
287+
loadingIcon: 'heroicons:arrow-path-20-solid',
286288
},
287289
intent: {
288290
solid: 'shadow-sm text-white dark:text-gray-900 bg-{color}-500 hover:enabled:bg-{color}-600 disabled:bg-{color}-500 dark:bg-{color}-400 dark:hover:enabled:bg-{color}-500 dark:disabled:bg-{color}-400 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-{color}-500 dark:focus-visible:outline-{color}-400',

0 commit comments

Comments
 (0)