Astro Integration

status: working in progress

Getting started

The Feelback integration for Astro allows your user to send feedback on your content.


The integration library provides:

Prerequisite

Setup

You can install the library with your preferred package manager:

npm install astro-feelback

You can include the default style:

layout.astro

---
import "astro-feedback/styles/feelback.css";
---

<html>
    ...
</html>

Step by step guides

You can checkout full tutorials with a step-by-step coverage on how to integrate Feelback into your Astro website.

Project example

Checkout the sample project astro-docs for a concrete Feelback integration and several usage examples.

Target content

For each Feelback* component you need to set the target content, that is, the content that will receive the feelback. You can do either:

For more info about how to identify the target content, checkout guide how to set the target content.

Properties

propertytypedefaultdescription
contentSetIdstringrequiredspecify the content-set container of the content receiving the feelback
keystringcurrentURLspecify the content key (unique inside the set), if omitted, it will default to the current page URL

Value Definition

When using custom elements, here’s the definition for each one:

ValueDef properties

propertytypedefaultdescription
valuestringrequiredthe value to be used and sent
titlestringrequiredthe the display text shown to the user for the choice item
descriptionstringundefineddisplay a subtitle to the choice item, if empty, it will display nothing
iconstringundefinedcan be html or a string

Components

FeelbackPulse

Display an icon button allowing users to activate it. Used to receive a Pulse feelback on your content.


Optionally, you can show a counter, which tracks the total amount of pulses received for the current content.

Properties

propertytypedefaultdescription
targetTargetContentrequiredspecify the target content
presetPreset | ValueDef"heart"determine which icon to display, you can pass a preset (see the list below) or use a custom one
showCountbooleanfalseshow the total pulses for the content

Presets

The FeelbackPulse component supports the following presets:

presetdescription
heartdisplay a heart icon which fills when active
stardisplay a star icon which fills when active
likedisplay a like icon which fills when active

Example

BlogPostTitle.astro

---
import FeelbackPulse from "astro-feelback/components/FeelbackPulse.astro";

interface Props = {
    title: string
}

const { title } = Astro.props;
---

<div>
    <h1>{title}</h1>
    <FeelbackPulse contentSetId="content-set-id-from-panel"
        preset="heart"
        showCount
    />
</div>

FeelbackYesNo

Display an small control with an optional question text with to icon buttons, for Ys and Ns. Used to receive a YesNo feelback on your content.


Optionally, you can show a counter near each button with the total of Ys and Ns for the current content.

Properties

propertytypedefaultdescription
targetTargetContentrequiredspecify the target content
presetPreset | ValueDef[]"like-dislike"determine which icon to display, you can pass a preset (see the list below) or use a custom one
showCountbooleanfalseshow the total count of Ys and Ns
showTitlebooleantruedisplay the browser builtin tooltip on button hover
textQuestionstring"Is this page useful?"you can set this to empty or undefined to hide the text
textAnswerstring"Thanks for your feedback"shows this text after the user pressed one of the buttons

Presets

The FeelbackYesNo component supports the following presets:

presetdescription
like-dislikedisplay the pair thumb-up and thumb-down icons
checkdisplay the pair check (tick) and times (X) icons
arrowsdisplay the pair up-vote and down-vote icons

Example

BlogPostTitle.astro

---
import FeelbackYesNo from "astro-feelback/components/FeelbackYesNo.astro";

interface Props = {
    title: string
}

const { title } = Astro.props;
---

<div>
    <h1>{title}</h1>
    <FeelbackYesNo contentSetId="content-set-id-from-panel"
        preset="like-dislike"
        textQuestion="Do you like this page?"
        textAnswer="Thanks for your feedback"
    />
</div>

FeelbackReaction

Display a control which allows the user to pick an emoji reaction. You can receive a FeelbackReaction feelback on your content.


This component supports both a picker layout, where a Select Reaction button is displayed, or list layout, where all emoji are displayed directly.

Properties

propertytypedefaultdescription
targetTargetContentrequiredspecify the target content
presetPreset | ValueDef[]requireddetermine which icon to display, you can pass a preset (see the list below) or use a custom one
layout"picker" | "list""list"set the component layout:
"picker" πŸ‘’ display a Pick Reaction button, when pressed a little popup shows all reaction the user can pick
"list" πŸ‘’ display all emoji in a row
showCountbooleanfalseshow the count for each reaction near the relative icon
showTitlebooleantruedisplay the browser builtin tooltip on button hover
textQuestionstring"Is this page useful?"you can set this to empty or undefined to hide the text
textAnswerstring"Thanks for your feedback"shows this text after the user pressed one of the buttons

Presets

The FeelbackReaction component supports the following presets:

presetdescription
feelingdisplay three feeling emoji faces: happy, neutral, sad
githubdisplay the github builtin emoji
facebookdisplay the facebook builtin emoji

Example

