Skip to content

Commit df6abb6

Browse files
committed
fix(NcNoteCard): Adjust padding and margin
Adjust the padding and margin to be a bit more condensed. Also fixed the documentation as the text was incomplete. Signed-off-by: Ferdinand Thiessen <[email protected]>
1 parent 9fe7295 commit df6abb6

File tree

1 file changed

+38
-17
lines changed

1 file changed

+38
-17
lines changed

src/components/NcNoteCard/NcNoteCard.vue

Lines changed: 38 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@
77
This component is made to display additional information to the user. It is
88
available in four versions:
99

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.
1618

1719
### Usage
1820

@@ -64,12 +66,13 @@ When using an error type,
6466
<component :is="icon"
6567
class="notecard__icon"
6668
:class="{'notecard__icon--heading': heading}"
67-
:fill-color="color" />
69+
:fill-color="color"
70+
:size="20" />
6871
</slot>
6972
<div>
70-
<h2 v-if="heading">
73+
<p v-if="heading" class="notecard__heading">
7174
{{ heading }}
72-
</h2>
75+
</p>
7376
<!-- @slot The main content (overwrites the `text` prop) -->
7477
<slot>
7578
<p class="notecard__text">
@@ -91,17 +94,26 @@ export default {
9194

9295
props: {
9396
/**
94-
* Type of the attribute
97+
* Type or severity of the message
9598
*/
9699
type: {
97100
type: String,
98101
default: 'warning',
99102
validator: type => ['success', 'info', 'warning', 'error'].includes(type),
100103
},
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+
*/
101110
showAlert: {
102111
type: Boolean,
103112
default: false,
104113
},
114+
/**
115+
* Optional text to show as a heading of the note card
116+
*/
105117
heading: {
106118
type: String,
107119
default: '',
@@ -152,20 +164,29 @@ export default {
152164

153165
<style lang="scss" scoped>
154166
.notecard {
167+
--note-card-icon-size: 20px;
168+
--note-card-padding: calc(2 * var(--default-grid-baseline));
155169
color: var(--color-main-text) !important;
156170
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);
158172
border-radius: var(--border-radius);
159173
margin: 1rem 0;
160-
margin-top: 1rem;
161-
padding: 1rem;
174+
padding: var(--note-card-padding);
162175
display: flex;
163176
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+
}
165183

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+
}
169190
}
170191

171192
&--success {

0 commit comments

Comments
 (0)