@saasmakers/ui 2.0.21 → 2.0.22

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.
@@ -5,10 +5,10 @@ import type { BaseAvatar } from '../../types/bases'
5
5
  const props = withDefaults(defineProps<BaseAvatar>(), {
6
6
  bordered: true,
7
7
  borderWidth: 3,
8
- circular: true,
9
8
  editable: false,
10
9
  maxSizeMb: undefined,
11
10
  shadow: true,
11
+ shape: 'circle',
12
12
  src: undefined,
13
13
  to: undefined,
14
14
  })
@@ -102,7 +102,8 @@ function onMouseLeave() {
102
102
  :aria-label="editable ? t('edit') : undefined"
103
103
  class="relative h-full w-full overflow-hidden"
104
104
  :class="{
105
- 'rounded-full': circular,
105
+ 'rounded-full': shape === 'circle',
106
+ 'rounded-lg': shape === 'square',
106
107
  'shadow': shadow,
107
108
  'cursor-pointer': isClickable,
108
109
  }"
@@ -116,7 +117,8 @@ function onMouseLeave() {
116
117
  <img
117
118
  class="h-full w-full object-cover drag-none"
118
119
  :class="{
119
- 'rounded-full': circular,
120
+ 'rounded-full': shape === 'circle',
121
+ 'rounded-lg': shape === 'square',
120
122
  'border-white dark:border-white': bordered,
121
123
  'border-2': bordered && borderWidth === 2,
122
124
  'border-3': bordered && borderWidth === 3,
@@ -1,10 +1,11 @@
1
1
  <script lang="ts" setup>
2
2
  import { NuxtLinkLocale } from '#components'
3
- import type { BaseButton } from '../../types/bases'
3
+ import type { BaseButton, BaseButtonShape } from '../../types/bases'
4
+
5
+ const fixedSizeButtonShapes = ['square', 'circle'] satisfies BaseButtonShape[]
4
6
 
5
7
  const props = withDefaults(defineProps<BaseButton>(), {
6
8
  background: true,
7
- circular: false,
8
9
  color: 'black',
9
10
  confirmation: false,
10
11
  disabled: false,
@@ -15,6 +16,7 @@ const props = withDefaults(defineProps<BaseButton>(), {
15
16
  light: false,
16
17
  loading: false,
17
18
  reverse: false,
19
+ shape: 'default',
18
20
  size: 'base',
19
21
  text: '',
20
22
  to: undefined,
@@ -33,6 +35,10 @@ defineSlots<{
33
35
  const confirming = ref(false)
34
36
  const { t } = useI18n()
35
37
 
38
+ const hasFixedSize = computed(() => {
39
+ return fixedSizeButtonShapes.includes(props.shape)
40
+ })
41
+
36
42
  function onClick(event: MouseEvent) {
37
43
  if (!props.loading) {
38
44
  if (props.confirmation) {
@@ -56,21 +62,21 @@ function onClick(event: MouseEvent) {
56
62
  :is="to ? NuxtLinkLocale : 'button'"
57
63
  class="relative inline-block select-none appearance-none border uppercase focus-visible:outline-none"
58
64
  :class="{
59
- 'flex items-center justify-center': circular,
65
+ 'flex items-center justify-center': hasFixedSize,
60
66
  'cursor-not-allowed opacity-50': disabled,
61
67
  'cursor-wait': loading,
62
68
  'cursor-pointer': !loading,
63
69
  'w-full': fullWidth,
64
70
  'bg-transparent shadow-none': light,
65
71
  'shadow-sm': !light,
66
- 'rounded-lg': !circular,
67
- 'rounded-full': circular,
68
- 'h-6 w-6': size === '2xs' && circular,
69
- 'h-8 w-8': size === 'xs' && circular && !confirming,
70
- 'h-10 w-10': size === 'sm' && circular && !confirming,
71
- 'h-12 w-12': size === 'base' && circular && !confirming,
72
- 'h-14 w-14': size === 'lg' && circular && !confirming,
73
- 'h-16 w-16': size === 'xl' && circular && !confirming,
72
+ 'rounded-lg': shape !== 'circle',
73
+ 'rounded-full': shape === 'circle',
74
+ 'h-6 w-6': size === '2xs' && hasFixedSize,
75
+ 'h-8 w-8': size === 'xs' && hasFixedSize && !confirming,
76
+ 'h-10 w-10': size === 'sm' && hasFixedSize && !confirming,
77
+ 'h-12 w-12': size === 'base' && hasFixedSize && !confirming,
78
+ 'h-14 w-14': size === 'lg' && hasFixedSize && !confirming,
79
+ 'h-16 w-16': size === 'xl' && hasFixedSize && !confirming,
74
80
  'border-gray-900 dark:border-gray-100 bg-gray-900 dark:bg-gray-100 text-white dark:text-black': color === 'black' && !light,
75
81
  'hover:bg-black dark:hover:bg-white hover:text-white dark:hover:text-black': color === 'black' && !light && !disabled && !loading,
76
82
  'border-gray-900 dark:border-gray-100 text-gray-900 dark:text-gray-100': color === 'black' && light,
@@ -94,12 +100,12 @@ function onClick(event: MouseEvent) {
94
100
  'border-white dark:border-gray-900 text-white dark:text-black': color === 'white' && light,
95
101
  'hover:border-black dark:hover:border-white hover:text-black dark:hover:text-white': color !== 'white' && light && !disabled && !loading,
96
102
  'hover:bg-white dark:hover:bg-gray-900 hover:text-gray-800 dark:hover:text-gray-200': color === 'white' && light && !disabled && !loading,
97
- 'h-6 px-3': size === '2xs' && (!circular || confirming),
98
- 'h-8 px-4': size === 'xs' && (!circular || confirming),
99
- 'h-10 px-5': size === 'sm' && (!circular || confirming),
100
- 'h-12 px-6': size === 'base' && (!circular || confirming),
101
- 'h-13 px-6.5': size === 'lg' && (!circular || confirming),
102
- 'h-14 px-7': size === 'xl' && (!circular || confirming),
103
+ 'h-6 px-3': size === '2xs' && (!hasFixedSize || confirming),
104
+ 'h-8 px-4': size === 'xs' && (!hasFixedSize || confirming),
105
+ 'h-10 px-5': size === 'sm' && (!hasFixedSize || confirming),
106
+ 'h-12 px-6': size === 'base' && (!hasFixedSize || confirming),
107
+ 'h-13 px-6.5': size === 'lg' && (!hasFixedSize || confirming),
108
+ 'h-14 px-7': size === 'xl' && (!hasFixedSize || confirming),
103
109
  }"
104
110
  :disabled="disabled"
105
111
  :to="to"
@@ -128,7 +128,7 @@ function onOpenFilePicker() {
128
128
 
129
129
  <BaseText
130
130
  class="min-w-0 flex-1 text-gray-900 dark:text-gray-100"
131
- :size="({ base: 'sm', lg: 'base', sm: 'xs' } as const)[size]"
131
+ :size="({ base: 'sm', lg: 'base', sm: 'xs', xs: '2xs' } as const)[size]"
132
132
  :text="loading ? t('actionLoading') : (action || t('action'))"
133
133
  />
134
134
  </div>
@@ -166,6 +166,7 @@ defineExpose({ blur, focus })
166
166
  <div
167
167
  class="flex items-center"
168
168
  :class="{
169
+ 'h-8': size === 'xs',
169
170
  'h-10': size === 'sm',
170
171
  'h-12': size === 'base',
171
172
  'h-14': size === 'lg',
@@ -199,6 +200,7 @@ defineExpose({ blur, focus })
199
200
  'px-10': border === 'bottom' && type !== 'password',
200
201
  'border-0 p-0': border === 'none' && type !== 'password',
201
202
  'border-0 pr-9': border === 'none' && type === 'password',
203
+ 'text-2xs': size === 'xs',
202
204
  'text-xs': size === 'sm',
203
205
  'text-sm': size === 'base',
204
206
  'text-base': size === 'lg',
@@ -29,6 +29,8 @@ const textSize = computed<BaseSize>(() => {
29
29
  return 'base'
30
30
  case 'sm':
31
31
  return 'xs'
32
+ case 'xs':
33
+ return '2xs'
32
34
  default:
33
35
  return 'sm'
34
36
  }
@@ -69,9 +71,11 @@ function onKeyDown(event: KeyboardEvent) {
69
71
  'text-gray-500 dark:text-gray-500 line-through': lineThrough,
70
72
  'hover:text-black dark:hover:text-white': isClickable && !lineThrough,
71
73
  'w-0 truncate': truncate,
74
+ 'mb-1.5': size === 'xs' && hasMarginBottom,
72
75
  'mb-2': size === 'sm' && hasMarginBottom,
73
76
  'mb-2.5': size === 'base' && hasMarginBottom,
74
77
  'mb-3': size === 'lg' && hasMarginBottom,
78
+ 'ml-1': size === 'xs' && hasMarginLeft,
75
79
  'ml-1.5': size === 'sm' && hasMarginLeft,
76
80
  'ml-2': size === 'base' && hasMarginLeft,
77
81
  'ml-2.5': size === 'lg' && hasMarginLeft,
@@ -24,13 +24,17 @@ export interface BaseAlert {
24
24
  // Global types for bases
25
25
  export type BaseAlignment = 'center' | 'left' | 'right'
26
26
 
27
+ export type BaseButtonShape = 'circle' | 'default' | 'square'
28
+
29
+ export type BaseAvatarShape = 'circle' | 'square'
30
+
27
31
  export interface BaseAvatar {
28
32
  bordered?: boolean
29
33
  borderWidth?: number
30
- circular?: boolean
31
34
  editable?: boolean
32
35
  maxSizeMb?: number
33
36
  shadow?: boolean
37
+ shape?: BaseAvatarShape
34
38
  src?: string
35
39
  to?: RouteLocationNamedI18n
36
40
  }
@@ -49,7 +53,6 @@ export type BaseBorderedColor = 'black' | 'gray'
49
53
 
50
54
  export interface BaseButton {
51
55
  background?: boolean
52
- circular?: boolean
53
56
  color?: BaseColor
54
57
  confirmation?: boolean
55
58
  disabled?: boolean
@@ -60,6 +63,7 @@ export interface BaseButton {
60
63
  light?: boolean
61
64
  loading?: boolean
62
65
  reverse?: boolean
66
+ shape?: BaseButtonShape
63
67
  size?: BaseButtonSize
64
68
  text?: BaseTextText
65
69
  to?: RouteLocationNamedI18n
@@ -155,7 +155,7 @@ export interface FieldSelectOption {
155
155
  value: string
156
156
  }
157
157
 
158
- export type FieldSize = 'base' | 'lg' | 'sm'
158
+ export type FieldSize = 'base' | 'lg' | 'sm' | 'xs'
159
159
 
160
160
  export type FieldStatus
161
161
  = | 'default'
@@ -66,6 +66,8 @@ declare global {
66
66
  type BaseQuoteSize = import('./bases').BaseQuoteSize
67
67
  type BaseShortcut = import('./bases').BaseShortcut
68
68
  type BaseSize = import('./bases').BaseSize
69
+ type BaseButtonShape = import('./bases').BaseButtonShape
70
+ type BaseAvatarShape = import('./bases').BaseAvatarShape
69
71
  type BaseSpinner = import('./bases').BaseSpinner
70
72
  type BaseStatus = import('./bases').BaseStatus
71
73
  type BaseTag = import('./bases').BaseTag
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saasmakers/ui",
3
- "version": "2.0.21",
3
+ "version": "2.0.22",
4
4
  "private": false,
5
5
  "description": "Reusable Nuxt UI components for SaaS Makers projects",
6
6
  "license": "MIT",