Skip to content

Commit

Permalink
feat(BaseButtonClose): update BaseButtonClose component styles and de…
Browse files Browse the repository at this point in the history
…fault values
  • Loading branch information
driss-chelouati committed Dec 17, 2023
1 parent 4ae77fa commit e4ea740
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 16 deletions.
3 changes: 3 additions & 0 deletions app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ export default defineAppConfig({
rounded: 'sm',
color: 'default',
},
BaseButtonClose: {
rounded: 'full',
},
BaseButtonIcon: {
rounded: 'sm',
color: 'default',
Expand Down
54 changes: 39 additions & 15 deletions components/base/BaseButtonClose.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,25 @@
const props = withDefaults(
defineProps<{
/**
* The shape of the button.
* The size of the button.
*
* @default 'sm'
*/
size?: 'xs' | 'sm' | 'md' | 'lg'
/**
* The radius of the button.
*
* @since 2.0.0
* @default 'full'
*/
rounded?: 'none' | 'sm' | 'md' | 'lg' | 'full'
/**
* The color of the button.
*
* @default 'default'
*/
shape?: 'straight' | 'rounded' | 'smooth' | 'curved' | 'full'
/** The color of the button. Can be 'default' or 'muted. */
color?:
| 'default'
| 'muted'
Expand All @@ -17,24 +32,32 @@ const props = withDefaults(
| 'none'
}>(),
{
shape: undefined,
color: 'default',
size: undefined,
rounded: undefined,
color: undefined,
},
)
const appConfig = useAppConfig()
const shape = computed(
() => props.shape ?? appConfig.nui.defaultShapes?.buttonClose,
)
const size = useNuiDefaultProperty(props, 'BaseButtonClose', 'size')
const rounded = useNuiDefaultProperty(props, 'BaseButtonClose', 'rounded')
const color = useNuiDefaultProperty(props, 'BaseButtonClose', 'color')
const shapeStyle = {
const sizes = {
xs: 'nui-button-xs',
sm: 'nui-button-sm',
md: 'nui-button-md',
lg: 'nui-button-lg',
} as Record<string, string>
const radiuses = {
straight: '',
rounded: 'nui-button-rounded',
smooth: 'nui-button-smooth',
curved: 'nui-button-curved',
full: 'nui-button-full',
}
const colorStyle = {
} as Record<string, string>
const colors = {
default: 'nui-button-default',
muted: 'nui-button-muted',
primary: 'nui-button-primary',
Expand All @@ -43,12 +66,13 @@ const colorStyle = {
warning: 'nui-button-warning',
danger: 'nui-button-danger',
none: '',
}
} as Record<string, string>
const classes = computed(() => [
'nui-button-close',
shape.value && shapeStyle[shape.value],
colorStyle[props.color],
size.value && sizes[size.value],
rounded.value && radiuses[rounded.value],
color.value && colors[color.value],
])
</script>

Expand Down
22 changes: 21 additions & 1 deletion nuxt.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default defineNuxtSchema({
/**
* Default size for the BaseButton component
*
* @type {'sm' | 'md' | 'lg' | 'xl'}
* @type {'sm' | 'md' | 'lg'}
*/
size: 'md',
},
Expand All @@ -41,6 +41,26 @@ export default defineNuxtSchema({
*/
color: 'default',
},
BaseButtonClose: {
/**
* Default size for the BaseButtonClose component
*
* @type {'xs' | 'sm' | 'md' | 'lg'}
*/
size: 'sm',
/**
* Default rounded for the BaseButtonClose component
*
* @type {'none' | 'sm' | 'md' | 'lg' | 'full'}
*/
rounded: 'full',
/**
* Default color for the BaseButtonClose component
*
* @type {'default'| 'primary'| 'info'| 'success'| 'warning'| 'danger'| 'light'| 'muted'| 'none'}
*/
color: 'default',
},
BaseButtonIcon: {
/**
* Default rounded for the BaseButtonIcon component
Expand Down

0 comments on commit e4ea740

Please sign in to comment.