@saasmakers/ui 0.1.18 → 0.1.20
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/app/app.vue +1 -1
- package/app/components/bases/BaseDivider.vue +41 -0
- package/app/components/bases/BaseText.vue +169 -0
- package/{types → app/types}/bases.d.ts +15 -4
- package/nuxt.config.ts +1 -9
- package/package.json +5 -6
- package/app/components/bases/HelloWorld.vue +0 -5
- /package/{types → app/types}/index.d.ts +0 -0
package/app/app.vue
CHANGED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
withDefaults(defineProps<BaseDivider>(), {
|
|
3
|
+
borderStyle: 'solid',
|
|
4
|
+
margin: 6,
|
|
5
|
+
size: 'base',
|
|
6
|
+
title: '',
|
|
7
|
+
})
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<template>
|
|
11
|
+
<div
|
|
12
|
+
class="relative block border-t border-gray-300 text-center dark:border-gray-700"
|
|
13
|
+
:class="{
|
|
14
|
+
'border-dashed': borderStyle === 'dashed',
|
|
15
|
+
'border-dotted': borderStyle === 'dotted',
|
|
16
|
+
'border-solid': borderStyle === 'solid',
|
|
17
|
+
|
|
18
|
+
'my-3': margin === 3,
|
|
19
|
+
'my-4': margin === 4,
|
|
20
|
+
'my-5': margin === 5,
|
|
21
|
+
'my-6': margin === 6,
|
|
22
|
+
'my-7': margin === 7,
|
|
23
|
+
'my-8': margin === 8,
|
|
24
|
+
'my-10': margin === 10,
|
|
25
|
+
'my-12': margin === 12,
|
|
26
|
+
'my-16': margin === 16,
|
|
27
|
+
'my-20': margin === 20,
|
|
28
|
+
|
|
29
|
+
'mx-auto max-w-xs': size === 'sm',
|
|
30
|
+
'w-full': size === 'base',
|
|
31
|
+
}"
|
|
32
|
+
style="height: 1px"
|
|
33
|
+
>
|
|
34
|
+
<BaseText
|
|
35
|
+
v-if="title"
|
|
36
|
+
class="absolute inline-block transform whitespace-nowrap bg-gray-100 px-4 text-center -mt-3 -translate-x-1/2 dark:bg-gray-900"
|
|
37
|
+
size="sm"
|
|
38
|
+
:text="title"
|
|
39
|
+
/>
|
|
40
|
+
</div>
|
|
41
|
+
</template>
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { NuxtLinkLocale } from '#components'
|
|
3
|
+
|
|
4
|
+
const props = withDefaults(defineProps<BaseText>(), {
|
|
5
|
+
background: '',
|
|
6
|
+
bold: false,
|
|
7
|
+
hasMargin: false,
|
|
8
|
+
maxCharacters: 0,
|
|
9
|
+
noWrap: false,
|
|
10
|
+
reverse: false,
|
|
11
|
+
size: 'base',
|
|
12
|
+
skeleton: false,
|
|
13
|
+
text: '',
|
|
14
|
+
to: undefined,
|
|
15
|
+
truncate: false,
|
|
16
|
+
underline: false,
|
|
17
|
+
uppercase: false,
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
const emit = defineEmits<{
|
|
21
|
+
click: [event: MouseEvent]
|
|
22
|
+
}>()
|
|
23
|
+
|
|
24
|
+
const showAll = ref(false)
|
|
25
|
+
|
|
26
|
+
const { t } = useI18n()
|
|
27
|
+
|
|
28
|
+
const finalText = computed(() => {
|
|
29
|
+
if (props.maxCharacters && typeof props.text === 'string') {
|
|
30
|
+
return ellipsize(
|
|
31
|
+
props.text,
|
|
32
|
+
showAll.value ? Number.POSITIVE_INFINITY : props.maxCharacters,
|
|
33
|
+
)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return props.text as string
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
function ellipsize(inputString: string, maxLength: number) {
|
|
40
|
+
if (inputString.length <= maxLength) {
|
|
41
|
+
return inputString
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
// If the input string is longer than the maximum length, find the last full word that fits
|
|
45
|
+
const truncatedString = inputString.slice(0, maxLength)
|
|
46
|
+
const lastSpaceIndex = truncatedString.lastIndexOf(' ')
|
|
47
|
+
|
|
48
|
+
// If there's no space in the truncated string, we can't avoid cutting a word
|
|
49
|
+
if (lastSpaceIndex === -1) {
|
|
50
|
+
return `${truncatedString.slice(0, maxLength - 3)}...`
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Return the string truncated at the last full word, with an ellipsis appended
|
|
54
|
+
return `${truncatedString.slice(0, lastSpaceIndex)}...`
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function onClick(event: MouseEvent) {
|
|
59
|
+
if (props.to) {
|
|
60
|
+
event.stopPropagation()
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
emit('click', event)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function onShowMore() {
|
|
67
|
+
showAll.value = true
|
|
68
|
+
}
|
|
69
|
+
</script>
|
|
70
|
+
|
|
71
|
+
<template>
|
|
72
|
+
<Component
|
|
73
|
+
:is="to ? NuxtLinkLocale : 'div'"
|
|
74
|
+
:class="{
|
|
75
|
+
'font-bold': bold,
|
|
76
|
+
'font-medium': uppercase || !bold,
|
|
77
|
+
'truncate': truncate,
|
|
78
|
+
'underline text-indigo-700 dark:text-indigo-300': !!to,
|
|
79
|
+
'uppercase': uppercase,
|
|
80
|
+
'whitespace-nowrap': noWrap,
|
|
81
|
+
underline,
|
|
82
|
+
|
|
83
|
+
'bg-gray-100 dark:bg-gray-900': background === 'gray',
|
|
84
|
+
'bg-white dark:bg-gray-900': background === 'white',
|
|
85
|
+
|
|
86
|
+
'ml-0.5': ['3xs'].includes(size) && !reverse && hasMargin,
|
|
87
|
+
'ml-1.5': ['2xs', 'xs', 'sm'].includes(size) && !reverse && hasMargin,
|
|
88
|
+
'ml-2': ['base', 'lg'].includes(size) && !reverse && hasMargin,
|
|
89
|
+
'ml-2.5': ['xl', '2xl'].includes(size) && !reverse && hasMargin,
|
|
90
|
+
'ml-3': ['3xl', '4xl'].includes(size) && !reverse && hasMargin,
|
|
91
|
+
'mr-0.5': ['3xs'].includes(size) && reverse && hasMargin,
|
|
92
|
+
'mr-1.5': ['2xs', 'xs', 'sm'].includes(size) && reverse && hasMargin,
|
|
93
|
+
'mr-2': ['base', 'lg'].includes(size) && reverse && hasMargin,
|
|
94
|
+
'mr-2.5': ['xl', '2xl'].includes(size) && reverse && hasMargin,
|
|
95
|
+
'mr-3': ['3xl', '4xl'].includes(size) && reverse && hasMargin,
|
|
96
|
+
|
|
97
|
+
'text-3xs': (size === '3xs') && !uppercase,
|
|
98
|
+
'text-2xs': (size === '2xs') || (size === 'xs' && uppercase),
|
|
99
|
+
'text-xs': (size === 'xs' && !uppercase) || (size === 'sm' && uppercase),
|
|
100
|
+
'text-sm': (size === 'sm' && !uppercase) || (size === 'base' && uppercase),
|
|
101
|
+
'text-base': (size === 'base' && !uppercase) || (size === 'lg' && uppercase),
|
|
102
|
+
'text-lg': (size === 'lg' && !uppercase) || (size === 'xl' && uppercase),
|
|
103
|
+
'text-xl': (size === 'xl' && !uppercase) || (size === '2xl' && uppercase),
|
|
104
|
+
'text-2xl': (size === '2xl' && !uppercase) || (size === '3xl' && uppercase),
|
|
105
|
+
'text-3xl': (size === '3xl' && !uppercase) || (size === '4xl' && uppercase),
|
|
106
|
+
'text-4xl': size === '4xl' && !uppercase,
|
|
107
|
+
}"
|
|
108
|
+
:to="to"
|
|
109
|
+
@click="onClick"
|
|
110
|
+
>
|
|
111
|
+
<template v-if="!skeleton">
|
|
112
|
+
<span v-if="maxCharacters || typeof text === 'string'">
|
|
113
|
+
{{ finalText }}
|
|
114
|
+
</span>
|
|
115
|
+
|
|
116
|
+
<template v-else-if="typeof text === 'object'">
|
|
117
|
+
<span class="sm:hidden">
|
|
118
|
+
{{ text.sm }}
|
|
119
|
+
</span>
|
|
120
|
+
|
|
121
|
+
<span class="hidden sm:inline">
|
|
122
|
+
{{ text.base }}
|
|
123
|
+
</span>
|
|
124
|
+
</template>
|
|
125
|
+
|
|
126
|
+
<BaseText
|
|
127
|
+
v-if="maxCharacters && typeof text === 'string' && finalText?.length !== text.length"
|
|
128
|
+
class="inline cursor-pointer text-indigo-700 dark:text-indigo-300"
|
|
129
|
+
has-margin
|
|
130
|
+
:size="size"
|
|
131
|
+
:text="t('showMore')"
|
|
132
|
+
@click="onShowMore"
|
|
133
|
+
/>
|
|
134
|
+
</template>
|
|
135
|
+
|
|
136
|
+
<div
|
|
137
|
+
v-else
|
|
138
|
+
class="w-full rounded bg-gray-300 dark:bg-gray-700"
|
|
139
|
+
:class="{
|
|
140
|
+
'h-2': size === '3xs',
|
|
141
|
+
'h-2.5': size === '2xs',
|
|
142
|
+
'h-3': size === 'xs',
|
|
143
|
+
'h-3.5': size === 'sm',
|
|
144
|
+
'h-4': size === 'base',
|
|
145
|
+
'h-4.5': size === 'lg',
|
|
146
|
+
'h-5': size === 'xl',
|
|
147
|
+
'h-6': size === '2xl',
|
|
148
|
+
'h-7': size === '3xl',
|
|
149
|
+
'h-8': size === '4xl',
|
|
150
|
+
}"
|
|
151
|
+
/>
|
|
152
|
+
|
|
153
|
+
<slot />
|
|
154
|
+
</Component>
|
|
155
|
+
</template>
|
|
156
|
+
|
|
157
|
+
<i18n lang="json">
|
|
158
|
+
{
|
|
159
|
+
"en": {
|
|
160
|
+
"showMore": "(show more)"
|
|
161
|
+
},
|
|
162
|
+
"fr": {
|
|
163
|
+
"showMore": "(afficher)"
|
|
164
|
+
},
|
|
165
|
+
"ja": {
|
|
166
|
+
"showMore": "(もっと見る)"
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
</i18n>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
declare global {
|
|
2
|
-
|
|
2
|
+
type BaseColor
|
|
3
3
|
= | 'black'
|
|
4
4
|
| 'gray'
|
|
5
5
|
| 'green'
|
|
@@ -8,7 +8,7 @@ declare global {
|
|
|
8
8
|
| 'red'
|
|
9
9
|
| 'white'
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
type BaseSize
|
|
12
12
|
= | '2xl'
|
|
13
13
|
| '2xs'
|
|
14
14
|
| '3xl'
|
|
@@ -20,12 +20,23 @@ declare global {
|
|
|
20
20
|
| 'xl'
|
|
21
21
|
| 'xs'
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
type BaseStatus
|
|
24
24
|
= | 'error'
|
|
25
25
|
| 'info'
|
|
26
26
|
| 'success'
|
|
27
27
|
| 'warning'
|
|
28
28
|
|
|
29
|
+
interface BaseDivider {
|
|
30
|
+
borderStyle?: BaseDividerBorderStyle
|
|
31
|
+
margin?: number
|
|
32
|
+
size?: BaseDividerSize
|
|
33
|
+
title?: string
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
type BaseDividerBorderStyle = 'dashed' | 'dotted' | 'solid'
|
|
37
|
+
|
|
38
|
+
type BaseDividerSize = 'base' | 'sm'
|
|
39
|
+
|
|
29
40
|
interface BaseText {
|
|
30
41
|
background?: BaseTextBackground
|
|
31
42
|
bold?: boolean
|
|
@@ -42,7 +53,7 @@ declare global {
|
|
|
42
53
|
uppercase?: boolean
|
|
43
54
|
}
|
|
44
55
|
|
|
45
|
-
type BaseTextBackground = 'gray' | 'white'
|
|
56
|
+
type BaseTextBackground = '' | 'gray' | 'white'
|
|
46
57
|
|
|
47
58
|
type BaseTextText = string | { base: string, sm: string }
|
|
48
59
|
}
|
package/nuxt.config.ts
CHANGED
|
@@ -11,15 +11,6 @@ export default defineNuxtConfig({
|
|
|
11
11
|
|
|
12
12
|
experimental: { typedPages: true },
|
|
13
13
|
|
|
14
|
-
typescript: {
|
|
15
|
-
tsConfig: {
|
|
16
|
-
compilerOptions: {
|
|
17
|
-
noUncheckedIndexedAccess: false,
|
|
18
|
-
types: ['@saasmakers/ui'],
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
|
|
23
14
|
// --> COMPONENTS, CSS, MODULES & PLUGINS <--
|
|
24
15
|
|
|
25
16
|
components: [
|
|
@@ -59,6 +50,7 @@ export default defineNuxtConfig({
|
|
|
59
50
|
|
|
60
51
|
i18n: {
|
|
61
52
|
defaultLocale: 'en',
|
|
53
|
+
locales: ['en', 'fr'],
|
|
62
54
|
strategy: 'prefix_except_default',
|
|
63
55
|
|
|
64
56
|
detectBrowserLanguage: {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@saasmakers/ui",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.20",
|
|
5
5
|
"private": false,
|
|
6
6
|
"description": "Reusable Nuxt UI components for SaaS Makers projects",
|
|
7
7
|
"license": "MIT",
|
|
@@ -11,19 +11,18 @@
|
|
|
11
11
|
"directory": "packages/ui"
|
|
12
12
|
},
|
|
13
13
|
"main": "nuxt.config.ts",
|
|
14
|
-
"types": "types/index.d.ts",
|
|
14
|
+
"types": "app/types/index.d.ts",
|
|
15
15
|
"publishConfig": {
|
|
16
16
|
"access": "public"
|
|
17
17
|
},
|
|
18
18
|
"files": [
|
|
19
19
|
"app",
|
|
20
|
-
"nuxt.config.ts"
|
|
21
|
-
"types"
|
|
20
|
+
"nuxt.config.ts"
|
|
22
21
|
],
|
|
23
22
|
"scripts": {
|
|
24
|
-
"dev": "nuxi dev
|
|
25
|
-
"dev:prepare": "nuxi prepare .playground",
|
|
23
|
+
"dev": "nuxi dev",
|
|
26
24
|
"lint": "eslint .",
|
|
25
|
+
"prepare": "nuxi prepare",
|
|
27
26
|
"typecheck": "nuxi typecheck"
|
|
28
27
|
},
|
|
29
28
|
"peerDependencies": {
|
|
File without changes
|