Skip to content

Commit

Permalink
release v0.2 with form-type Feelbacks
Browse files Browse the repository at this point in the history
SDKs bumped to v0.2.0
- feat: added FeelbackMessage and FeelbackTaggedMessage components
- feat: style improvements with per-component styling possible

Samples
- added nextjs with bare template
- added nextra with doc template
  • Loading branch information
giuseppelt committed May 29, 2023
1 parent e23023a commit 289dd08
Show file tree
Hide file tree
Showing 85 changed files with 5,449 additions and 733 deletions.
1 change: 1 addition & 0 deletions .vscode/cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"mjml",
"mobx",
"nestjs",
"nextra",
"nocheck",
"nodenext",
"outdir",
Expand Down
14 changes: 14 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,20 @@
"presentation": {
"reveal": "never"
}
},
{
"label": "example docusaurus",
"type": "npm",
"script": "start",
"group": "build",
"path": "${workspaceFolder}/samples/docusaurus",
"options": {
"cwd": "${workspaceFolder}/samples/docusaurus"
},
"isBackground": true,
"presentation": {
"reveal": "never"
}
}
]
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Feelback is a service allowing to collect any type of feedback for your content,
## Repository structure
This repository includes:
- Integration SDKs with many frameworks and site builders -- dir [packages](packages)
- Integrations examples with complete projects -- dir [samples](samples)
- Integration examples with complete projects -- dir [samples](samples)


## Contributing
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"watch:ts": "tsc --build tsconfig.dev.json --watch --incremental --force"
},
"devDependencies": {
"@types/node": "^18.16.1",
"@types/node": "^18.16.16",
"ts-node": "^10.9.1",
"typescript": "^5.0.4"
}
Expand Down
6 changes: 6 additions & 0 deletions packages/astro/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# astro-feelback changelog

## 0.2.0 Major release
- feat: added FeelbackMessage and FeelbackTaggedMessage components
- feat: style improvements with per-component styling possible

