-
Notifications
You must be signed in to change notification settings - Fork 7
Hosting signup: free self-host branch with a downloadable deployment bundle #1466
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
103 changes: 103 additions & 0 deletions
103
apps/web/src/features/hosting-signup/destination-picker.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| "use client"; | ||
|
|
||
| import { type ChangeEvent } from "react"; | ||
| import i18next from "i18next"; | ||
| import { FormControl } from "@ui/input"; | ||
| import { normalizeDomain } from "./self-host-bundle"; | ||
|
|
||
| export type HostingDestination = "managed" | "self-host"; | ||
|
|
||
| interface Props { | ||
| value: HostingDestination; | ||
| onChange: (value: HostingDestination) => void; | ||
| /** Where the owner will serve an independent deployment, if they know yet. */ | ||
| domain: string; | ||
| onDomainChange: (value: string) => void; | ||
| disabled?: boolean; | ||
| } | ||
|
|
||
| const OPTIONS: { | ||
| id: HostingDestination; | ||
| titleKey: string; | ||
| bodyKey: string; | ||
| }[] = [ | ||
| { | ||
| id: "managed", | ||
| titleKey: "hosting.destination-managed", | ||
| bodyKey: "hosting.destination-managed-hint" | ||
| }, | ||
| { | ||
| id: "self-host", | ||
| titleKey: "hosting.destination-self", | ||
| bodyKey: "hosting.destination-self-hint" | ||
| } | ||
| ]; | ||
|
|
||
| /** | ||
| * Where the blog someone just customized will actually live: on Ecency's | ||
| * hosting, or on their own server. The self-host branch is free and creates | ||
| * nothing, so this choice sits INSIDE the customize step rather than after | ||
| * it: the reader sees both routes while they are still deciding, and the | ||
| * flow does not grow a click for the paid path everyone else takes. | ||
| */ | ||
| export function DestinationPicker({ | ||
| value, | ||
| onChange, | ||
| domain, | ||
| onDomainChange, | ||
| disabled | ||
| }: Props) { | ||
| // Typed but unusable input gets said out loud rather than silently | ||
| // dropped: the bundle falls back to the placeholder domain, and someone | ||
| // who typed something deserves to know their value was not used. | ||
| const invalidDomain = domain.trim().length > 0 && normalizeDomain(domain) === null; | ||
|
|
||
| return ( | ||
| <div className="flex flex-col gap-2"> | ||
| <div role="radiogroup" aria-label={i18next.t("hosting.destination-label")} className="grid sm:grid-cols-2 gap-2"> | ||
| {OPTIONS.map((option) => { | ||
| const selected = value === option.id; | ||
| return ( | ||
| <button | ||
| key={option.id} | ||
| type="button" | ||
| role="radio" | ||
| aria-checked={selected} | ||
| disabled={disabled} | ||
| onClick={() => onChange(option.id)} | ||
| className={`text-left rounded-2xl border p-3 transition-colors disabled:opacity-50 ${ | ||
| selected | ||
| ? "border-blue-dark-sky bg-blue-dark-sky-030" | ||
| : "border-[--border-color] hover:border-blue-dark-sky" | ||
| }`} | ||
| > | ||
| <div className="text-sm font-semibold">{i18next.t(option.titleKey)}</div> | ||
| <div className="text-xs opacity-75 mt-1">{i18next.t(option.bodyKey)}</div> | ||
| </button> | ||
| ); | ||
| })} | ||
| </div> | ||
|
|
||
| {value === "self-host" && ( | ||
| <div className="flex flex-col gap-1"> | ||
| <label className="text-sm font-semibold" htmlFor="self-host-domain"> | ||
| {i18next.t("hosting.self-host-domain-label")} | ||
| </label> | ||
| <FormControl | ||
| id="self-host-domain" | ||
| type="text" | ||
| value={domain} | ||
| disabled={disabled} | ||
| onChange={(e: ChangeEvent<HTMLInputElement>) => onDomainChange(e.target.value)} | ||
| placeholder={i18next.t("hosting.self-host-domain-placeholder")} | ||
| /> | ||
| {invalidDomain ? ( | ||
| <p className="text-xs text-red">{i18next.t("hosting.self-host-domain-invalid")}</p> | ||
| ) : ( | ||
| <p className="text-xs opacity-60">{i18next.t("hosting.self-host-domain-hint")}</p> | ||
| )} | ||
| </div> | ||
| )} | ||
| </div> | ||
| ); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.