-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
206 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<template> | ||
<Button size="small" rounded class="text-xs" :pt="preset" outline :ptOptions="{ mergeSections: false, mergeProps: false }" /> | ||
</template> | ||
|
||
<script setup> | ||
import Button from 'primevue/button'; | ||
const preset = { | ||
root: ({ props, context, parent }) => ({ | ||
class: [ | ||
'relative', | ||
// Alignments | ||
'items-center justify-center inline-flex text-center align-bottom', | ||
// Sizes & Spacing | ||
'text-sm', | ||
{ | ||
'px-2.5 py-1.5 min-w-[2rem]': props.size === null, | ||
'px-2 py-1': props.size === 'small', | ||
'px-3 py-2': props.size === 'large' | ||
}, | ||
{ | ||
'h-8 w-8 p-0': props.label == null && props.icon !== null | ||
}, | ||
// Shapes | ||
{ 'rounded-md': !props.rounded, 'rounded-full': props.rounded }, | ||
{ 'rounded-none first:rounded-l-md last:rounded-r-md self-center': parent.instance.$name == 'InputGroup' }, | ||
// Colors | ||
'text-surface-500 hover:bg-surface-200 dark:hover:bg-surface-300 hover:ring-surface-600 dark:hover:ring-surface-300', | ||
'active:bg-surface-400', | ||
// Disabled | ||
{ 'opacity-60 pointer-events-none cursor-default': context.disabled }, | ||
// Transitions | ||
'transition duration-200 ease-in-out', | ||
// Misc | ||
'cursor-pointer overflow-hidden select-none' | ||
] | ||
}), | ||
label: ({ props }) => ({ | ||
class: [ | ||
'duration-200', | ||
'font-semibold', | ||
{ | ||
'hover:underline': props.link | ||
}, | ||
{ 'flex-1': props.label !== null, 'invisible w-0': props.label == null } | ||
] | ||
}), | ||
icon: ({ props }) => ({ | ||
class: [ | ||
'mx-0', | ||
{ | ||
'mr-2': props.iconPos == 'left' && props.label != null, | ||
'ml-2 order-1': props.iconPos == 'right' && props.label != null, | ||
'mb-2': props.iconPos == 'top' && props.label != null, | ||
'mt-2': props.iconPos == 'bottom' && props.label != null | ||
} | ||
] | ||
}), | ||
loadingicon: ({ props }) => ({ | ||
class: [ | ||
'h-3 w-3', | ||
'mx-0', | ||
{ | ||
'mr-2': props.iconPos == 'left' && props.label != null, | ||
'ml-2 order-1': props.iconPos == 'right' && props.label != null, | ||
'mb-2': props.iconPos == 'top' && props.label != null, | ||
'mt-2': props.iconPos == 'bottom' && props.label != null | ||
}, | ||
'animate-spin' | ||
] | ||
}), | ||
badge: ({ props }) => ({ | ||
class: [{ 'ml-2 w-4 h-4 leading-none flex items-center justify-center': props.badge }] | ||
}) | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
<template> | ||
<ToggleButton :pt="preset" outline :ptOptions="{ mergeSections: false, mergeProps: false }" /> | ||
</template> | ||
|
||
<script setup> | ||
import ToggleButton from 'primevue/togglebutton'; | ||
const preset = { | ||
root: { | ||
class: [ | ||
'border-none', | ||
'relative', | ||
// Alignment | ||
'inline-flex', | ||
// Misc | ||
'cursor-pointer', | ||
'select-none', | ||
] | ||
}, | ||
box: ({ props }) => ({ | ||
class: [ | ||
// Alignments | ||
'items-center inline-flex flex-1 text-center align-bottom justify-center', | ||
// Sizes & Spacing | ||
'px-2 py-1', | ||
'text-xs', | ||
// Shapes | ||
'rounded-xl', | ||
{ 'ring-surface-200 dark:ring-surface-700': !props.invalid }, | ||
{ | ||
'bg-surface-0 dark:bg-surface-900 ': !props.modelValue, | ||
'bg-surface-600 text-white dark:bg-surface-700': props.modelValue | ||
}, | ||
// Invalid State | ||
{ 'ring-red-500 dark:ring-red-400': props.invalid }, | ||
// States | ||
{ | ||
'peer-hover:bg-surface-200': !props.modelValue, | ||
'peer-hover:bg-surface-700': props.modelValue | ||
}, | ||
, | ||
{ | ||
'peer-focus-visible:ring-2 peer-focus-visible:ring-inset peer-focus-visible:ring-primary-500 dark:peer-focus-visible:ring-primary-400': !props.disabled | ||
}, | ||
// Transitions | ||
'transition-all duration-200', | ||
// Misc | ||
{ 'cursor-pointer': !props.disabled, 'opacity-60 select-none pointer-events-none cursor-default': props.disabled } | ||
] | ||
}), | ||
label: ({ props }) => ({ | ||
class: [ | ||
'font-semibold text-center w-full', | ||
{ | ||
'text-surface-500': !props.modelValue, | ||
'text-white': props.modelValue | ||
}, | ||
] | ||
}), | ||
input: { | ||
class: [ | ||
'peer', | ||
// Size | ||
'w-full ', | ||
'h-full', | ||
// Position | ||
'absolute', | ||
'top-0 left-0', | ||
'z-10', | ||
// Spacing | ||
'p-0', | ||
'm-0', | ||
// Shape | ||
'opacity-0', | ||
// Misc | ||
'appearance-none', | ||
'cursor-pointer' | ||
] | ||
}, | ||
icon: ({ props }) => ({ | ||
class: [ | ||
'mr-2', | ||
{ | ||
'text-surface-500': !props.modelValue, | ||
'text-white': props.modelValue | ||
}, | ||
'transition-transform duration-200', | ||
{ | ||
'-rotate-45': !props.modelValue, | ||
'-rotate-90': props.modelValue | ||
}, | ||
] | ||
}) | ||
}; | ||
</script> |