tangled
alpha
login
or
join now
leaflet.pub
/
leaflet
289
fork
atom
a tool for shared writing and social publishing
289
fork
atom
overview
issues
27
pulls
pipelines
little styling to the create pub form
cozylittle.house
9 months ago
0342e797
9af6ece6
+44
-22
1 changed file
expand all
collapse all
unified
split
app
lish
createPub
CreatePubForm.tsx
+44
-22
app/lish/createPub/CreatePubForm.tsx
···
8
8
import { useRouter } from "next/navigation";
9
9
import { useState, useRef, useEffect } from "react";
10
10
import { useDebouncedEffect } from "src/hooks/useDebouncedEffect";
11
11
+
import { set } from "colorjs.io/fn";
12
12
+
import { theme } from "tailwind.config";
11
13
12
14
export const CreatePubForm = () => {
13
15
let [nameValue, setNameValue] = useState("");
···
38
40
<div className="flex flex-col items-center mb-4 gap-2">
39
41
<div className="text-center text-secondary flex flex-col ">
40
42
<h3 className="-mb-1">Logo</h3>
41
41
-
<h3>(optional)</h3>
43
43
+
<p className="italic text-tertiary">(optional)</p>
42
44
</div>
43
45
<div
44
46
className="w-24 h-24 rounded-full border-2 border-dotted border-accent-1 flex items-center justify-center cursor-pointer hover:border-accent-contrast"
···
82
84
}}
83
85
/>
84
86
85
85
-
<DomainInput domain={domainValue} setDomain={setDomainValue} />
86
86
-
87
87
<InputWithLabel
88
88
label="Description (optional)"
89
89
textarea
···
94
94
setDescriptionValue(e.currentTarget.value);
95
95
}}
96
96
/>
97
97
+
<DomainInput domain={domainValue} setDomain={setDomainValue} />
97
98
98
99
<div className="flex w-full justify-center">
99
100
<ButtonPrimary type="submit">Create Publication!</ButtonPrimary>
···
106
107
domain: string;
107
108
setDomain: (d: string) => void;
108
109
}) {
109
109
-
let [state, setState] = useState<"normal" | "valid" | "invalid">("normal");
110
110
+
let [state, setState] = useState<"empty" | "valid" | "invalid" | "pending">(
111
111
+
"empty",
112
112
+
);
110
113
useEffect(() => {
111
111
-
setState("normal");
114
114
+
if (!props.domain) {
115
115
+
setState("empty");
116
116
+
} else {
117
117
+
setState("pending");
118
118
+
}
112
119
}, [props.domain]);
113
120
useDebouncedEffect(
114
121
async () => {
115
115
-
if (!props.domain) return setState("normal");
122
122
+
if (!props.domain) return setState("empty");
116
123
let status = await callRPC("get_leaflet_subdomain_status", {
117
124
domain: props.domain,
118
125
});
···
124
131
[props.domain],
125
132
);
126
133
return (
127
127
-
<label className=" input-with-border flex flex-col text-sm text-tertiary font-bold italic leading-tight !py-1 !px-[6px]">
128
128
-
<div>Domain</div>
129
129
-
<div className="flex flex-row items-center">
130
130
-
<Input
131
131
-
placeholder="domain"
132
132
-
className="appearance-none w-full font-normal bg-transparent text-base text-primary focus:outline-0 outline-none"
133
133
-
value={props.domain}
134
134
-
onChange={(e) => props.setDomain(e.currentTarget.value)}
135
135
-
/>
136
136
-
.leaflet.pub
134
134
+
<div className="flex flex-col gap-1">
135
135
+
<label className=" input-with-border flex flex-col text-sm text-tertiary font-bold italic leading-tight !py-1 !px-[6px]">
136
136
+
<div>Domain</div>
137
137
+
<div className="flex flex-row items-center">
138
138
+
<Input
139
139
+
placeholder="domain"
140
140
+
className="appearance-none w-full font-normal bg-transparent text-base text-primary focus:outline-0 outline-none"
141
141
+
value={props.domain}
142
142
+
onChange={(e) => props.setDomain(e.currentTarget.value)}
143
143
+
/>
144
144
+
.leaflet.pub
145
145
+
</div>
146
146
+
</label>
147
147
+
<div
148
148
+
className={"text-sm italic "}
149
149
+
style={{
150
150
+
fontWeight: state === "valid" ? "bold" : "normal",
151
151
+
color:
152
152
+
state === "valid"
153
153
+
? theme.colors["accent-contrast"]
154
154
+
: theme.colors.tertiary,
155
155
+
}}
156
156
+
>
157
157
+
{state === "valid"
158
158
+
? "Available!"
159
159
+
: state === "invalid"
160
160
+
? "Already Taken ):"
161
161
+
: state === "pending"
162
162
+
? "Checking Availability..."
163
163
+
: "Choose a domain!"}
137
164
</div>
138
138
-
{state === "valid"
139
139
-
? "Available!"
140
140
-
: state === "invalid"
141
141
-
? "Unavailable"
142
142
-
: null}
143
143
-
</label>
165
165
+
</div>
144
166
);
145
167
}