Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

feat: Move license purchase to same upgrade flow

Richie McIlroy33b1dd164196
diff --git a/apps/desktop/src-tauri/src/lib.rs b/apps/desktop/src-tauri/src/lib.rs
index 46efe7ce2..ee4259a49 100644
--- a/apps/desktop/src-tauri/src/lib.rs
+++ b/apps/desktop/src-tauri/src/lib.rs
@@ -1706,6 +1706,14 @@ fn list_screenshots(app: AppHandle) -> Result<Vec<(String, PathBuf, RecordingMet
#[specta::specta]
async fn check_upgraded_and_update(app: AppHandle) -> Result<bool, String> {
println!("Checking upgraded status and updating...");
+
+ // Check for commercial license first
+ if let Ok(Some(settings)) = GeneralSettingsStore::get(&app) {
+ if settings.commercial_license.is_some() {
+ return Ok(true);
+ }
+ }
+
let Ok(Some(mut auth)) = AuthStore::get(&app) else {
println!("No auth found, clearing auth store");
AuthStore::set(&app, None).map_err(|e| e.to_string())?;
diff --git a/apps/desktop/src-tauri/src/windows.rs b/apps/desktop/src-tauri/src/windows.rs
index 402cd2c99..f38065c0d 100644
--- a/apps/desktop/src-tauri/src/windows.rs
+++ b/apps/desktop/src-tauri/src/windows.rs
@@ -129,7 +129,7 @@ impl CapWindowId {
Self::Editor { .. } => (900.0, 800.0),
Self::Settings => (600.0, 450.0),
Self::Camera => (460.0, 920.0),
- Self::Upgrade => (800.0, 850.0),
+ Self::Upgrade => (850.0, 850.0),
_ => return None,
})
}
@@ -205,6 +205,7 @@ impl ShowCapWindow {
.focused(true)
.always_on_top(true)
.maximized(false)
+ .shadow(true)
.transparent(true)
.center()
.build()?,
diff --git a/apps/desktop/src/routes/(window-chrome)/(main).tsx b/apps/desktop/src/routes/(window-chrome)/(main).tsx
index 2f75718f6..97bbb3128 100644
--- a/apps/desktop/src/routes/(window-chrome)/(main).tsx
+++ b/apps/desktop/src/routes/(window-chrome)/(main).tsx
@@ -136,7 +136,19 @@ export default function () {
Feedback
</Button>
<ChangelogButton />
- <GiftButton />
+ <Show when={!license.isLoading && license.data?.type === "personal"}>
+ <button
+ type="button"
+ onClick={() => commands.showWindow("Upgrade")}
+ class="relative"
+ >
+ <IconLucideGift class="size-[1.10rem] text-gray-400 hover:text-gray-500" />
+ <div
+ style={{ "background-color": "#FF4747" }}
+ class="block z-10 absolute top-0 right-0 size-1.5 rounded-full animate-bounce"
+ />
+ </button>
+ </Show>
</div>
);
@@ -167,10 +179,10 @@ export default function () {
} rounded-lg px-1.5 py-0.5`}
>
{license.data?.type === "commercial"
- ? "Commercial"
+ ? "Commercial License"
: license.data?.type === "pro"
? "Pro"
- : "Personal"}
+ : "Personal License"}
</span>
</Suspense>
</ErrorBoundary>
@@ -1044,23 +1056,3 @@ function ChangelogButton() {
</button>
);
}
-
-function GiftButton() {
- const [isUpgraded] = createResource(() => commands.checkUpgradedAndUpdate());
-
- return (
- <Show when={!isUpgraded()}>
- <button
- type="button"
- onClick={() => commands.showWindow("Upgrade")}
- class="relative"
- >
- <IconLucideGift class="size-[1.10rem] text-gray-400 hover:text-gray-500" />
- <div
- style={{ "background-color": "#FF4747" }}
- class="block z-10 absolute top-0 right-0 size-1.5 rounded-full animate-bounce"
- />
- </button>
- </Show>
- );
-}
diff --git a/apps/desktop/src/routes/(window-chrome)/licensing.tsx b/apps/desktop/src/routes/(window-chrome)/licensing.tsx
index 0793c2d60..a59377992 100644
--- a/apps/desktop/src/routes/(window-chrome)/licensing.tsx
+++ b/apps/desktop/src/routes/(window-chrome)/licensing.tsx
@@ -67,9 +67,9 @@ export default function Page() {
</span>
</div>
- <p class="text-[--text-tertiary] text-sm pt-1">
+ {/* <p class="text-[--text-tertiary] text-sm pt-1">
Instance ID: {license().instanceId}
- </p>
+ </p> */}
<div class="flex flex-row justify-end">
<Button variant="destructive">Deactivate License Key</Button>
</div>
@@ -138,9 +138,9 @@ function LicenseKeyActivate(props: {
>
Submit
</Button>
- <p class="text-[--text-tertiary] text-sm pt-1">
+ {/* <p class="text-[--text-tertiary] text-sm pt-1">
Instance ID: {generalSettings().instanceId}
- </p>
+ </p> */}
</div>
);
}}
diff --git a/apps/desktop/src/routes/(window-chrome)/upgrade.tsx b/apps/desktop/src/routes/(window-chrome)/upgrade.tsx
index ef1e1c569..589b823b8 100644
--- a/apps/desktop/src/routes/(window-chrome)/upgrade.tsx
+++ b/apps/desktop/src/routes/(window-chrome)/upgrade.tsx
@@ -22,6 +22,12 @@ import { clientEnv } from "~/utils/env";
import { identifyUser, trackEvent } from "~/utils/analytics";
import callbackTemplate from "./callback.template";
import { Input } from "../editor/ui";
+import { licenseApiClient } from "~/utils/web-api";
+import { generalSettingsStore } from "~/store";
+import { createMutation } from "@tanstack/solid-query";
+import { ClientInferResponseBody } from "@ts-rest/core";
+import { licenseContract } from "@cap/web-api-contract";
+import { createLicenseQuery } from "~/utils/queries";
const signInAction = action(async (planType: "yearly" | "monthly") => {
console.log("Starting sign in action");
@@ -78,7 +84,7 @@ const signInAction = action(async (planType: "yearly" | "monthly") => {
console.log("Hiding upgrade window");
const currentUpgradeWindow = await Window.getByLabel("upgrade");
if (currentUpgradeWindow) {
- await currentUpgradeWindow.hide();
+ await currentUpgradeWindow.minimize();
}
console.log("Opening auth URL in browser");
@@ -154,8 +160,9 @@ const signInAction = action(async (planType: "yearly" | "monthly") => {
console.log("Opening checkout URL in external browser");
commands.openExternalLink(response.body.url);
console.log("Minimizing upgrade window");
- if (focusedUpgradeWindow) {
- await focusedUpgradeWindow.minimize();
+ const window = await Window.getByLabel("upgrade");
+ if (window) {
+ await window.minimize();
}
}
} catch (error) {
@@ -166,30 +173,75 @@ const signInAction = action(async (planType: "yearly" | "monthly") => {
});
export default function Page() {
- console.log("Rendering upgrade page");
const proFeatures = [
+ "Commercial License Included",
"Unlimited cloud storage & Shareable links",
"Connect custom S3 storage bucket",
"Advanced teams features",
"Unlimited views",
"Password protected videos",
"Advanced analytics",
- "Commercial Use of Cap Recorder + Editor",
"Priority support",
];
const [isAnnual, setIsAnnual] = createSignal(true);
+ const [isCommercialAnnual, setIsCommercialAnnual] = createSignal(true);
const [upgradeComplete, setUpgradeComplete] = createSignal(false);
const [loading, setLoading] = createSignal(false);
const [isAuthenticated, setIsAuthenticated] = createSignal(true);
+ const [licenseKey, setLicenseKey] = createSignal("");
const signIn = useAction(signInAction);
const submission = useSubmission(signInAction);
+ const license = createLicenseQuery();
+ const navigate = useNavigate();
+
+ const resetLicense = createMutation(() => ({
+ mutationFn: async () => {
+ const generalSettings = await generalSettingsStore.get();
+ if (
+ !generalSettings?.instanceId ||
+ !license.data ||
+ license.data.type !== "commercial"
+ ) {
+ throw new Error("No instance ID or valid commercial license found");
+ }
+
+ const resp = await licenseApiClient.activateCommercialLicense({
+ headers: {
+ licensekey: license.data.licenseKey,
+ instanceid: generalSettings.instanceId,
+ },
+ body: { reset: true },
+ });
+
+ if (resp.status !== 200) {
+ if (
+ typeof resp.body === "object" &&
+ resp.body &&
+ "message" in resp.body
+ )
+ throw resp.body.message;
+ throw new Error((resp.body as any).toString());
+ }
+ },
+ onSuccess: async () => {
+ await generalSettingsStore.set({
+ commercialLicense: undefined,
+ });
+ license.refetch();
+ },
+ }));
const togglePricing = () => {
console.log("Toggling pricing plan");
setIsAnnual(!isAnnual());
};
+ const toggleCommercialPricing = () => {
+ console.log("Toggling commercial pricing plan");
+ setIsCommercialAnnual(!isCommercialAnnual());
+ };
+
const openCheckoutInExternalBrowser = async () => {
console.log("Opening checkout in external browser");
setLoading(true);
@@ -215,9 +267,9 @@ export default function Page() {
console.log("Opening checkout URL in external browser");
commands.openExternalLink(response.body.url);
console.log("Minimizing upgrade window");
- const focusedUpgradeWindow = await Window.getByLabel("upgrade");
- if (focusedUpgradeWindow) {
- await focusedUpgradeWindow.minimize();
+ const window = await Window.getByLabel("upgrade");
+ if (window) {
+ await window.minimize();
}
} else {
console.error("Failed to get checkout URL, status:", response.status);
@@ -229,14 +281,57 @@ export default function Page() {
}
};
- const checkUpgradeStatus = async () => {
- console.log("Checking upgrade status");
- const result = await commands.checkUpgradedAndUpdate();
- if (result) {
- console.log("Upgrade complete");
- setUpgradeComplete(true);
- }
- };
+ const openCommercialCheckout = createMutation(() => ({
+ mutationFn: async () => {
+ const resp = await licenseApiClient.createCommercialCheckoutUrl({
+ body: { type: isCommercialAnnual() ? "yearly" : "lifetime" },
+ });
+
+ if (resp.status === 200) {
+ console.log("Opening checkout URL in external browser");
+ commands.openExternalLink(resp.body.url);
+ console.log("Minimizing upgrade window");
+ const window = await Window.getByLabel("upgrade");
+ if (window) {
+ await window.minimize();
+ }
+ } else {
+ throw resp.body;
+ }
+ },
+ }));
+
+ const activateLicenseKey = createMutation(() => ({
+ mutationFn: async (vars: { licenseKey: string }) => {
+ const generalSettings = await generalSettingsStore.get();
+ if (!generalSettings?.instanceId) {
+ throw new Error("No instance ID found");
+ }
+ const resp = await licenseApiClient.activateCommercialLicense({
+ headers: {
+ licensekey: vars.licenseKey,
+ instanceid: generalSettings.instanceId,
+ },
+ body: { reset: false },
+ });
+
+ if (resp.status === 200)
+ return { ...resp.body, licenseKey: vars.licenseKey };
+ if (typeof resp.body === "object" && resp.body && "message" in resp.body)
+ throw resp.body.message;
+ throw new Error((resp.body as any).toString());
+ },
+ onSuccess: async (value) => {
+ await generalSettingsStore.set({
+ commercialLicense: {
+ activatedOn: Date.now(),
+ expiryDate: value.expiryDate,
+ refresh: value.refresh,
+ licenseKey: value.licenseKey,
+ },
+ });
+ },
+ }));
onMount(async () => {
console.log("Component mounted");
@@ -326,27 +421,29 @@ export default function Page() {
});
console.log("Setting up upgrade status check interval");
- const interval = setInterval(checkUpgradeStatus, 5000);
+ const interval = setInterval(async () => {
+ console.log("Checking upgrade status");
+ const result = await commands.checkUpgradedAndUpdate();
+ if (result) {
+ console.log("Upgrade complete");
+ setUpgradeComplete(true);
+ }
+ }, 5000);
onCleanup(() => {
console.log("Cleaning up upgrade status check interval");
clearInterval(interval);
});
});
- const navigate = useNavigate();
-
return (
- <div
- class={`py-5 w-full max-w-[700px] mx-auto relative items-center flex flex-col ${
- upgradeComplete() ? "h-full" : ""
- }`}
- >
+ <div class="p-5 w-full h-full mx-auto relative items-center justify-center flex flex-col">
{upgradeComplete() && (
<div class="flex justify-center items-center h-full bg-gray-800 bg-opacity-75">
<div class="relative z-10 p-6 text-center bg-white rounded-lg shadow-lg">
- <h2 class="mb-4 text-2xl font-bold">
- Upgrade complete - Welcome to Cap Pro!
- </h2>
+ <h2 class="mb-4 text-2xl font-bold">Upgrade complete</h2>
+ <p class="mb-4 text-sm text-[--text-tertiary]">
+ You can now close this window - thank you for upgrading!
+ </p>
<Button
onClick={() => {
console.log("Closing window after upgrade");
@@ -363,116 +460,283 @@ export default function Page() {
)}
{!upgradeComplete() && (
<>
- <div class="text-center">
- <h1 class="text-4xl md:text-4xl mb-3 tracking-[-.05em] font-medium text-[--text-primary]">
- Upgrade to Cap Pro
- </h1>
- <p class="text-base font-normal leading-6 text-gray-400 dark:text-[--black-transparent-60]">
- Cap is currently in public beta, and we're offering special early
- adopter pricing to our first users.{" "}
- <span class="text-gray-500 dark:text-[--text-primary]">
- This pricing will be locked in for the lifetime of your
- subscription.
- </span>
- </p>
- </div>
- <Button
- class="text-[--text-secondary] text-center text-base my-4"
- variant="secondary"
- onClick={() => navigate("/licensing")}
- >
- Looking for Commercial Licenses?
- </Button>
- <div class="flex-grow p-3 bg-blue-300 rounded-xl border shadow-sm text-card-foreground md:p-3 border-blue-500/20 w-full">
- <div class="space-y-3">
- <div class="flex flex-col space-y-1.5 pt-6 px-6">
- <h3 class="text-2xl font-medium tracking-tight text-gray-50 dark:text-[--text-primary]">
- Cap Pro — Early Adopter Pricing
- </h3>
- <p class="text-[0.875rem] leading-[1.25rem] text-gray-50 dark:text-[--text-primary]">
- For professional use and teams.
- </p>
- <div>
- <div class="flex items-center space-x-3">
- <h3 class="text-4xl text-gray-50 dark:text-[--text-primary]">
- {isAnnual() ? "$6/mo" : "$9/mo"}
- </h3>
- <div>
- <p class="text-sm font-medium text-gray-50 dark:text-[--text-primary]">
- {isAnnual()
- ? "per user, billed annually."
- : "per user, billed monthly."}
- </p>
- {isAnnual() && (
- <p class="text-sm text-gray-50 dark:text-[--text-primary]">
- or, $9/month, billed monthly.
- </p>
+ {license.data?.type === "commercial" ? (
+ <div class="bg-[--gray-50] dark:bg-[--gray-900] rounded-xl shadow-sm border border-gray-200 dark:border-[--gray-700] p-8 w-full">
+ <div class="space-y-6">
+ <div class="border-b border-gray-200 dark:border-[--gray-700] pb-6">
+ <h3 class="text-2xl font-semibold tracking-tight text-[--text-primary]">
+ Your Commercial License
+ </h3>
+ <p class="mt-2 text-sm text-[--text-tertiary]">
+ License details for Cap commercial use
+ </p>
+ </div>
+
+ <div class="space-y-6">
+ <div class="space-y-2">
+ <label class="text-sm font-medium text-[--text-primary]">
+ License Key
+ </label>
+ <pre class="w-full p-3 bg-gray-50 dark:bg-[--gray-800] rounded-lg border border-gray-200 dark:border-[--gray-700] font-mono text-sm text-[--text-secondary] break-all whitespace-pre-wrap">
+ {license.data.licenseKey}
+ </pre>
+ </div>
+
+ <div class="space-y-2">
+ <label class="text-sm font-medium text-[--text-primary]">
+ Expiration Date
+ </label>
+ <div class="w-full p-3 bg-gray-50 dark:bg-[--gray-800] rounded-lg border border-gray-200 dark:border-[--gray-700] text-sm text-[--text-secondary]">
+ {new Date(license.data.expiryDate).toLocaleDateString(
+ undefined,
+ {
+ year: "numeric",
+ month: "long",
+ day: "numeric",
+ }
)}
</div>
</div>
+
+ <div class="pt-4 border-t border-gray-200 dark:border-[--gray-700]">
+ <Button
+ variant="destructive"
+ class="w-fit mx-auto"
+ disabled={resetLicense.isPending}
+ onClick={() => {
+ resetLicense.mutate();
+ }}
+ >
+ {resetLicense.isPending
+ ? "Detaching..."
+ : "Detach License"}
+ </Button>
+ <p class="mt-2 text-xs text-[--text-tertiary]">
+ This will remove the license key from this device.
+ </p>
+ </div>
</div>
</div>
- <div class="px-3 mt-3 md:px-8">
- <div class="flex items-center pt-4 pb-1 mt-3 border-t-2 border-[--white-transparent-20] dark:border-[--black-transparent-20]">
- <span class="mr-2 text-xs text-gray-50 dark:text-[--text-primary]">
- Switch to {isAnnual() ? "monthly" : "annually"}
- </span>
- <button
- type="button"
- role="switch"
- aria-checked={isAnnual()}
- data-state={isAnnual() ? "unchecked" : "checked"}
- value={isAnnual() ? "on" : "off"}
- class="peer inline-flex h-4 w-8 shrink-0
- cursor-pointer items-center rounded-full border-2 border-transparent
- dark:bg-[#3F75E0]
- transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2
- focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 bg-[--blue-400]"
- onClick={togglePricing}
- >
- <span
- data-state={isAnnual() ? "unchecked" : "checked"}
- class={`pointer-events-none block h-4 w-4 rounded-full dark:bg-gray-500
- bg-gray-50 shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4
- data-[state=unchecked]:translate-x-0 border-2 ${
+ </div>
+ ) : (
+ <>
+ <div class="text-center">
+ <h1 class="text-4xl md:text-4xl mb-3 tracking-[-.05em] font-medium text-[--text-primary]">
+ Early Adopter Pricing
+ </h1>
+ </div>
+ <div class="flex gap-4 w-full">
+ <div class="flex-grow p-3 bg-gray-200 rounded-xl border shadow-sm text-card-foreground md:p-3 border-gray-300/20">
+ <div class="space-y-3">
+ <div class="flex flex-col space-y-1.5 pt-6 px-6">
+ <h3 class="text-2xl font-medium tracking-tight text-[--text-primary]">
+ Commercial License
+ </h3>
+ <p class="text-[0.875rem] leading-[1.25rem] text-[--text-primary]">
+ For professional use without cloud features.
+ </p>
+ <div>
+ <div class="flex items-center space-x-3">
+ <h3 class="text-4xl text-[--text-primary]">
+ {isCommercialAnnual() ? "$29" : "$58"}
+ </h3>
+ <div>
+ {isCommercialAnnual() && (
+ <p class="text-sm font-medium text-[--text-primary]">
+ billed annually
+ </p>
+ )}
+ {!isCommercialAnnual() && (
+ <p class="text-sm font-medium text-[--text-primary]">
+ one-time payment
+ </p>
+ )}
+ {isCommercialAnnual() && (
+ <p class="text-sm text-[--text-primary]">
+ or, $58 one-time payment.
+ </p>
+ )}
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="px-3 md:px-8">
+ <div class="flex items-center pt-4 pb-1 mt-3 border-t-2 border-[--black-transparent-20]">
+ <span class="mr-2 text-xs text-[--text-primary]">
+ Switch to{" "}
+ {isCommercialAnnual() ? "lifetime" : "yearly"}
+ </span>
+ <button
+ type="button"
+ role="switch"
+ aria-checked={!isCommercialAnnual()}
+ data-state={
+ isCommercialAnnual() ? "unchecked" : "checked"
+ }
+ value={!isCommercialAnnual() ? "on" : "off"}
+ class="peer inline-flex h-4 w-8 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent bg-[--gray-400] transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50"
+ onClick={toggleCommercialPricing}
+ >
+ <span
+ data-state={
+ isCommercialAnnual() ? "unchecked" : "checked"
+ }
+ class={`pointer-events-none block h-4 w-4 rounded-full bg-gray-50 shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0 border-2 ${
+ !isCommercialAnnual()
+ ? "border-gray-400"
+ : "border-gray-300"
+ }`}
+ />
+ </button>
+ </div>
+ </div>
+ <div class="px-6 pt-0 pb-4">
+ <button
+ onClick={() => openCommercialCheckout.mutate()}
+ disabled={openCommercialCheckout.isPending}
+ class="flex items-center justify-center transition-opacity duration-200 rounded-full bg-[--gray-500] hover:opacity-90 disabled:bg-[--gray-400] font-medium text-lg px-6 h-12 w-full no-underline text-gray-50"
+ >
+ {openCommercialCheckout.isPending
+ ? "Loading..."
+ : "Purchase License"}
+ </button>
+ </div>
+ <div class="px-6 pt-0">
+ <p class="text-[--text-primary] text-sm mb-2">
+ Already have a license key?
+ </p>
+ <div class="h-[76px]">
+ <Input
+ placeholder="Enter license key"
+ value={licenseKey()}
+ onInput={(e) => setLicenseKey(e.currentTarget.value)}
+ />
+ <Button
+ class="mt-2 w-full relative"
+ disabled={activateLicenseKey.isPending}
+ onClick={() =>
+ activateLicenseKey.mutate({
+ licenseKey: licenseKey(),
+ })
+ }
+ >
+ <div class="w-full flex justify-center">
+ Activate License
+ </div>
+ </Button>
+ </div>
+ </div>
+ <div class="flex items-center px-6 pt-0 pb-6">
+ <div class="space-y-6">
+ <div>
+ <ul class="p-0 space-y-3 list-none">
+ {[
+ "Commercial Use of Cap Recorder + Editor",
+ "Community Support",
+ "Local-only features",
+ "Perpetual license option",
+ ].map((feature) => (
+ <li class="flex justify-start items-center">
+ <div class="w-6 h-6 m-0 p-0 flex items-center border-[2px] border-[--gray-500] justify-center rounded-full">
+ <IconLucideCheck class="w-4 h-4 text-[--text-primary]" />
+ </div>
+ <span class="ml-2 text-[0.9rem] text-[--text-primary]">
+ {feature}
+ </span>
+ </li>
+ ))}
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="flex-grow p-3 bg-blue-300 rounded-xl border shadow-sm text-card-foreground md:p-3 border-blue-500/20">
+ <div class="space-y-3">
+ <div class="flex flex-col space-y-1.5 pt-6 px-6">
+ <h3 class="text-2xl font-medium tracking-tight text-gray-50 dark:text-[--text-primary]">
+ Cap Pro
+ </h3>
+ <p class="text-[0.875rem] leading-[1.25rem] text-gray-50 dark:text-[--text-primary]">
+ For professional use and teams.
+ </p>
+ <div>
+ <div class="flex items-center space-x-3">
+ <h3 class="text-4xl text-gray-50 dark:text-[--text-primary]">
+ {isAnnual() ? "$6/mo" : "$9/mo"}
+ </h3>
+ <div>
+ <p class="text-sm font-medium text-gray-50 dark:text-[--text-primary]">
+ {isAnnual()
+ ? "per user, billed annually."
+ : "per user, billed monthly."}
+ </p>
+ {isAnnual() && (
+ <p class="text-sm text-gray-50 dark:text-[--text-primary]">
+ or, $9/month, billed monthly.
+ </p>
+ )}
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="px-3 mt-3 md:px-8">
+ <div class="flex items-center pt-4 pb-1 mt-3 border-t-2 border-[--white-transparent-20] dark:border-[--black-transparent-20]">
+ <span class="mr-2 text-xs text-gray-50 dark:text-[--text-primary]">
+ Switch to {isAnnual() ? "monthly" : "annually"}
+ </span>
+ <button
+ type="button"
+ role="switch"
+ aria-checked={isAnnual()}
+ data-state={isAnnual() ? "unchecked" : "checked"}
+ value={isAnnual() ? "on" : "off"}
+ class="peer inline-flex h-4 w-8 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent dark:bg-[#3F75E0] transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 bg-[--blue-400]"
+ onClick={togglePricing}
+ >
+ <span
+ data-state={isAnnual() ? "unchecked" : "checked"}
+ class={`pointer-events-none block h-4 w-4 rounded-full dark:bg-gray-500 bg-gray-50 shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0 border-2 ${
isAnnual()
? "border-blue-400 dark:border-[#3F75E0]"
: "border-gray-300 dark:border-[--white-transparent-20]"
}`}
- />
- </button>
- </div>
- </div>
- <div class="px-6 pt-0 pb-4">
- <button
- onClick={openCheckoutInExternalBrowser}
- class="flex items-center justify-center hover:opacity-90 transition-opacity duration-200 rounded-full bg-[--gray-50] dark:bg-[--gray-500] hover:bg-[--gray-200] disabled:bg-[--gray-100]
- font-medium text-lg px-6 h-12 w-full no-underline text-gray-500 dark:text-gray-50"
- disabled={loading()}
- >
- {loading() ? "Loading..." : "Upgrade to Cap Pro"}
- </button>
- </div>
- <div class="flex items-center px-6 pt-0 pb-6">
- <div class="space-y-6">
- <div>
- <ul class="p-0 space-y-3 list-none">
- {proFeatures.map((feature) => (
- <li class="flex justify-start items-center">
- <div class="w-6 h-6 m-0 p-0 flex items-center border-[2px] border-[--gray-50] dark:border-[--gray-500] justify-center rounded-full">
- <IconLucideCheck class="w-4 h-4 text-gray-50 dark:text-[--text-primary]" />
- </div>
- <span class="ml-2 text-[0.9rem] text-gray-50 dark:text-[--text-primary]">
- {feature}
- </span>
- </li>
- ))}
- </ul>
+ />
+ </button>
+ </div>
+ </div>
+ <div class="px-6 pt-0 pb-4">
+ <button
+ onClick={openCheckoutInExternalBrowser}
+ class="flex items-center justify-center hover:opacity-90 transition-opacity duration-200 rounded-full bg-[--gray-50] dark:bg-[--gray-500] hover:bg-[--gray-200] disabled:bg-[--gray-100] font-medium text-lg px-6 h-12 w-full no-underline text-gray-500 dark:text-gray-50"
+ disabled={loading()}
+ >
+ {loading() ? "Loading..." : "Upgrade to Cap Pro"}
+ </button>
+ </div>
+ <div class="flex items-center px-6 pt-0 pb-6">
+ <div class="space-y-6">
+ <div>
+ <ul class="p-0 space-y-3 list-none">
+ {proFeatures.map((feature) => (
+ <li class="flex justify-start items-center">
+ <div class="w-6 h-6 m-0 p-0 flex items-center border-[2px] border-[--gray-50] dark:border-[--gray-500] justify-center rounded-full">
+ <IconLucideCheck class="w-4 h-4 text-gray-50 dark:text-[--text-primary]" />
+ </div>
+ <span class="ml-2 text-[0.9rem] text-gray-50 dark:text-[--text-primary]">
+ {feature}
+ </span>
+ </li>
+ ))}
+ </ul>
+ </div>
+ </div>
+ </div>
</div>
</div>
</div>
- </div>
- </div>
+ </>
+ )}
</>
)}
</div>
diff --git a/apps/desktop/src/routes/editor/Header.tsx b/apps/desktop/src/routes/editor/Header.tsx
index ded7bf021..de2ed933f 100644
--- a/apps/desktop/src/routes/editor/Header.tsx
+++ b/apps/desktop/src/routes/editor/Header.tsx
@@ -9,6 +9,8 @@ import {
createSignal,
onCleanup,
onMount,
+ ErrorBoundary,
+ Suspense,
} from "solid-js";
import { type as ostype } from "@tauri-apps/plugin-os";
import { Tooltip } from "@kobalte/core";
@@ -34,6 +36,7 @@ import {
import Titlebar from "~/components/titlebar/Titlebar";
import { initializeTitlebar, setTitlebar } from "~/utils/titlebar-state";
import { Channel } from "@tauri-apps/api/core";
+import { createLicenseQuery } from "~/utils/queries";
type ResolutionOption = {
label: string;
@@ -61,6 +64,7 @@ export interface ExportEstimates {
export function Header() {
const currentWindow = getCurrentWindow();
+ const license = createLicenseQuery();
const [selectedFps, setSelectedFps] = createSignal(
Number(localStorage.getItem("cap-export-fps")) || 30
@@ -93,11 +97,10 @@ export function Header() {
<div
data-tauri-drag-region
class={cx(
- "flex flex-row justify-between items-center w-full cursor-default pr-5",
+ "flex flex-row justify-end items-center w-full cursor-default pr-5",
ostype() === "windows" ? "pl-[4.3rem]" : "pl-[1.25rem]"
)}
>
- <div class="flex flex-row items-center gap-[0.5rem] text-[0.875rem]"></div>
<div class="flex flex-row gap-2 font-medium items-center">
<ShareButton
selectedResolution={selectedResolution}
@@ -114,7 +117,35 @@ export function Header() {
);
});
- return <Titlebar />;
+ return (
+ <div class="relative">
+ <div class="absolute left-[6rem] top-[1.25rem] z-10">
+ <ErrorBoundary fallback={<></>}>
+ <Suspense>
+ <span
+ onClick={async () => {
+ if (license.data?.type !== "pro") {
+ await commands.showWindow("Upgrade");
+ }
+ }}
+ class={`text-[0.85rem] ${
+ license.data?.type === "pro"
+ ? "bg-[--blue-400] text-gray-50 dark:text-gray-500"
+ : "bg-gray-200 cursor-pointer hover:bg-gray-300"
+ } rounded-lg px-1.5 py-0.5`}
+ >
+ {license.data?.type === "commercial"
+ ? "Commercial License"
+ : license.data?.type === "pro"
+ ? "Pro"
+ : "Personal License"}
+ </span>
+ </Suspense>
+ </ErrorBoundary>
+ </div>
+ <Titlebar />
+ </div>
+ );
}
function ExportButton(props: {
diff --git a/packages/utils/src/helpers.ts b/packages/utils/src/helpers.ts
index 8f43c3cdd..111f2af4a 100644
--- a/packages/utils/src/helpers.ts
+++ b/packages/utils/src/helpers.ts
@@ -14,8 +14,8 @@ export const uuidFormat = (uuid: string) => {
};
export const CAP_LOGO_URL =
- "https://raw.githubusercontent.com/CapSoftware/cap/main/app-icon.png";
-
+ "https://raw.githubusercontent.com/CapSoftware/cap/main/apps/desktop/src-tauri/icons/Square310x310Logo.png";
+
export const saveLatestVideoId = (videoId: string) => {
try {
if (typeof navigator !== "undefined" && typeof window !== "undefined") {