Skip to content

Commit

Permalink
chore: smooth offset anchors for card ctas
Browse files Browse the repository at this point in the history
  • Loading branch information
jamiehenson committed Sep 25, 2024
1 parent b8ff740 commit 56b3176
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 34 deletions.
2 changes: 1 addition & 1 deletion src/core/FeaturedLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const FeaturedLink = ({

return (
<a
href={url}
{...(onClick ? {} : { href: url })}
className={`font-sans font-bold block text-gui-default hover:text-gui-hover focus:text-gui-focus focus:outline-gui-focus group ui-${textSize} ${
flush ? "" : "py-8"
} ${additionalCSS}`}
Expand Down
16 changes: 14 additions & 2 deletions src/core/Pricing/PricingCards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@ export type PricingCardsProps = {
delimiter?: IconName;
};

const onCtaClick = (id: string) => {
const element = document.getElementById(id.split("#")[1]);

if (element) {
window.scrollTo({
top: element.getBoundingClientRect().top + window.scrollY - 96,
behavior: "smooth",
});
}
};

const PricingCards = ({
data,
theme = "dark",
Expand Down Expand Up @@ -139,8 +150,9 @@ const PricingCards = ({
•••
</div>
<FeaturedLink
url={cta.url ?? "#"}
additionalCSS={`sm:hidden group-hover:block font-medium ui-text-p3 ${t("text-neutral-500")} hover:${t("text-neutral-000")} transition-colors`}
url="#"
additionalCSS={`sm:hidden group-hover:block font-medium ui-text-p3 ${t("text-neutral-500")} hover:${t("text-neutral-000")} transition-colors cursor-pointer`}
onClick={() => onCtaClick(cta.url)}
>
{cta.text}
</FeaturedLink>
Expand Down
48 changes: 20 additions & 28 deletions src/core/Pricing/__snapshots__/PricingCards.stories.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ exports[`Features/Pricing Cards PlansDarkMode smoke-test 1`] = `
</div>
</div>
<div class="group">
<a href="#"
<a href="https://ably.com/sign-up"
class="font-sans font-bold block text-gui-default hover:text-gui-hover focus:text-gui-focus focus:outline-gui-focus group ui-text-p2 py-8 text-center ui-btn bg-neutral-000 text-neutral-1300 hover:text-neutral-000 px-24 !py-12 "
style="--featured-link-icon-size: var(--fs-p2);"
>
Expand Down Expand Up @@ -660,8 +660,7 @@ exports[`Features/Pricing Cards PlansDarkMode smoke-test 1`] = `
<div class="hidden sm:block sm:group-hover:hidden leading-6 font-extralight text-p3 text-neutral-800">
•••
</div>
<a href="#"
class="font-sans font-bold block text-gui-default hover:text-gui-hover focus:text-gui-focus focus:outline-gui-focus group ui-text-p2 py-8 sm:hidden group-hover:block font-medium ui-text-p3 text-neutral-500 hover:text-neutral-000 transition-colors"
<a class="font-sans font-bold block text-gui-default hover:text-gui-hover focus:text-gui-focus focus:outline-gui-focus group ui-text-p2 py-8 sm:hidden group-hover:block font-medium ui-text-p3 text-neutral-500 hover:text-neutral-000 transition-colors cursor-pointer"
style="--featured-link-icon-size: var(--fs-p2);"
>
See all features
Expand Down Expand Up @@ -704,7 +703,7 @@ exports[`Features/Pricing Cards PlansDarkMode smoke-test 1`] = `
</div>
</div>
<div class="group">
<a href="#"
<a href="https://ably.com/users/paid_sign_up"
class="font-sans font-bold block text-gui-default hover:text-gui-hover focus:text-gui-focus focus:outline-gui-focus group ui-text-p2 py-8 text-center ui-btn bg-neutral-000 text-neutral-1300 hover:text-neutral-000 px-24 !py-12 "
style="--featured-link-icon-size: var(--fs-p2);"
>
Expand Down Expand Up @@ -773,8 +772,7 @@ exports[`Features/Pricing Cards PlansDarkMode smoke-test 1`] = `
<div class="hidden sm:block sm:group-hover:hidden leading-6 font-extralight text-p3 text-neutral-800">
•••
</div>
<a href="#"
class="font-sans font-bold block text-gui-default hover:text-gui-hover focus:text-gui-focus focus:outline-gui-focus group ui-text-p2 py-8 sm:hidden group-hover:block font-medium ui-text-p3 text-neutral-500 hover:text-neutral-000 transition-colors"
<a class="font-sans font-bold block text-gui-default hover:text-gui-hover focus:text-gui-focus focus:outline-gui-focus group ui-text-p2 py-8 sm:hidden group-hover:block font-medium ui-text-p3 text-neutral-500 hover:text-neutral-000 transition-colors cursor-pointer"
style="--featured-link-icon-size: var(--fs-p2);"
>
See all features
Expand All @@ -798,7 +796,7 @@ exports[`Features/Pricing Cards PlansDarkMode smoke-test 1`] = `
Pro
</p>
<p class="ui-text-p1 ui-text-p1 text-neutral-500">
Scale with confidence.
Scale business critical workloads.
</p>
</div>
<div class="flex items-end gap-8 ">
Expand All @@ -817,7 +815,7 @@ exports[`Features/Pricing Cards PlansDarkMode smoke-test 1`] = `
</div>
</div>
<div class="group">
<a href="#"
<a href="https://ably.com/users/paid_sign_up"
class="font-sans font-bold block text-gui-default hover:text-gui-hover focus:text-gui-focus focus:outline-gui-focus group ui-text-p2 py-8 text-center ui-btn bg-neutral-000 text-neutral-1300 hover:text-neutral-000 px-24 !py-12 "
style="--featured-link-icon-size: var(--fs-p2);"
>
Expand Down Expand Up @@ -897,8 +895,7 @@ exports[`Features/Pricing Cards PlansDarkMode smoke-test 1`] = `
<div class="hidden sm:block sm:group-hover:hidden leading-6 font-extralight text-p3 text-neutral-800">
•••
</div>
<a href="#"
class="font-sans font-bold block text-gui-default hover:text-gui-hover focus:text-gui-focus focus:outline-gui-focus group ui-text-p2 py-8 sm:hidden group-hover:block font-medium ui-text-p3 text-neutral-500 hover:text-neutral-000 transition-colors"
<a class="font-sans font-bold block text-gui-default hover:text-gui-hover focus:text-gui-focus focus:outline-gui-focus group ui-text-p2 py-8 sm:hidden group-hover:block font-medium ui-text-p3 text-neutral-500 hover:text-neutral-000 transition-colors cursor-pointer"
style="--featured-link-icon-size: var(--fs-p2);"
>
See all features
Expand All @@ -922,7 +919,7 @@ exports[`Features/Pricing Cards PlansDarkMode smoke-test 1`] = `
Enterprise
</p>
<p class="ui-text-p1 ui-text-p1 text-neutral-500">
Deliver without limits.
Serious workloads without limits.
</p>
</div>
<div class="flex items-end gap-8 ">
Expand All @@ -933,7 +930,7 @@ exports[`Features/Pricing Cards PlansDarkMode smoke-test 1`] = `
</div>
</div>
<div class="group">
<a href="#"
<a href="#pricing-enterprise"
class="font-sans font-bold block text-gui-default hover:text-gui-hover focus:text-gui-focus focus:outline-gui-focus group ui-text-p2 py-8 text-center ui-btn bg-neutral-000 text-neutral-1300 hover:text-neutral-000 px-24 !py-12 ui-btn-alt text-white"
style="--featured-link-icon-size: var(--fs-p2);"
>
Expand Down Expand Up @@ -1035,8 +1032,7 @@ exports[`Features/Pricing Cards PlansDarkMode smoke-test 1`] = `
<div class="hidden sm:block sm:group-hover:hidden leading-6 font-extralight text-p3 text-neutral-800">
•••
</div>
<a href="#"
class="font-sans font-bold block text-gui-default hover:text-gui-hover focus:text-gui-focus focus:outline-gui-focus group ui-text-p2 py-8 sm:hidden group-hover:block font-medium ui-text-p3 text-neutral-500 hover:text-neutral-000 transition-colors"
<a class="font-sans font-bold block text-gui-default hover:text-gui-hover focus:text-gui-focus focus:outline-gui-focus group ui-text-p2 py-8 sm:hidden group-hover:block font-medium ui-text-p3 text-neutral-500 hover:text-neutral-000 transition-colors cursor-pointer"
style="--featured-link-icon-size: var(--fs-p2);"
>
See all features
Expand Down Expand Up @@ -1080,7 +1076,7 @@ exports[`Features/Pricing Cards PlansLightMode smoke-test 1`] = `
</div>
</div>
<div class="group">
<a href="#"
<a href="https://ably.com/sign-up"
class="font-sans font-bold block text-gui-default hover:text-gui-hover focus:text-gui-focus focus:outline-gui-focus group ui-text-p2 py-8 text-center ui-btn bg-neutral-1300 text-neutral-000 hover:text-neutral-000 px-24 !py-12 "
style="--featured-link-icon-size: var(--fs-p2);"
>
Expand Down Expand Up @@ -1144,8 +1140,7 @@ exports[`Features/Pricing Cards PlansLightMode smoke-test 1`] = `
<div class="hidden sm:block sm:group-hover:hidden leading-6 font-extralight text-p3 text-neutral-500">
•••
</div>
<a href="#"
class="font-sans font-bold block text-gui-default hover:text-gui-hover focus:text-gui-focus focus:outline-gui-focus group ui-text-p2 py-8 sm:hidden group-hover:block font-medium ui-text-p3 text-neutral-800 hover:text-neutral-1300 transition-colors"
<a class="font-sans font-bold block text-gui-default hover:text-gui-hover focus:text-gui-focus focus:outline-gui-focus group ui-text-p2 py-8 sm:hidden group-hover:block font-medium ui-text-p3 text-neutral-800 hover:text-neutral-1300 transition-colors cursor-pointer"
style="--featured-link-icon-size: var(--fs-p2);"
>
See all features
Expand Down Expand Up @@ -1188,7 +1183,7 @@ exports[`Features/Pricing Cards PlansLightMode smoke-test 1`] = `
</div>
</div>
<div class="group">
<a href="#"
<a href="https://ably.com/users/paid_sign_up"
class="font-sans font-bold block text-gui-default hover:text-gui-hover focus:text-gui-focus focus:outline-gui-focus group ui-text-p2 py-8 text-center ui-btn bg-neutral-1300 text-neutral-000 hover:text-neutral-000 px-24 !py-12 "
style="--featured-link-icon-size: var(--fs-p2);"
>
Expand Down Expand Up @@ -1257,8 +1252,7 @@ exports[`Features/Pricing Cards PlansLightMode smoke-test 1`] = `
<div class="hidden sm:block sm:group-hover:hidden leading-6 font-extralight text-p3 text-neutral-500">
•••
</div>
<a href="#"
class="font-sans font-bold block text-gui-default hover:text-gui-hover focus:text-gui-focus focus:outline-gui-focus group ui-text-p2 py-8 sm:hidden group-hover:block font-medium ui-text-p3 text-neutral-800 hover:text-neutral-1300 transition-colors"
<a class="font-sans font-bold block text-gui-default hover:text-gui-hover focus:text-gui-focus focus:outline-gui-focus group ui-text-p2 py-8 sm:hidden group-hover:block font-medium ui-text-p3 text-neutral-800 hover:text-neutral-1300 transition-colors cursor-pointer"
style="--featured-link-icon-size: var(--fs-p2);"
>
See all features
Expand All @@ -1282,7 +1276,7 @@ exports[`Features/Pricing Cards PlansLightMode smoke-test 1`] = `
Pro
</p>
<p class="ui-text-p1 ui-text-p1 text-neutral-800">
Scale with confidence.
Scale business critical workloads.
</p>
</div>
<div class="flex items-end gap-8 ">
Expand All @@ -1301,7 +1295,7 @@ exports[`Features/Pricing Cards PlansLightMode smoke-test 1`] = `
</div>
</div>
<div class="group">
<a href="#"
<a href="https://ably.com/users/paid_sign_up"
class="font-sans font-bold block text-gui-default hover:text-gui-hover focus:text-gui-focus focus:outline-gui-focus group ui-text-p2 py-8 text-center ui-btn bg-neutral-1300 text-neutral-000 hover:text-neutral-000 px-24 !py-12 "
style="--featured-link-icon-size: var(--fs-p2);"
>
Expand Down Expand Up @@ -1381,8 +1375,7 @@ exports[`Features/Pricing Cards PlansLightMode smoke-test 1`] = `
<div class="hidden sm:block sm:group-hover:hidden leading-6 font-extralight text-p3 text-neutral-500">
•••
</div>
<a href="#"
class="font-sans font-bold block text-gui-default hover:text-gui-hover focus:text-gui-focus focus:outline-gui-focus group ui-text-p2 py-8 sm:hidden group-hover:block font-medium ui-text-p3 text-neutral-800 hover:text-neutral-1300 transition-colors"
<a class="font-sans font-bold block text-gui-default hover:text-gui-hover focus:text-gui-focus focus:outline-gui-focus group ui-text-p2 py-8 sm:hidden group-hover:block font-medium ui-text-p3 text-neutral-800 hover:text-neutral-1300 transition-colors cursor-pointer"
style="--featured-link-icon-size: var(--fs-p2);"
>
See all features
Expand All @@ -1406,7 +1399,7 @@ exports[`Features/Pricing Cards PlansLightMode smoke-test 1`] = `
Enterprise
</p>
<p class="ui-text-p1 ui-text-p1 text-neutral-800">
Deliver without limits.
Serious workloads without limits.
</p>
</div>
<div class="flex items-end gap-8 ">
Expand All @@ -1417,7 +1410,7 @@ exports[`Features/Pricing Cards PlansLightMode smoke-test 1`] = `
</div>
</div>
<div class="group">
<a href="#"
<a href="#pricing-enterprise"
class="font-sans font-bold block text-gui-default hover:text-gui-hover focus:text-gui-focus focus:outline-gui-focus group ui-text-p2 py-8 text-center ui-btn bg-neutral-1300 text-neutral-000 hover:text-neutral-000 px-24 !py-12 ui-btn-alt text-white"
style="--featured-link-icon-size: var(--fs-p2);"
>
Expand Down Expand Up @@ -1519,8 +1512,7 @@ exports[`Features/Pricing Cards PlansLightMode smoke-test 1`] = `
<div class="hidden sm:block sm:group-hover:hidden leading-6 font-extralight text-p3 text-neutral-500">
•••
</div>
<a href="#"
class="font-sans font-bold block text-gui-default hover:text-gui-hover focus:text-gui-focus focus:outline-gui-focus group ui-text-p2 py-8 sm:hidden group-hover:block font-medium ui-text-p3 text-neutral-800 hover:text-neutral-1300 transition-colors"
<a class="font-sans font-bold block text-gui-default hover:text-gui-hover focus:text-gui-focus focus:outline-gui-focus group ui-text-p2 py-8 sm:hidden group-hover:block font-medium ui-text-p3 text-neutral-800 hover:text-neutral-1300 transition-colors cursor-pointer"
style="--featured-link-icon-size: var(--fs-p2);"
>
See all features
Expand Down
6 changes: 3 additions & 3 deletions src/core/Pricing/data.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const planData: PricingDataFeature[] = [
color: "text-neutral-500",
},
price: { amount: 0 },
cta: { text: "Start for free", url: "https://ably.com/sign-up" },
cta: { text: "Start for free", url: "/sign-up" },
sections: [
{
title: "Capacity",
Expand Down Expand Up @@ -61,7 +61,7 @@ export const planData: PricingDataFeature[] = [
</>
),
},
cta: { text: "Get started", url: "https://ably.com/users/paid_sign_up" },
cta: { text: "Get started", url: "/users/paid_sign_up" },
sections: [
{
title: "Capacity",
Expand Down Expand Up @@ -112,7 +112,7 @@ export const planData: PricingDataFeature[] = [
</>
),
},
cta: { text: "Get started", url: "https://ably.com/users/paid_sign_up" },
cta: { text: "Get started", url: "/users/paid_sign_up" },
sections: [
{
title: "Capacity",
Expand Down

0 comments on commit 56b3176

Please sign in to comment.