-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathslds-tile.vue
138 lines (110 loc) · 3.2 KB
/
slds-tile.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<template>
<slds-media-object class="slds-tile">
<template #figure>
<!-- Avatar -->
<slds-avatar
v-if="avatar"
circle
medium
:src="avatar"
/>
<!-- Icon -->
<slds-icon
v-else-if="iconName"
:icon-name="iconName"
:icon-class="iconClass"
:large="iconLarge"
medium
:small="iconSmall"
:x-small="iconXSmall"
:xx-small="iconXXSmall"
/>
</template>
<template #default>
<!-- Header -->
<div class="slds-grid slds-grid_align-spread slds-has-flexi-truncate slds-hint-parent">
<!-- Title -->
<h3 class="slds-tile__title slds-truncate" :title="title">
<slot name="title">
<p v-if="linkless">
<b>{{ title }}</b>
</p>
<a v-else @click="handleClickTitle">
{{ title }}
</a>
</slot>
</h3>
<!-- Actions -->
<div v-if="$slots.actions" class="slds-shrink-none">
<slot name="actions"/>
</div>
</div>
<!-- Content -->
<div class="slds-tile__detail">
<slot/>
</div>
</template>
</slds-media-object>
</template>
<script lang="ts">
import SldsAvatar from "../slds-avatar/slds-avatar.vue"
import SldsIcon from "../slds-icon/slds-icon.vue"
import SldsMediaObject from "../slds-media-object/slds-media-object.vue"
import { EVENTS } from "../../constants"
import { defineComponent } from "vue"
export default defineComponent({
name: "SldsTile",
components: {
SldsMediaObject,
SldsAvatar,
SldsIcon,
},
props: {
/**
* The URL for the avatar
*/
avatar: String,
/**
* The class names to be passed to the icon.
*/
iconClass: String,
/**
* The Lightning Design System name of the icon. Names are written in the format
* 'utility:down' where 'utility' is the category, and 'down' is the specific icon to be displayed.value
*/
iconName: String,
/**
* Indicates whether to use a large icon.
*/
iconLarge: Boolean,
/**
* Indicates whether to use a small icon.
*/
iconSmall: Boolean,
/**
* Indicates whether to use an x-small icon.
*/
iconXSmall: Boolean,
/**
* Indicates whether to use a xx-small icon.
*/
iconXXSmall: Boolean,
/**
* Indicates whether title no has link.
*/
linkless: Boolean,
/**
* The title of the tile.
*/
title: String,
},
methods: {
/**
* Handles the click event on the title.
*/
handleClickTitle(): void {
this.$emit(EVENTS.CLICK)
},
},
})
</script>