Free
a month
Month to month
- 3 sites
- 10K renders a month
- 250 MB of storage
Todos os componentes · Categoria: Preços e contadores
Planos mensais e anuais com preços que rolam como um odômetro.
Cartões de planos sob uma chave: vire e cada preço rola dígito a dígito para o outro período, com a economia calculada dos seus próprios números. Os planos, os preços e os limites vêm todos por props, então a página decide cada valor. Não há etapa de pagamento, e escolher um plano só avisa a sua página.
01
Props
Gerado a partir do manifesto do componente e dos valores acima.
index.html
<pricing-toggle
currency="$"
period="yearly"
locale="en"
plans="[{"name":"Free","monthly":0,"yearly":0,"limits":"3 sites;10K renders a month;250 MB of storage","featured":false},{"name":"Pro","monthly":14,"yearly":140,"limits":"25 sites;1.25M renders a month;3 GB of storage","featured":true},{"name":"Agency","monthly":49,"yearly":490,"limits":"100 sites;4M renders a month;50 GB of storage","featured":false}]"
></pricing-toggle>
<script>
const element = document.querySelector("pricing-toggle");
element.addEventListener("pricing-toggle:period", (event) => {
console.log(event.detail);
});
element.addEventListener("pricing-toggle:pick", (event) => {
console.log(event.detail);
});
</script>
taggor-component.js
const element = document.createElement("pricing-toggle");
element.setAttribute("currency", "$");
element.setAttribute("period", "yearly");
element.setAttribute("locale", "en");
element.plans = [
{
"name": "Free",
"monthly": 0,
"yearly": 0,
"limits": "3 sites;10K renders a month;250 MB of storage",
"featured": false
},
{
"name": "Pro",
"monthly": 14,
"yearly": 140,
"limits": "25 sites;1.25M renders a month;3 GB of storage",
"featured": true
},
{
"name": "Agency",
"monthly": 49,
"yearly": 490,
"limits": "100 sites;4M renders a month;50 GB of storage",
"featured": false
}
];
element.addEventListener("pricing-toggle:period", (event) => {
console.log(event.detail);
});
element.addEventListener("pricing-toggle:pick", (event) => {
console.log(event.detail);
});
document.body.append(element);
PricingToggle.tsx
import { useEffect, useRef } from "react";
export function PricingToggle() {
const ref = useRef<HTMLElement>(null);
useEffect(() => {
const element = ref.current;
if (!element) return;
Object.assign(element, {
plans: [
{
"name": "Free",
"monthly": 0,
"yearly": 0,
"limits": "3 sites;10K renders a month;250 MB of storage",
"featured": false
},
{
"name": "Pro",
"monthly": 14,
"yearly": 140,
"limits": "25 sites;1.25M renders a month;3 GB of storage",
"featured": true
},
{
"name": "Agency",
"monthly": 49,
"yearly": 490,
"limits": "100 sites;4M renders a month;50 GB of storage",
"featured": false
}
],
});
const onPeriod = (event: Event) => {
console.log((event as CustomEvent).detail);
};
element.addEventListener("pricing-toggle:period", onPeriod);
const onPick = (event: Event) => {
console.log((event as CustomEvent).detail);
};
element.addEventListener("pricing-toggle:pick", onPick);
return () => {
element.removeEventListener("pricing-toggle:period", onPeriod);
element.removeEventListener("pricing-toggle:pick", onPick);
};
}, []);
return <pricing-toggle ref={ref} currency={"$"} period="yearly" locale="en" />;
}
PricingToggle.tsx
import { useEffect, useRef } from "react";
export function PricingToggle() {
const ref = useRef<HTMLElement>(null);
useEffect(() => {
const element = ref.current;
if (!element) return;
Object.assign(element, {
plans: [
{
"name": "Free",
"monthly": 0,
"yearly": 0,
"limits": "3 sites;10K renders a month;250 MB of storage",
"featured": false
},
{
"name": "Pro",
"monthly": 14,
"yearly": 140,
"limits": "25 sites;1.25M renders a month;3 GB of storage",
"featured": true
},
{
"name": "Agency",
"monthly": 49,
"yearly": 490,
"limits": "100 sites;4M renders a month;50 GB of storage",
"featured": false
}
],
});
const onPeriod = (event: Event) => {
console.log((event as CustomEvent).detail);
};
element.addEventListener("pricing-toggle:period", onPeriod);
const onPick = (event: Event) => {
console.log((event as CustomEvent).detail);
};
element.addEventListener("pricing-toggle:pick", onPick);
return () => {
element.removeEventListener("pricing-toggle:period", onPeriod);
element.removeEventListener("pricing-toggle:pick", onPick);
};
}, []);
return <pricing-toggle ref={ref} currency={"$"} period="yearly" locale="en" />;
}
src/PricingToggle.vue
<script setup lang="ts">
function onPeriod(event: Event) {
console.log((event as CustomEvent).detail);
}
function onPick(event: Event) {
console.log((event as CustomEvent).detail);
}
</script>
<template>
<pricing-toggle
currency="$"
period="yearly"
locale="en"
:plans.prop="[{"name":"Free","monthly":0,"yearly":0,"limits":"3 sites;10K renders a month;250 MB of storage","featured":false},{"name":"Pro","monthly":14,"yearly":140,"limits":"25 sites;1.25M renders a month;3 GB of storage","featured":true},{"name":"Agency","monthly":49,"yearly":490,"limits":"100 sites;4M renders a month;50 GB of storage","featured":false}]"
@pricing-toggle:period="onPeriod"
@pricing-toggle:pick="onPick"
/>
</template>
vite.config.ts
import vue from "@vitejs/plugin-vue";
import { defineConfig } from "vite";
export default defineConfig({
plugins: [
vue({
template: {
compilerOptions: {
isCustomElement: (tag) => tag === "pricing-toggle",
},
},
}),
],
});
src/app/pricing-toggle.component.ts
import { afterNextRender, Component, CUSTOM_ELEMENTS_SCHEMA, DestroyRef, ElementRef, inject } from "@angular/core";
@Component({
selector: "app-pricing-toggle",
schemas: [CUSTOM_ELEMENTS_SCHEMA],
template: `
<pricing-toggle
[currency]="'$'"
period="yearly"
locale="en"
[plans]="values.plans"
></pricing-toggle>
`,
})
export class PricingToggleComponent {
readonly values = {
plans: [
{
"name": "Free",
"monthly": 0,
"yearly": 0,
"limits": "3 sites;10K renders a month;250 MB of storage",
"featured": false
},
{
"name": "Pro",
"monthly": 14,
"yearly": 140,
"limits": "25 sites;1.25M renders a month;3 GB of storage",
"featured": true
},
{
"name": "Agency",
"monthly": 49,
"yearly": 490,
"limits": "100 sites;4M renders a month;50 GB of storage",
"featured": false
}
],
};
constructor() {
const host = inject<ElementRef<HTMLElement>>(ElementRef);
const element = () => host.nativeElement.querySelector("pricing-toggle");
const onPeriod = (event: Event) => {
console.log((event as CustomEvent).detail);
};
afterNextRender(() => element()?.addEventListener("pricing-toggle:period", onPeriod));
inject(DestroyRef).onDestroy(() => element()?.removeEventListener("pricing-toggle:period", onPeriod));
const onPick = (event: Event) => {
console.log((event as CustomEvent).detail);
};
afterNextRender(() => element()?.addEventListener("pricing-toggle:pick", onPick));
inject(DestroyRef).onDestroy(() => element()?.removeEventListener("pricing-toggle:pick", onPick));
}
}
src/TaggorComponent.svelte
<script>
function onPeriod(event) {
console.log(event.detail);
}
function onPick(event) {
console.log(event.detail);
}
</script>
<pricing-toggle
currency={"$"}
period="yearly"
locale="en"
plans={[
{
"name": "Free",
"monthly": 0,
"yearly": 0,
"limits": "3 sites;10K renders a month;250 MB of storage",
"featured": false
},
{
"name": "Pro",
"monthly": 14,
"yearly": 140,
"limits": "25 sites;1.25M renders a month;3 GB of storage",
"featured": true
},
{
"name": "Agency",
"monthly": 49,
"yearly": 490,
"limits": "100 sites;4M renders a month;50 GB of storage",
"featured": false
}
]}
onpricing-toggle:period={onPeriod}
onpricing-toggle:pick={onPick}
></pricing-toggle>
Como um agente leva um componente assim a um site:
taggor checktaggor publishAs variáveis CSS que o componente expõe, definidas como a página de um cliente faria.
styles.css
pricing-toggle {
--pt-radius: 18px;
}02
| Prop | Tipo | Padrão | O que faz |
|---|---|---|---|
| plans | list | nenhum | The plans. Prices are numbers (yearly is the whole year's total); limits are separated by semicolons. |
| currency | string | $ | Symbol before each price. |
| period | monthly | yearly | yearly | Which period the switch starts on. |
| cta | string | nenhum | Replaces the plan button text. |
| hideSample | boolean | false | Hides the Sample content mark (use it with your own plans). |
| locale | pt-BR | en | en | – |
Os nomes e as descrições das props são os do próprio componente, em inglês, como o autor escreveu.
03
| Evento | Quando dispara |
|---|---|
| period | The visitor moved the switch. |
| pick | The visitor chose a plan. |
04
Cole no seu agente. Ele pergunta a você antes de entrar na conta, pagar ou ir além de verificar e publicar.
Construa para mim um componente do Taggor como "Alternador de preços" (pricing-toggle): Planos mensais e anuais com preços que rolam como um odômetro.
Busque https://taggor.dev/agent-setup/prompt.md e siga as instruções de lá para me configurar para o Taggor. Pergunte-me antes de entrar na conta, criar uma conta, aceitar termos, pagar qualquer coisa ou digitar um segredo.
Verifique com `taggor check` e publique com `taggor publish`, e pare por aí.
Não promova para produção, não anexe a um site, não faça rollback nem use --yes, --force ou --force-drop-invalid, a menos que eu peça exatamente isso nesta conversa.
05