Check the [documentation](https://www.feelback.dev/docs) for full details.

## 0.1.0 Initial release
Check the [readme](readme.md) for the documentation.
25 changes: 25 additions & 0 deletions packages/astro/components/FeelbackForm.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
import type { TargetContent } from "../src";
import Component from "./parts/Component.astro";
import SwitchResult from "./parts/SwitchResult.astro";
type Props = TargetContent & {
class?: string;
title?: string;
textAnswer?: string;
};
const {
class: className,
title = "Send feedback",
textAnswer = "Thanks for your feedback",
...target
/* */
} = Astro.props;
---

<Component component="form" class={className} {...target}>
<SwitchResult textAnswer={textAnswer}>
<slot />
</SwitchResult>
</Component>
76 changes: 76 additions & 0 deletions packages/astro/components/FeelbackMessage.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
---
import type { TargetContent } from "../src";
import Component from "./parts/Component.astro";
import SwitchResult from "./parts/SwitchResult.astro";
import TriggerButton from "./parts/TriggerButton.astro";
import MessageForm from "./forms/MessageForm.astro";
import FeelbackForm from "./FeelbackForm.astro";
type Props = TargetContent & {
layout?: "button-switch" | "button-dialog" | "inline";
title?: string;
label?: string;
minLength?: number;
maxLength?: number;
textAnswer?: string;
placeholder?: string;
};
const {
layout = "inline",
label = "Send feedback",
title = "Send feedback",
textAnswer = "Thanks for your feedback",
placeholder = "Type your message",
minLength,
maxLength,
...target
} = Astro.props;
const behavior = layout === "button-dialog" ? "dialog" : layout === "button-switch" ? "switch" : undefined;
const formAttrs = {
title,
placeholder,
minLength,
maxLength,
};
const btnCancelAttrs =
layout === "button-switch"
? {
"data-behavior-action": "switch",
"data-behavior-target": ".trigger-btn",
"data-behavior-source": ".feelback-form",
}
: {
"data-behavior-action": "cancel",
};
---

{
(layout === "button-dialog" || layout === "button-switch") && (
<Component component="form" class={`feelback-message layout-${layout}`} behavior={behavior} {...target}>
<SwitchResult textAnswer={textAnswer}>
<TriggerButton
action={layout === "button-dialog" ? "dialog" : "switch"}
target=".feelback-form"
label={label}
/>
<MessageForm {...formAttrs} class={`hidden${layout === "button-dialog" ? " dialog" : ""}`}>
<button slot="btn-cancel" class="feelback-btn btn-cancel" title="Cancel" {...btnCancelAttrs}>
Cancel
</button>
</MessageForm>
</SwitchResult>
</Component>
)
}

{
layout === "inline" && (
<FeelbackForm class="feelback-message layout-inline" textAnswer={textAnswer} {...target}>
<MessageForm {...formAttrs} />
</FeelbackForm>
)
}
19 changes: 14 additions & 5 deletions packages/astro/components/FeelbackPulse.astro
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import type { TargetContent } from "../src";
import ButtonValueList from "./parts/ButtonValueList.astro";
import type { PresetName as ButtonsPresetName } from "./parts/ButtonValueList.astro";
import Container from "./parts/Container.astro";
import Component from "./parts/Component.astro";
type PresetName = "heart" | "star" | "like";
Expand All @@ -13,11 +13,20 @@ type Props = TargetContent & {
revokable?: boolean;
};
const { revokable, showCount, showTitle, preset = "heart", ...target } = Astro.props;
const {
preset = "heart",
revokable,
showCount,
showTitle,
...target
/* */
} = Astro.props;
const items = typeof preset === "string" ? (`pulse-${preset}` as ButtonsPresetName) : ([["+", ...preset]] as const);
---

<Container {...{...target, revokable, showCount}}>
<ButtonValueList {...{items, showTitle, showCount}} />
</Container>
<Component component="buttons" class="feelback-pulse" {...{ ...target, revokable, showCount }}>
<div class="feelback-q">
<ButtonValueList {...{ items, showTitle, showCount }} />
</div>
</Component>
7 changes: 4 additions & 3 deletions packages/astro/components/FeelbackReaction.astro
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,20 @@ import type { ButtonItem } from "./parts/ButtonValueList.astro";
import FeelbackReactionPicker from "./FeelbackReactionPicker.astro";
import FeelbackReactionList from "./FeelbackReactionList.astro";
type PresetName = "sentiment" | "github" | "facebook";
type PresetName = "feeling" | "github" | "facebook";
type Props = TargetContent & {
preset: PresetName | readonly ButtonItem[];
layout?: "picker" | "list";
pickerTitle?: string;
showCount?: boolean;
showTitle?: boolean;
revokable?: boolean;
textQuestion?: string;
textAnswer?: string;
};
const { layout = "list", ...props } = Astro.props;
const { layout = "list", pickerTitle, ...props } = Astro.props;
---

{layout === "list" ? <FeelbackReactionList {...props} /> : <FeelbackReactionPicker {...props} />}
{layout === "list" ? <FeelbackReactionList {...props} /> : <FeelbackReactionPicker title={pickerTitle} {...props} />}
16 changes: 11 additions & 5 deletions packages/astro/components/FeelbackReactionList.astro
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
import type { TargetContent } from "../src";
import type { ButtonItem } from "./parts/ButtonValueList.astro";
import ButtonValueList from "./parts/ButtonValueList.astro";
import SwitchContainer from "./parts/SwitchContainer.astro";
import Component from "./parts/Component.astro";
import SwitchResult from "./parts/SwitchResult.astro";
type PresetName = "sentiment" | "github" | "facebook";
type PresetName = "feeling" | "github" | "facebook";
type Props = TargetContent & {
preset: PresetName | readonly ButtonItem[];
Expand All @@ -26,6 +27,11 @@ const {
} = Astro.props;
---

<SwitchContainer {...{...target,revokable,showCount,textQuestion,textAnswer}}>
<ButtonValueList {...{items, showTitle,showCount}} />
</SwitchContainer>
<Component component="buttons" class="feelback-reaction layout-list" {...{ ...target, revokable, showCount }}>
<SwitchResult textAnswer={textAnswer}>
<div class="feelback-q">
{textQuestion && <span class="feelback-text">{textQuestion}</span>}
<ButtonValueList {...{ items, showTitle, showCount }} />
</div>
</SwitchResult>
</Component>
25 changes: 14 additions & 11 deletions packages/astro/components/FeelbackReactionPicker.astro
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,30 @@
import type { TargetContent } from "../src";
import type { ButtonItem } from "./parts/ButtonValueList.astro";
import ButtonValueList from "./parts/ButtonValueList.astro";
import Container from "./parts/Container.astro";
import Component from "./parts/Component.astro";
import iconHappy from "@feelback/js/icons/icon-happy.svg?raw";
type PresetName = "sentiment" | "github" | "facebook";
type PresetName = "feeling" | "github" | "facebook";
type Props = TargetContent & {
preset: PresetName | readonly ButtonItem[];
title?: string;
showCount?: boolean;
showTitle?: boolean;
revokable?: boolean;
};
const { revokable, showCount = true, showTitle, preset: items, ...target } = Astro.props;
const { revokable, title = "Pick a reaction", showCount = true, showTitle, preset: items, ...target } = Astro.props;
---

<Container {...{...target,revokable,showCount}}>
<button class="feelback-btn btn-picker">
<span class="feelback-icon" set:html={iconHappy} />
</button>
<div class="picker">
<ButtonValueList {...{items, showTitle}} />
<Component component="buttons" class="feelback-reaction layout-picker" {...{ ...target, revokable, showCount }}>
<div class="feelback-q">
<button class="feelback-btn btn-reaction-picker" title={title} data-behavior-action="popup">
<span class="feelback-icon" set:html={iconHappy} />
</button>
<div class="hidden popup">
<ButtonValueList class="attached" {...{ items, showTitle }} />
</div>
<ButtonValueList hideZero {...{ items, showTitle, showCount }} />
</div>
<ButtonValueList {...{items, showTitle,showCount}} hideZero />
</Container>
</Component>
79 changes: 79 additions & 0 deletions packages/astro/components/FeelbackTaggedMessage.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
---
import type { TargetContent } from "../src";
import Component from "./parts/Component.astro";
import SwitchResult from "./parts/SwitchResult.astro";
import TriggerButton from "./parts/TriggerButton.astro";
import TaggedMessageForm, { PresetName } from "./forms/TaggedMessageForm.astro";
import FeelbackForm from "./FeelbackForm.astro";
type Props = TargetContent & {
layout?: "button-switch" | "button-dialog" | "inline";
preset?: PresetName;
title?: string;
label?: string;
minLength?: number;
maxLength?: number;
textAnswer?: string;
placeholder?: string;
};
const {
layout = "inline",
label = "Send feedback",
title = "Send feedback",
textAnswer = "Thanks for your feedback",
placeholder = "Type your message",
preset = "feedback",
minLength,
maxLength,
...target
} = Astro.props;
const behavior = layout === "button-dialog" ? "dialog" : layout === "button-switch" ? "switch" : undefined;
const formAttrs = {
preset,
title,
placeholder,
minLength,
maxLength,
};
const btnCancelAttrs =
layout === "button-switch"
? {
"data-behavior-action": "switch",
"data-behavior-target": ".trigger-btn",
"data-behavior-source": ".feelback-form",
}
: {
"data-behavior-action": "cancel",
};
---

{
(layout === "button-dialog" || layout === "button-switch") && (
<Component component="form" class={`feelback-tagged-message layout-${layout}`} behavior={behavior} {...target}>
<SwitchResult textAnswer={textAnswer}>
<TriggerButton
action={layout === "button-dialog" ? "dialog" : "switch"}
target=".feelback-form"
label={label}
/>
<TaggedMessageForm {...formAttrs} class={`hidden${layout === "button-dialog" ? " dialog" : ""}`}>
<button slot="btn-cancel" class="feelback-btn btn-cancel" title="Cancel" {...btnCancelAttrs}>
Cancel
</button>
</TaggedMessageForm>
</SwitchResult>
</Component>
)
}

{
layout === "inline" && (
<FeelbackForm class="feelback-tagged-message layout-inline" textAnswer={textAnswer} {...target}>
<TaggedMessageForm {...formAttrs} />
</FeelbackForm>
)
}
Loading

0 comments on commit 289dd08

Please sign in to comment.