22 </script >
33
44<script setup lang="ts">
5- import { computed } from ' vue'
5+ import { computed , toRefs } from ' vue'
66
77export type CardColor = ' green' | ' blue' | ' red' | ' gold' | ' orange'
8+ export type CardLayout = ' column' | ' row'
89export interface NqCardProps {
910 icon? : string
1011 iconClass? : string
@@ -13,11 +14,37 @@ export interface NqCardProps {
1314 title? : string
1415 description? : string
1516 label? : string
17+ layout? : CardLayout
1618}
1719
18- const { bgColor, icon, href, iconClass } = defineProps <NqCardProps >()
20+ const props = withDefaults (defineProps <NqCardProps >(), {
21+ layout: ' column' ,
22+ })
1923
20- const hasLink = computed (() => !! href )
24+ const { bgColor, icon, href, iconClass, layout } = toRefs (props )
25+
26+ const hasLink = computed (() => !! href .value )
27+
28+ const iconClasses = computed (() => {
29+ if (! icon .value )
30+ return []
31+
32+ const classes = [icon .value ]
33+
34+ if (iconClass .value ) {
35+ classes .push (iconClass .value )
36+ }
37+
38+ if (! iconClass .value ) {
39+ classes .push (' f-size-120/160' )
40+ classes .push (layout .value === ' row' ? ' shrink-0' : ' absolute right--12' )
41+ }
42+ else if (layout .value === ' row' ) {
43+ classes .push (' shrink-0' )
44+ }
45+
46+ return classes
47+ })
2148
2249const colors: Partial <Record <CardColor , string >> = { blue: ' #0E65C9' , green: ' #1DA186' , gold: ' #ffffffaa' }
2350 </script >
@@ -32,13 +59,26 @@ const colors: Partial<Record<CardColor, string>> = { blue: '#0E65C9', green: '#1
3259 :target =" hasLink && href?.startsWith('http') ? '_blank' : undefined"
3360 :class =" [
3461 hasLink ? 'nq-hoverable' : 'nq-card',
62+ layout === 'row' ? 'flex items-start gap-16' : '',
3563 { 'children:max-w-[max(50%,240px)]': bgColor },
3664 ]"
3765 p-16
3866 >
39- <div v-if =" icon" :class =" [`${icon} ${iconClass}`, iconClass ? iconClass : 'f-size-120/160 absolute right--12']" :style =" `color: ${colors[bgColor!]}`" />
40- <span v-if =" label" nq-label text-12 mb-4 text =" neutral-700 data-inverted:white/50" data-inverted:mb-8 >{{ label }}</span >
41- <h2 v-if =" title" font-semibold f-text =" xl data-inverted:2xl" data-inverted:text-white v-html =" title" />
42- <p v-if =" description" text =" data-inverted:white/60" data-inverted:f-text-lg data-inverted:mt-4 v-html =" description" />
67+ <template v-if =" layout === ' row' " >
68+ <div v-if =" icon" class =" flex-shrink-0" >
69+ <div :class =" iconClasses" :style =" `color: ${colors[bgColor!]}`" />
70+ </div >
71+ <div class =" flex-1 flex flex-col" >
72+ <span v-if =" label" nq-label text-12 mb-4 text =" neutral-700 data-inverted:white/50" data-inverted:mb-8 >{{ label }}</span >
73+ <h2 v-if =" title" font-semibold f-text =" xl data-inverted:2xl" data-inverted:text-white v-html =" title" />
74+ <p v-if =" description" text =" data-inverted:white/60" data-inverted:f-text-lg data-inverted:mt-4 v-html =" description" />
75+ </div >
76+ </template >
77+ <template v-else >
78+ <div v-if =" icon" :class =" iconClasses" :style =" `color: ${colors[bgColor!]}`" />
79+ <span v-if =" label" nq-label text-12 mb-4 text =" neutral-700 data-inverted:white/50" data-inverted:mb-8 >{{ label }}</span >
80+ <h2 v-if =" title" font-semibold f-text =" xl data-inverted:2xl" data-inverted:text-white v-html =" title" />
81+ <p v-if =" description" text =" data-inverted:white/60" data-inverted:f-text-lg data-inverted:mt-4 v-html =" description" />
82+ </template >
4383 </component >
4484</template >
0 commit comments