Skip to content

Commit cba9f75

Browse files
authored
Merge pull request #5894 from nextcloud-libraries/feat/nc-note-card-prop
feat(NcNoteCard): Add `text` prop to pass the content of the note card
2 parents 8092e7a + eb35514 commit cba9f75

File tree

1 file changed

+28
-15
lines changed

1 file changed

+28
-15
lines changed

src/components/NcNoteCard/NcNoteCard.vue

+28-15
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,31 @@ available in four versions:
1414

1515
When using an error type,
1616

17+
### Usage
18+
1719
```vue
1820
<template>
1921
<div>
20-
<NcNoteCard type="warning">
21-
<p>This is dangerous</p>
22-
</NcNoteCard>
22+
<NcNoteCard type="warning" text="This is dangerous" />
2323

24-
<NcNoteCard type="error" heading="Error">
25-
<p>The server is not happy and reported the following error</p>
26-
</NcNoteCard>
24+
<NcNoteCard type="error"
25+
heading="Error"
26+
text="The server is not happy and reported the following error" />
2727

28-
<NcNoteCard type="success">
29-
<p>You won</p>
30-
</NcNoteCard>
28+
<NcNoteCard type="success" text="You won" />
3129

32-
<NcNoteCard type="info">
33-
<p>For your information</p>
34-
</NcNoteCard>
30+
<NcNoteCard type="info" text="For your information" />
3531

36-
<NcNoteCard type="warning">
32+
<h4>Custom icon</h4>
33+
<NcNoteCard type="warning" text="Custom icon usage">
3734
<template #icon>
3835
<Cog :size="20"/>
3936
</template>
40-
<p>Custom icon usage</p>
37+
</NcNoteCard>
38+
39+
<h4>Custom content using the default slot</h4>
40+
<NcNoteCard type="info">
41+
Press <kbd>CTRL</kbd>+<kbd>C</kbd>
4142
</NcNoteCard>
4243
</div>
4344
</template>
@@ -69,7 +70,12 @@ When using an error type,
6970
<h2 v-if="heading">
7071
{{ heading }}
7172
</h2>
72-
<slot />
73+
<!-- @slot The main content (overwrites the `text` prop) -->
74+
<slot>
75+
<p class="notecard__text">
76+
{{ text }}
77+
</p>
78+
</slot>
7379
</div>
7480
</div>
7581
</template>
@@ -100,6 +106,13 @@ export default {
100106
type: String,
101107
default: '',
102108
},
109+
/**
110+
* The message text of the note card
111+
*/
112+
text: {
113+
type: String,
114+
default: '',
115+
},
103116
},
104117
computed: {
105118
shouldShowAlert() {

0 commit comments

Comments
 (0)