-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathslds-panel.vue
136 lines (103 loc) · 3.34 KB
/
slds-panel.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
<template>
<div aria-hidden="false" :class="panelClassNames">
<!-- Custom header -->
<div v-if="$slots.header" :class="headerClassNames">
<slot name="header"/>
</div>
<!-- Header -->
<div :class="headerClassNames">
<!-- Back button -->
<slds-button-icon
v-if="backButton"
class="slds-panel__back"
icon-name="utility:back"
small
title="Collapse Panel Header"
@click="handleClickBack"
/>
<!-- Title -->
<h2 class="slds-panel__header-title slds-text-heading_small slds-truncate" :title="title">
{{ title }}
</h2>
<!-- Close button -->
<slds-button-icon
v-if="closeButton"
:assistive-text="assistiveText"
class="slds-panel__close"
icon-name="utility:close"
small
title="Collapse Panel Header"
@click="handleClickClose"
/>
</div>
<!-- Body -->
<div class="slds-panel__body">
<slot/>
</div>
</div>
</template>
<script lang="ts">
import SldsButtonIcon from "../slds-button-icon/slds-button-icon.vue"
import { EVENTS } from "../../constants"
import { defineComponent } from "vue"
export default defineComponent({
name: "SldsPanel",
components: { SldsButtonIcon },
props: {
assistiveText: String,
backButton: Boolean,
centeredHeader: Boolean,
closeButton: { type: Boolean, default: true },
full: Boolean,
large: Boolean,
left: Boolean,
medium: Boolean,
right: Boolean,
small: Boolean,
title: String,
xLarge: Boolean,
},
computed: {
/**
* The CSS class names for the header.
*/
headerClassNames(): string {
let classNames = "slds-panel__header"
if (this.$slots.header) classNames += " slds-panel__header_custom"
if (this.centeredHeader) classNames += " slds-panel__header_align-center"
return classNames
},
/**
* The CSS class names for the panel.
*/
panelClassNames(): string {
let classNames = "slds-panel slds-panel_docked slds-is-open"
// Size
if (this.small) classNames += " slds-size_small"
else if (this.medium) classNames += " slds-size_medium"
else if (this.large) classNames += " slds-size_large"
else if (this.xLarge) classNames += " slds-size_x-large"
else if (this.full) classNames += " slds-size_full"
else classNames += " slds-size_medium"
// Position
if (this.right) classNames += " slds-panel_docked-right"
else if (this.left) classNames += " slds-panel_docked-left"
return classNames
},
},
methods: {
/**
* Handles the click event on the back button.
*/
handleClickBack(): void {
this.$emit(EVENTS.BACK)
},
/**
* Handles the click event on the close button.
*/
handleClickClose(): void {
this.$emit(EVENTS.CLOSE)
},
},
})
</script>