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

✨ attempt to introduce html in notifications #359

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
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
18 changes: 18 additions & 0 deletions docs/content/6.overlays/6.notification.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,24 @@ excludedProps:
---
::

You can pass HTML into the `title` and `description` props.

::component-card
---
baseProps:
id: 6
title: 'Notification <i>italic</i>'
description: 'This is an <u>underlined</u> and <b>bold</b> notification.'
timeout: 600000
props:
icon: 'i-heroicons-check-badge'
extraColors:
- gray
excludedProps:
- icon
---
::

### Click

Use the `click` prop to execute a function when the Notification is clicked.
Expand Down
8 changes: 2 additions & 6 deletions src/runtime/components/overlays/Notification.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,8 @@
<UAvatar v-if="avatar" v-bind="{ size: ui.avatar.size, ...avatar }" :class="ui.avatar.base" />

<div class="w-0 flex-1">
<p :class="ui.title">
{{ title }}
</p>
<p v-if="description" :class="ui.description">
{{ description }}
</p>
<p :class="ui.title" v-html="title" />
<p v-if="description" :class="ui.description" v-html="description" />
Comment on lines +11 to +12
Copy link
Contributor

@Haythamasalama Haythamasalama Jun 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@acidjazz that's what I mean

<slot>
  <p :class="ui.title">
    {{ title }}
  </p>

  <p v-if="description" :class="ui.description">
    {{ description }}
  </p>
</slot>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Haythamasalama I see, thanks for the example, how would this work programmatically?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<UNotification>
  <p>
   // your title 
  </p>
  <p>
   // your description  
  </p>
</UNotification>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no I mean using the composable useToast().add here


<div v-if="description && actions.length" class="mt-3 flex items-center gap-2">
<UButton v-for="(action, index) of actions" :key="index" v-bind="{ ...ui.default.actionButton, ...action }" @click.stop="onAction(action)" />
Expand Down