7
7
This component is made to display additional information to the user. It is
8
8
available in four versions:
9
9
10
- - success: Display a successful message
11
- - info: Display an informational message
12
- - warning: Display a warning to the user. This indicate that the action they want
13
- - error: Display an error message. For example
14
-
15
- When using an error type,
10
+ - **success**: Display a successful message.<br>
11
+ Should be used to show success of an operation or optional information to help a user be more successful.
12
+ - **info**: Display an informational message.<br>
13
+ Should be used to highlight information that users should take into account.
14
+ - **warning**: Display a warning to the user.<br>
15
+ Should be used for critical content demanding user attention due to potential risks.
16
+ - **error**: Display an error message.<br>
17
+ Should be used for negative potential consequences of an action.
16
18
17
19
### Usage
18
20
@@ -64,12 +66,13 @@ When using an error type,
64
66
<component :is="icon"
65
67
class="notecard__icon"
66
68
:class="{'notecard__icon--heading': heading}"
67
- :fill-color="color" />
69
+ :fill-color="color"
70
+ :size="20" />
68
71
</slot>
69
72
<div>
70
- <h2 v-if="heading">
73
+ <p v-if="heading" class="notecard__heading ">
71
74
{{ heading }}
72
- </h2 >
75
+ </p >
73
76
<!-- @slot The main content (overwrites the `text` prop) -->
74
77
<slot>
75
78
<p class="notecard__text">
@@ -91,17 +94,26 @@ export default {
91
94
92
95
props: {
93
96
/**
94
- * Type of the attribute
97
+ * Type or severity of the message
95
98
*/
96
99
type: {
97
100
type: String,
98
101
default: 'warning',
99
102
validator: type => ['success', 'info', 'warning', 'error'].includes(type),
100
103
},
104
+ /**
105
+ * Enforce the `alert` role on the note card.
106
+ *
107
+ * The [`alert` role](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/alert_role)
108
+ * should only be used for information that requires the user's immediate attention.
109
+ */
101
110
showAlert: {
102
111
type: Boolean,
103
112
default: false,
104
113
},
114
+ /**
115
+ * Optional text to show as a heading of the note card
116
+ */
105
117
heading: {
106
118
type: String,
107
119
default: '',
@@ -152,20 +164,29 @@ export default {
152
164
153
165
<style lang="scss" scoped>
154
166
.notecard {
167
+ --note-card-icon-size: 20px;
168
+ --note-card-padding: calc(2 * var(--default-grid-baseline));
155
169
color: var(--color-main-text) !important;
156
170
background-color: var(--note-background) !important;
157
- border-inline-start: 4px solid var(--note-theme);
171
+ border-inline-start: var(--default-grid-baseline) solid var(--note-theme);
158
172
border-radius: var(--border-radius);
159
173
margin: 1rem 0;
160
- margin-top: 1rem;
161
- padding: 1rem;
174
+ padding: var(--note-card-padding);
162
175
display: flex;
163
176
flex-direction: row;
164
- gap: 1rem;
177
+ gap: var(--note-card-padding);
178
+
179
+ &__heading {
180
+ font-size: var(--note-card-icon-size); // Same as icon
181
+ font-weight: 600;
182
+ }
165
183
166
- &__icon--heading {
167
- margin-bottom: auto;
168
- margin-top: 0.3rem;
184
+ &__icon {
185
+ &--heading {
186
+ font-size: var(--note-card-icon-size);
187
+ // Ensure icon is on the same height as the heading
188
+ margin-block: calc((1lh - 1em) / 2) auto;
189
+ }
169
190
}
170
191
171
192
&--success {
0 commit comments