BlogPostTitle.astro

---
import FeelbackReaction from "astro-feelback/components/FeelbackReaction.astro";

interface Props = {
    title: string
}

const { title } = Astro.props;
---

<div>
    <h1>{title}</h1>
    <FeelbackReaction contentSetId="content-set-id-from-panel"
        layout="picker"
        preset="github"
        showCount
    />
</div>

FeelbackTaggedMessage

Display an form with a button choice and an optional text message. You can receive a FeelbackTaggedMessage feelback on your content. The user can pick a button to activate the relative tag, and optionally can fill a textarea before sending the feedback.


This component supports different layouts:

Feelback tagged messageFeelback tagged message optionsFeelback send buttonFeelback reactions

Properties

propertytypedefaultdescription
targetTargetContentrequiredspecify the target content
presetPreset | ValueDef[]requireddetermine which icon to display, you can pass a preset (see the list below) or use a custom one
layout"inline" |
"reveal-message" |
"radio-group" |
"button-switch" |
"button-dialog"
"inline"set the component layout:
"inline" πŸ‘’ display the form directly
"reveal-message" πŸ‘’ display the tags as icon buttons, when pressed the message area appears
"button-switch" πŸ‘’ display a button, when pressed disappears and shows the form
"button-dialog" πŸ‘’ display a button, then pressed shows a blocking centered dialog
titlestring"Send feedback"The form form title
labelstring"Send feedback"The button label for button-based layouts
textAnswerstring"Thanks for your feedback"shows this text after the user pressed one of the buttons
placeholderstring"Type your message"the text message placeholder
showLabelsbooleanfalsetrue to the tag-button labels otherwise only the icon will be visible
preselectstring | numberundefinedtag to preselect, if specified as string the tag with that value is preselect, if number the tag at that position
withEmailboolean | "required"falseshow an email field, optional to fill. if "required", the field must be filled

Presets

The FeelbackTaggedMessage component supports the following presets:

presetdescription
like-dislikedisplay the pair thumb-up and thumb-down icons
feelingdisplay three feeling emoji faces: happy, neutral, sad
evaluationdisplay four feeling emoji faces: love, happy, sad, cry
feedbackdisplay three feedback-type icon: idea, error, other

Example

Rightbar.astro

---
import FeelbackTaggedMessage from "astro-feelback/components/FeelbackTaggedMessage.astro";
---

<div class="rightbar">
    <FeelbackTaggedMessage contentSetId="content-set-id-from-panel"
        layout="button-switch"
        preset="feeling"
        label="Send feedback"
        title="What's on your mind?"
        textAnswer="Thanks for your feedback"
    />
</div>

FeelbackSplitTaggedMessage

Displays a Do you like this page? question with Yes / No buttons. When pressed, a form with different choices is shown. The user can pick a choice to activate the relative tag, and optionally can fill a textarea before sending the feedback. The choices can be different for the Yes and the No cases.

Example stripe docs question Example stripe docs form

You can checkout a step by step guide to use this component: Stripe-like documentation for Astro.


With the FeelbackSplitTaggedMessage, you can receive a FeelbackTaggedMessage feelback on your content.

Properties

propertytypedefaultdescription
targetTargetContentrequiredspecify the target content
titles{
  y: string,
  n: string
}
(empty)The form form titles for both the Yes case and the No case, if empty the title is not shown
tags{
  y: ValueDef[],
  n: ValueDef[]
}
requiredThe list of ValueDef values for both the Yes case and the No case, used to compose the choices
textQuestionstring"Is this page useful?"you can set this to empty or undefined to hide the text
textAnswerstring"Thanks for your feedback"shows this text after the user pressed one of the buttons
placeholderstring"Type your message"the text message placeholder
withMessagebooleanfalseshow an textarea for an optional text message
withEmailboolean | "required"falseshow an email field, optional to fill. if "required", the field must be filled

Example

ArticleFooter.astro

---
import FeelbackSplitTaggedMessage from "astro-feelback/components/FeelbackSplitTaggedMessage.astro";

const YES_TAGS = [
    {value: "love", title: "I love this"}
    {value: "moderate", title: "I like this"}
];
const NO_TAGS = [
    {value: "dislike", title: "I don't like this"}
    {value: "hate", title: "I hate this"}
];
---

<div class="footer">
    <FeelbackSplitTaggedMessage contentSetId="content-set-id-from-panel"
        tags={{y: YES_TAGS, n: NO_TAGS }}
        titles={{ y: "How much do you like?", n: "How much you didn't like?"}}
        textAnswer="Thanks for your feedback"
        withMessage
    />
</div>

Style

Feelback components can use the default style provided by the package.


You can import directly the css in your layout file:

layout.astro

---
import "astro-feelback/styles/feelback.css";
---

Or, if you use sass, you can include the source scss and override theme variables:

style.scss

@import "~astro-feelback/styles/feelback.scss";