Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(NcNoteCard): provide a slot for inserting a custom icon instead of default #4894

Merged
merged 1 commit into from
Jan 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 43 additions & 21 deletions src/components/NcNoteCard/NcNoteCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,34 +30,56 @@ available in four versions:
When using an error type,

```vue
<div>
<NcNoteCard type="warning">
<p>This is dangerous</p>
</NcNoteCard>

<NcNoteCard type="error" heading="Error">
<p>The server is not happy and reported the following error</p>
</NcNoteCard>

<NcNoteCard type="success">
<p>You won</p>
</NcNoteCard>

<NcNoteCard type="info">
<p>For your information</p>
</NcNoteCard>
</div>
<template>
<div>
<NcNoteCard type="warning">
<p>This is dangerous</p>
</NcNoteCard>

<NcNoteCard type="error" heading="Error">
<p>The server is not happy and reported the following error</p>
</NcNoteCard>

<NcNoteCard type="success">
<p>You won</p>
</NcNoteCard>

<NcNoteCard type="info">
<p>For your information</p>
</NcNoteCard>

<NcNoteCard type="warning">
<template #icon>
<Cog :size="20"/>
</template>
<p>Custom icon usage</p>
</NcNoteCard>
</div>
</template>

<script>
import Cog from 'vue-material-design-icons/Cog.vue'

export default {
components: {
Cog,
},
}
</script>
```
</docs>

<template>
<div class="notecard"
:class="`notecard--${type}`"
:role="shouldShowAlert ? 'alert' : 'note'">
<component :is="icon"
class="notecard__icon"
:class="{'notecard__icon--heading': heading}"
:fill-color="color" />
<!-- @slot Manually provide icon -->
<slot name="icon">
<component :is="icon"
class="notecard__icon"
:class="{'notecard__icon--heading': heading}"
:fill-color="color" />
</slot>
<div>
<h2 v-if="heading">
{{ heading }}
Expand Down
Loading