@bobbykim/mcl-cards 0.2.0
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/CHANGELOG.md +17 -0
- package/LICENSE.md +9 -0
- package/README.md +21 -0
- package/index.d.ts +6 -0
- package/index.js +6 -0
- package/index.ts +7 -0
- package/lib/common/index.types.d.ts +7 -0
- package/lib/common/index.types.js +1 -0
- package/lib/common/index.types.ts +8 -0
- package/lib/mcl-card-a/MclCardA.vue +260 -0
- package/lib/mcl-card-a/MclCardA.vue.d.ts +149 -0
- package/lib/mcl-card-b/MclCardB.vue +145 -0
- package/lib/mcl-card-b/MclCardB.vue.d.ts +92 -0
- package/lib/mcl-card-c/MclCardC.vue +142 -0
- package/lib/mcl-card-c/MclCardC.vue.d.ts +82 -0
- package/lib/mcl-card-d/MclCardD.vue +264 -0
- package/lib/mcl-card-d/MclCardD.vue.d.ts +135 -0
- package/lib/mcl-card-d/index.types.d.ts +4 -0
- package/lib/mcl-card-d/index.types.js +1 -0
- package/lib/mcl-card-d/index.types.ts +5 -0
- package/package.json +27 -0
- package/tsconfig.json +9 -0
- package/tsconfig.vue.json +9 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
# 0.2.0 (2024-02-27)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **.storybook,mcl-cards:** add opengraph configuration, add mcl-cards components ([13a255c](https://github.com/bobbykim89/manguito-component-library/commit/13a255c26048ccc56ed837ebac0281ee23aaa03e))
|
|
12
|
+
* **manguito-theme,mcl-cards,mcl-header,mcl-footer,mcl-carousel:** add vueuse as one of dependencies, update code to make them ssr friendly ([119a327](https://github.com/bobbykim89/manguito-component-library/commit/119a327adf1ca9866e6ac063bce5acd4790db612))
|
|
13
|
+
* **mcl-card-d:** update gradient handling method ([4adcd5d](https://github.com/bobbykim89/manguito-component-library/commit/4adcd5d8522a761485ff09e3334ed3cd2bb50ac1))
|
|
14
|
+
* **mcl-card-d:** update prop name, add story file ([1c8e5a1](https://github.com/bobbykim89/manguito-component-library/commit/1c8e5a1fde09070e5366155b0d899cbc5d5348a4))
|
|
15
|
+
* **mcl-cards:** update prop name, add story files ([d3b4609](https://github.com/bobbykim89/manguito-component-library/commit/d3b460968bfd4cb8213e29b16da8f615477e4487))
|
|
16
|
+
* **stories/*:** ran package:build to build type declaration, move deprecated story files into deprecated folder ([ffc487d](https://github.com/bobbykim89/manguito-component-library/commit/ffc487dbcc093be7a3ccfeae98c5e10e8372a0e3))
|
|
17
|
+
* **stories:** add story for mcl-card-b ([7470f0d](https://github.com/bobbykim89/manguito-component-library/commit/7470f0ddee5b3ba3c9f5c37e52bd37f6a1a75202))
|
package/LICENSE.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Bobby Kim
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# @bobbykim/mcl-cards
|
|
2
|
+
|
|
3
|
+
Add description
|
|
4
|
+
|
|
5
|
+
## Demo
|
|
6
|
+
|
|
7
|
+
[MCL Histoire Page](https://manguito-component-library.vercel.app/story/{%story-link%})
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
`import MclCards from "@bobbykim/mcl-cards"`;
|
|
14
|
+
|
|
15
|
+
## Maintainer
|
|
16
|
+
|
|
17
|
+
- **Bobby Kim** - _Initial work_
|
|
18
|
+
|
|
19
|
+
## License
|
|
20
|
+
|
|
21
|
+
This project is licensed under the MIT License - see the [LICENSE.md](./LICENSE.md) file for details
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import MclCardA from './lib/mcl-card-a/MclCardA.vue';
|
|
2
|
+
import MclCardB from './lib/mcl-card-b/MclCardB.vue';
|
|
3
|
+
import MclCardC from './lib/mcl-card-c/MclCardC.vue';
|
|
4
|
+
import MclCardD from './lib/mcl-card-d/MclCardD.vue';
|
|
5
|
+
export * from './lib/common/index.types';
|
|
6
|
+
export { MclCardA, MclCardB, MclCardC, MclCardD };
|
package/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import MclCardA from './lib/mcl-card-a/MclCardA.vue';
|
|
2
|
+
import MclCardB from './lib/mcl-card-b/MclCardB.vue';
|
|
3
|
+
import MclCardC from './lib/mcl-card-c/MclCardC.vue';
|
|
4
|
+
import MclCardD from './lib/mcl-card-d/MclCardD.vue';
|
|
5
|
+
export * from './lib/common/index.types';
|
|
6
|
+
export { MclCardA, MclCardB, MclCardC, MclCardD };
|
package/index.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import MclCardA from './lib/mcl-card-a/MclCardA.vue'
|
|
2
|
+
import MclCardB from './lib/mcl-card-b/MclCardB.vue'
|
|
3
|
+
import MclCardC from './lib/mcl-card-c/MclCardC.vue'
|
|
4
|
+
import MclCardD from './lib/mcl-card-d/MclCardD.vue'
|
|
5
|
+
|
|
6
|
+
export * from './lib/common/index.types'
|
|
7
|
+
export { MclCardA, MclCardB, MclCardC, MclCardD }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type {
|
|
3
|
+
ColorPalette,
|
|
4
|
+
CrossOrigin,
|
|
5
|
+
CtaTarget,
|
|
6
|
+
HeadingSize,
|
|
7
|
+
} from '@bobbykim/manguito-theme'
|
|
8
|
+
import generateClass from '@bobbykim/manguito-theme'
|
|
9
|
+
import type { CardClickEvent } from '../common/index.types'
|
|
10
|
+
|
|
11
|
+
const props = withDefaults(
|
|
12
|
+
defineProps<{
|
|
13
|
+
title: string
|
|
14
|
+
titleSize?: HeadingSize
|
|
15
|
+
titleColor?: ColorPalette
|
|
16
|
+
borderColor?: ColorPalette
|
|
17
|
+
bgColor?: ColorPalette
|
|
18
|
+
displayImage?: boolean
|
|
19
|
+
imageSource?: string
|
|
20
|
+
imageAlt?: string
|
|
21
|
+
imageCors?: CrossOrigin
|
|
22
|
+
displayCta?: boolean
|
|
23
|
+
ctaAsLink?: boolean
|
|
24
|
+
ctaText?: string
|
|
25
|
+
ctaColor?: ColorPalette
|
|
26
|
+
ctaLink?: string
|
|
27
|
+
ctaTarget?: CtaTarget
|
|
28
|
+
displayLabel?: boolean
|
|
29
|
+
labelText?: string
|
|
30
|
+
labelTextColor?: ColorPalette
|
|
31
|
+
labelColor?: ColorPalette
|
|
32
|
+
enlargeOnHover?: boolean
|
|
33
|
+
displayHighlight?: boolean
|
|
34
|
+
highlightColor?: ColorPalette
|
|
35
|
+
rounded?: boolean
|
|
36
|
+
displayShadow?: boolean
|
|
37
|
+
}>(),
|
|
38
|
+
{
|
|
39
|
+
titleSize: 'md',
|
|
40
|
+
titleColor: 'dark-3',
|
|
41
|
+
borderColor: 'light-3',
|
|
42
|
+
bgColor: 'light-1',
|
|
43
|
+
displayImage: true,
|
|
44
|
+
imageCors: 'anonymous',
|
|
45
|
+
displayCta: true,
|
|
46
|
+
ctaAsLink: true,
|
|
47
|
+
ctaColor: 'primary',
|
|
48
|
+
ctaLink: '#',
|
|
49
|
+
ctaTarget: '_self',
|
|
50
|
+
ctaText: 'cta text',
|
|
51
|
+
displayLabel: true,
|
|
52
|
+
labelText: 'Lorem ipsum',
|
|
53
|
+
labelTextColor: 'light-1',
|
|
54
|
+
labelColor: 'dark-4',
|
|
55
|
+
displayHighlight: true,
|
|
56
|
+
highlightColor: 'primary',
|
|
57
|
+
enlargeOnHover: false,
|
|
58
|
+
rounded: true,
|
|
59
|
+
displayShadow: true,
|
|
60
|
+
}
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
const emit = defineEmits(['card-click', 'card-btn-click'])
|
|
64
|
+
|
|
65
|
+
const getBorderClass = (
|
|
66
|
+
border: ColorPalette,
|
|
67
|
+
bg: ColorPalette,
|
|
68
|
+
rounded: boolean,
|
|
69
|
+
enlarge: boolean,
|
|
70
|
+
shadow: boolean
|
|
71
|
+
): string => {
|
|
72
|
+
/**
|
|
73
|
+
* @border - borderColor
|
|
74
|
+
* @bg - bgColor
|
|
75
|
+
* @rounded - rounded
|
|
76
|
+
* @enlarge - enlargeOnHover
|
|
77
|
+
* @shadow - displayShadow
|
|
78
|
+
*/
|
|
79
|
+
|
|
80
|
+
const classArray = [
|
|
81
|
+
generateClass('BORDER', border),
|
|
82
|
+
generateClass('BGCOLOR', bg),
|
|
83
|
+
]
|
|
84
|
+
|
|
85
|
+
if (rounded) {
|
|
86
|
+
classArray.push('rounded-md')
|
|
87
|
+
} else {
|
|
88
|
+
classArray.push('rounded-sm')
|
|
89
|
+
}
|
|
90
|
+
if (enlarge) {
|
|
91
|
+
classArray.push('hover:scale-105 transition ease-in duration-300')
|
|
92
|
+
}
|
|
93
|
+
if (shadow) {
|
|
94
|
+
classArray.push('drop-shadow-md')
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return classArray.join(' ')
|
|
98
|
+
}
|
|
99
|
+
const getTitleClass = (
|
|
100
|
+
size: HeadingSize,
|
|
101
|
+
color: ColorPalette,
|
|
102
|
+
hl: boolean
|
|
103
|
+
): string => {
|
|
104
|
+
/**
|
|
105
|
+
* @size - titleSize
|
|
106
|
+
* @color - titleColor
|
|
107
|
+
* @hl - displayHighlight
|
|
108
|
+
*/
|
|
109
|
+
|
|
110
|
+
const classArray = [
|
|
111
|
+
generateClass('H3', size),
|
|
112
|
+
generateClass('TEXTCOLOR', color),
|
|
113
|
+
]
|
|
114
|
+
|
|
115
|
+
if (hl) {
|
|
116
|
+
classArray.push('mb-2xs')
|
|
117
|
+
} else {
|
|
118
|
+
classArray.push('mb-xs')
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return classArray.join(' ')
|
|
122
|
+
}
|
|
123
|
+
const getLabelClass = (tColor: ColorPalette, bColor: ColorPalette): string => {
|
|
124
|
+
/**
|
|
125
|
+
* @tColor - labelTextColor
|
|
126
|
+
* @bColor - labelColor
|
|
127
|
+
*/
|
|
128
|
+
const classArray = [
|
|
129
|
+
generateClass('TEXTCOLOR', tColor),
|
|
130
|
+
generateClass('BGCOLOR', bColor),
|
|
131
|
+
]
|
|
132
|
+
return classArray.join(' ')
|
|
133
|
+
}
|
|
134
|
+
const getCtaClass = (color: ColorPalette, round: boolean): string => {
|
|
135
|
+
/**
|
|
136
|
+
* @color - ctaColor
|
|
137
|
+
* @round - rounded
|
|
138
|
+
*/
|
|
139
|
+
const classArray: string[] = [generateClass('BTNCOLOR', color)]
|
|
140
|
+
|
|
141
|
+
const lightColor: string[] = ['light-1', 'light-2', 'light-3', 'light-4']
|
|
142
|
+
|
|
143
|
+
let textColor = lightColor.includes(color) ? 'text-black' : 'text-white'
|
|
144
|
+
|
|
145
|
+
classArray.push(textColor)
|
|
146
|
+
|
|
147
|
+
if (round) {
|
|
148
|
+
classArray.push('btn-round')
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return classArray.join(' ')
|
|
152
|
+
}
|
|
153
|
+
const handleButtonClick = (
|
|
154
|
+
e: Event,
|
|
155
|
+
title: string,
|
|
156
|
+
link: string,
|
|
157
|
+
target: CtaTarget = '_self',
|
|
158
|
+
btnLink: boolean
|
|
159
|
+
): void => {
|
|
160
|
+
/**
|
|
161
|
+
* @title - title
|
|
162
|
+
* @link - ctaLink
|
|
163
|
+
* @target - ctaTarget
|
|
164
|
+
* @btnLink - ctaAsLink
|
|
165
|
+
*/
|
|
166
|
+
const cardEvent: CardClickEvent = {
|
|
167
|
+
event: e,
|
|
168
|
+
title,
|
|
169
|
+
url: link,
|
|
170
|
+
target: target ? target : '_self',
|
|
171
|
+
}
|
|
172
|
+
!btnLink && e.preventDefault()
|
|
173
|
+
emit('card-btn-click', cardEvent)
|
|
174
|
+
}
|
|
175
|
+
const handleCardClick = (e: Event): void => {
|
|
176
|
+
const { title, ctaLink, ctaTarget } = props
|
|
177
|
+
const cardEvent: CardClickEvent = {
|
|
178
|
+
event: e,
|
|
179
|
+
title,
|
|
180
|
+
url: ctaLink,
|
|
181
|
+
target: ctaTarget ? ctaTarget : '_self',
|
|
182
|
+
}
|
|
183
|
+
emit('card-click', cardEvent)
|
|
184
|
+
}
|
|
185
|
+
</script>
|
|
186
|
+
|
|
187
|
+
<template>
|
|
188
|
+
<div
|
|
189
|
+
class="overflow-hidden border max-w-[450px] sm:max-w-[350px] w-full xs:w-auto flex-grow flex-shrink-0 cursor-pointer"
|
|
190
|
+
:class="
|
|
191
|
+
getBorderClass(
|
|
192
|
+
borderColor,
|
|
193
|
+
bgColor,
|
|
194
|
+
rounded,
|
|
195
|
+
enlargeOnHover,
|
|
196
|
+
displayShadow
|
|
197
|
+
)
|
|
198
|
+
"
|
|
199
|
+
@click="handleCardClick"
|
|
200
|
+
>
|
|
201
|
+
<div class="relative" v-if="displayImage">
|
|
202
|
+
<img
|
|
203
|
+
:src="imageSource"
|
|
204
|
+
:alt="imageAlt"
|
|
205
|
+
:crossorigin="imageCors"
|
|
206
|
+
class="object-cover object-top h-[220px] min-w-full"
|
|
207
|
+
/>
|
|
208
|
+
<span
|
|
209
|
+
v-if="displayLabel"
|
|
210
|
+
class="py-3xs px-2xs ml-xs inline-block font-bold text-xs absolute bottom-0 translate-y-[50%]"
|
|
211
|
+
:class="getLabelClass(labelTextColor, labelColor)"
|
|
212
|
+
v-html="labelText"
|
|
213
|
+
></span>
|
|
214
|
+
</div>
|
|
215
|
+
<div class="content-height flex flex-col justify-between">
|
|
216
|
+
<div class="min-h-[100px] p-0">
|
|
217
|
+
<div class="px-xs pt-sm">
|
|
218
|
+
<span
|
|
219
|
+
v-if="!displayImage && displayLabel"
|
|
220
|
+
class="py-3xs px-2xs mb-2xs inline-block font-bold text-xs"
|
|
221
|
+
:class="getLabelClass(labelTextColor, labelColor)"
|
|
222
|
+
v-html="labelText"
|
|
223
|
+
></span>
|
|
224
|
+
<h3
|
|
225
|
+
:class="getTitleClass(titleSize, titleColor, displayHighlight)"
|
|
226
|
+
v-html="title"
|
|
227
|
+
></h3>
|
|
228
|
+
<div
|
|
229
|
+
v-if="displayHighlight"
|
|
230
|
+
class="mb-xs h-3xs w-md"
|
|
231
|
+
:class="generateClass('BGCOLOR', highlightColor)"
|
|
232
|
+
></div>
|
|
233
|
+
<div class="mb-sm cursor-default" @click.stop>
|
|
234
|
+
<slot></slot>
|
|
235
|
+
</div>
|
|
236
|
+
</div>
|
|
237
|
+
</div>
|
|
238
|
+
<div class="pb-sm border-0 cursor-default" v-if="displayCta" @click.stop>
|
|
239
|
+
<div class="w-full px-xs">
|
|
240
|
+
<a
|
|
241
|
+
:href="ctaLink"
|
|
242
|
+
:target="ctaTarget"
|
|
243
|
+
class="btn btn-full"
|
|
244
|
+
:class="getCtaClass(ctaColor, rounded)"
|
|
245
|
+
@click="
|
|
246
|
+
handleButtonClick($event, title, ctaLink, ctaTarget, ctaAsLink)
|
|
247
|
+
"
|
|
248
|
+
>{{ ctaText }}</a
|
|
249
|
+
>
|
|
250
|
+
</div>
|
|
251
|
+
</div>
|
|
252
|
+
</div>
|
|
253
|
+
</div>
|
|
254
|
+
</template>
|
|
255
|
+
|
|
256
|
+
<style lang="scss" scoped>
|
|
257
|
+
.content-height {
|
|
258
|
+
height: calc(100% - 200px);
|
|
259
|
+
}
|
|
260
|
+
</style>
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import type { ColorPalette, CrossOrigin, CtaTarget, HeadingSize } from '@bobbykim/manguito-theme';
|
|
2
|
+
declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
3
|
+
title: string;
|
|
4
|
+
titleSize?: HeadingSize | undefined;
|
|
5
|
+
titleColor?: ColorPalette | undefined;
|
|
6
|
+
borderColor?: ColorPalette | undefined;
|
|
7
|
+
bgColor?: ColorPalette | undefined;
|
|
8
|
+
displayImage?: boolean | undefined;
|
|
9
|
+
imageSource?: string | undefined;
|
|
10
|
+
imageAlt?: string | undefined;
|
|
11
|
+
imageCors?: CrossOrigin | undefined;
|
|
12
|
+
displayCta?: boolean | undefined;
|
|
13
|
+
ctaAsLink?: boolean | undefined;
|
|
14
|
+
ctaText?: string | undefined;
|
|
15
|
+
ctaColor?: ColorPalette | undefined;
|
|
16
|
+
ctaLink?: string | undefined;
|
|
17
|
+
ctaTarget?: CtaTarget | undefined;
|
|
18
|
+
displayLabel?: boolean | undefined;
|
|
19
|
+
labelText?: string | undefined;
|
|
20
|
+
labelTextColor?: ColorPalette | undefined;
|
|
21
|
+
labelColor?: ColorPalette | undefined;
|
|
22
|
+
enlargeOnHover?: boolean | undefined;
|
|
23
|
+
displayHighlight?: boolean | undefined;
|
|
24
|
+
highlightColor?: ColorPalette | undefined;
|
|
25
|
+
rounded?: boolean | undefined;
|
|
26
|
+
displayShadow?: boolean | undefined;
|
|
27
|
+
}>, {
|
|
28
|
+
titleSize: string;
|
|
29
|
+
titleColor: string;
|
|
30
|
+
borderColor: string;
|
|
31
|
+
bgColor: string;
|
|
32
|
+
displayImage: boolean;
|
|
33
|
+
imageCors: string;
|
|
34
|
+
displayCta: boolean;
|
|
35
|
+
ctaAsLink: boolean;
|
|
36
|
+
ctaColor: string;
|
|
37
|
+
ctaLink: string;
|
|
38
|
+
ctaTarget: string;
|
|
39
|
+
ctaText: string;
|
|
40
|
+
displayLabel: boolean;
|
|
41
|
+
labelText: string;
|
|
42
|
+
labelTextColor: string;
|
|
43
|
+
labelColor: string;
|
|
44
|
+
displayHighlight: boolean;
|
|
45
|
+
highlightColor: string;
|
|
46
|
+
enlargeOnHover: boolean;
|
|
47
|
+
rounded: boolean;
|
|
48
|
+
displayShadow: boolean;
|
|
49
|
+
}>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
50
|
+
"card-click": (...args: any[]) => void;
|
|
51
|
+
"card-btn-click": (...args: any[]) => void;
|
|
52
|
+
}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
53
|
+
title: string;
|
|
54
|
+
titleSize?: HeadingSize | undefined;
|
|
55
|
+
titleColor?: ColorPalette | undefined;
|
|
56
|
+
borderColor?: ColorPalette | undefined;
|
|
57
|
+
bgColor?: ColorPalette | undefined;
|
|
58
|
+
displayImage?: boolean | undefined;
|
|
59
|
+
imageSource?: string | undefined;
|
|
60
|
+
imageAlt?: string | undefined;
|
|
61
|
+
imageCors?: CrossOrigin | undefined;
|
|
62
|
+
displayCta?: boolean | undefined;
|
|
63
|
+
ctaAsLink?: boolean | undefined;
|
|
64
|
+
ctaText?: string | undefined;
|
|
65
|
+
ctaColor?: ColorPalette | undefined;
|
|
66
|
+
ctaLink?: string | undefined;
|
|
67
|
+
ctaTarget?: CtaTarget | undefined;
|
|
68
|
+
displayLabel?: boolean | undefined;
|
|
69
|
+
labelText?: string | undefined;
|
|
70
|
+
labelTextColor?: ColorPalette | undefined;
|
|
71
|
+
labelColor?: ColorPalette | undefined;
|
|
72
|
+
enlargeOnHover?: boolean | undefined;
|
|
73
|
+
displayHighlight?: boolean | undefined;
|
|
74
|
+
highlightColor?: ColorPalette | undefined;
|
|
75
|
+
rounded?: boolean | undefined;
|
|
76
|
+
displayShadow?: boolean | undefined;
|
|
77
|
+
}>, {
|
|
78
|
+
titleSize: string;
|
|
79
|
+
titleColor: string;
|
|
80
|
+
borderColor: string;
|
|
81
|
+
bgColor: string;
|
|
82
|
+
displayImage: boolean;
|
|
83
|
+
imageCors: string;
|
|
84
|
+
displayCta: boolean;
|
|
85
|
+
ctaAsLink: boolean;
|
|
86
|
+
ctaColor: string;
|
|
87
|
+
ctaLink: string;
|
|
88
|
+
ctaTarget: string;
|
|
89
|
+
ctaText: string;
|
|
90
|
+
displayLabel: boolean;
|
|
91
|
+
labelText: string;
|
|
92
|
+
labelTextColor: string;
|
|
93
|
+
labelColor: string;
|
|
94
|
+
displayHighlight: boolean;
|
|
95
|
+
highlightColor: string;
|
|
96
|
+
enlargeOnHover: boolean;
|
|
97
|
+
rounded: boolean;
|
|
98
|
+
displayShadow: boolean;
|
|
99
|
+
}>>> & {
|
|
100
|
+
"onCard-click"?: ((...args: any[]) => any) | undefined;
|
|
101
|
+
"onCard-btn-click"?: ((...args: any[]) => any) | undefined;
|
|
102
|
+
}, {
|
|
103
|
+
titleColor: ColorPalette;
|
|
104
|
+
titleSize: HeadingSize;
|
|
105
|
+
borderColor: ColorPalette;
|
|
106
|
+
bgColor: ColorPalette;
|
|
107
|
+
displayImage: boolean;
|
|
108
|
+
imageCors: CrossOrigin;
|
|
109
|
+
displayCta: boolean;
|
|
110
|
+
ctaAsLink: boolean;
|
|
111
|
+
ctaText: string;
|
|
112
|
+
ctaColor: ColorPalette;
|
|
113
|
+
ctaLink: string;
|
|
114
|
+
ctaTarget: CtaTarget;
|
|
115
|
+
displayLabel: boolean;
|
|
116
|
+
labelText: string;
|
|
117
|
+
labelTextColor: ColorPalette;
|
|
118
|
+
labelColor: ColorPalette;
|
|
119
|
+
enlargeOnHover: boolean;
|
|
120
|
+
displayHighlight: boolean;
|
|
121
|
+
highlightColor: ColorPalette;
|
|
122
|
+
rounded: boolean;
|
|
123
|
+
displayShadow: boolean;
|
|
124
|
+
}, {}>, {
|
|
125
|
+
default?(_: {}): any;
|
|
126
|
+
}>;
|
|
127
|
+
export default _default;
|
|
128
|
+
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
129
|
+
type __VLS_TypePropsToRuntimeProps<T> = {
|
|
130
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
131
|
+
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
132
|
+
} : {
|
|
133
|
+
type: import('vue').PropType<T[K]>;
|
|
134
|
+
required: true;
|
|
135
|
+
};
|
|
136
|
+
};
|
|
137
|
+
type __VLS_WithDefaults<P, D> = {
|
|
138
|
+
[K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
|
|
139
|
+
default: D[K];
|
|
140
|
+
}> : P[K];
|
|
141
|
+
};
|
|
142
|
+
type __VLS_Prettify<T> = {
|
|
143
|
+
[K in keyof T]: T[K];
|
|
144
|
+
} & {};
|
|
145
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
146
|
+
new (): {
|
|
147
|
+
$slots: S;
|
|
148
|
+
};
|
|
149
|
+
};
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type {
|
|
3
|
+
ColorPalette,
|
|
4
|
+
CrossOrigin,
|
|
5
|
+
CtaTarget,
|
|
6
|
+
HeadingSize,
|
|
7
|
+
} from '@bobbykim/manguito-theme'
|
|
8
|
+
import generateClass from '@bobbykim/manguito-theme'
|
|
9
|
+
import type { CardClickEvent } from '../common/index.types'
|
|
10
|
+
|
|
11
|
+
withDefaults(
|
|
12
|
+
defineProps<{
|
|
13
|
+
title: string
|
|
14
|
+
titleSize?: HeadingSize
|
|
15
|
+
titleColor?: ColorPalette
|
|
16
|
+
titleBlockColor?: ColorPalette
|
|
17
|
+
borderColor?: ColorPalette
|
|
18
|
+
imageSource?: string
|
|
19
|
+
imageAlt?: string
|
|
20
|
+
imageCors?: CrossOrigin
|
|
21
|
+
displayGrayScale?: boolean
|
|
22
|
+
ctaAsLink?: boolean
|
|
23
|
+
ctaLink?: string
|
|
24
|
+
ctaTarget?: CtaTarget
|
|
25
|
+
rounded?: boolean
|
|
26
|
+
}>(),
|
|
27
|
+
{
|
|
28
|
+
titleSize: 'md',
|
|
29
|
+
titleColor: 'light-1',
|
|
30
|
+
titleBlockColor: 'dark-4',
|
|
31
|
+
borderColor: 'light-3',
|
|
32
|
+
displayGrayScale: true,
|
|
33
|
+
imageCors: 'anonymous',
|
|
34
|
+
ctaAsLink: false,
|
|
35
|
+
ctaLink: '#',
|
|
36
|
+
ctaTarget: '_self',
|
|
37
|
+
rounded: false,
|
|
38
|
+
}
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
const emit = defineEmits(['card-click'])
|
|
42
|
+
|
|
43
|
+
const getBorderClass = (bColor: ColorPalette, rounded: boolean): string => {
|
|
44
|
+
/**
|
|
45
|
+
* @bColor - borderColor
|
|
46
|
+
* @rounded - rounded
|
|
47
|
+
*/
|
|
48
|
+
const classArray = [generateClass('BORDER', bColor)]
|
|
49
|
+
if (rounded) {
|
|
50
|
+
classArray.push('rounded-md')
|
|
51
|
+
} else {
|
|
52
|
+
classArray.push('rounded-sm')
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return classArray.join(' ')
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const handleHoverEffect = (dGray: boolean): string => {
|
|
59
|
+
/**
|
|
60
|
+
* @dgray - displayGrayScale
|
|
61
|
+
*/
|
|
62
|
+
if (dGray) {
|
|
63
|
+
return '[@media(hover:hover)]:grayscale peer-hover:grayscale-0'
|
|
64
|
+
}
|
|
65
|
+
return ''
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const handleTitleClass = (
|
|
69
|
+
tSize: HeadingSize,
|
|
70
|
+
tColor: ColorPalette,
|
|
71
|
+
tBgColor: ColorPalette
|
|
72
|
+
): string => {
|
|
73
|
+
/**
|
|
74
|
+
* @tSize - titleSize
|
|
75
|
+
* @tColor - titleColor
|
|
76
|
+
* @tBgColor - titleBlockColor
|
|
77
|
+
*/
|
|
78
|
+
|
|
79
|
+
const classArray = [
|
|
80
|
+
generateClass('H3', tSize),
|
|
81
|
+
generateClass('TEXTCOLOR', tColor),
|
|
82
|
+
generateClass('BGCOLOR', tBgColor),
|
|
83
|
+
]
|
|
84
|
+
|
|
85
|
+
return classArray.join(' ')
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const handleCardClick = (
|
|
89
|
+
e: Event,
|
|
90
|
+
title: string,
|
|
91
|
+
link: string,
|
|
92
|
+
target: CtaTarget = '_self',
|
|
93
|
+
ctaLink: boolean
|
|
94
|
+
): void => {
|
|
95
|
+
/**
|
|
96
|
+
* @e - Event
|
|
97
|
+
* @title - title
|
|
98
|
+
* @link - ctaLink
|
|
99
|
+
* @target - ctaTarget
|
|
100
|
+
* @ctaLink - ctaAsLink
|
|
101
|
+
*/
|
|
102
|
+
!ctaLink && e.preventDefault()
|
|
103
|
+
const cardEvent: CardClickEvent = {
|
|
104
|
+
event: e,
|
|
105
|
+
title,
|
|
106
|
+
url: link,
|
|
107
|
+
target: target ? target : '_self',
|
|
108
|
+
}
|
|
109
|
+
console.log(cardEvent)
|
|
110
|
+
emit('card-click', cardEvent)
|
|
111
|
+
}
|
|
112
|
+
</script>
|
|
113
|
+
|
|
114
|
+
<template>
|
|
115
|
+
<div
|
|
116
|
+
class="relative max-w-[450px] sm:max-w-[350px] w-full xs:w-auto flex-grow flex-shrink-0 cursor-pointer overflow-hidden border border-light-3"
|
|
117
|
+
:class="getBorderClass(borderColor, rounded)"
|
|
118
|
+
>
|
|
119
|
+
<a
|
|
120
|
+
:href="ctaLink"
|
|
121
|
+
:target="ctaTarget"
|
|
122
|
+
@click="handleCardClick($event, title, ctaLink, ctaTarget, ctaAsLink)"
|
|
123
|
+
>
|
|
124
|
+
<div
|
|
125
|
+
class="absolute z-[15] flex flex-col justify-end items-start inset-0 p-xs [@media(hover:hover)]:opacity-0 hover:opacity-100 peer transition-opacity duration-200"
|
|
126
|
+
>
|
|
127
|
+
<h3
|
|
128
|
+
v-html="title"
|
|
129
|
+
class="inline-block px-xs py-2xs mb-2xs pointer-events-none tracking-wide"
|
|
130
|
+
:class="handleTitleClass(titleSize, titleColor, titleBlockColor)"
|
|
131
|
+
></h3>
|
|
132
|
+
<slot></slot>
|
|
133
|
+
</div>
|
|
134
|
+
<img
|
|
135
|
+
:src="imageSource"
|
|
136
|
+
:alt="imageAlt"
|
|
137
|
+
:crossorigin="imageCors"
|
|
138
|
+
class="relative z-10 object-cover aspect-[3/4] transition-all duration-200"
|
|
139
|
+
:class="handleHoverEffect(displayGrayScale)"
|
|
140
|
+
/>
|
|
141
|
+
</a>
|
|
142
|
+
</div>
|
|
143
|
+
</template>
|
|
144
|
+
|
|
145
|
+
<style lang="scss" scoped></style>
|