Request details, Drive folders, image folders, clip tool to Drive (v1.9.12 to v1.9.14-content-display) #16
2 changed files with 29 additions and 4 deletions
|
|
@ -51,6 +51,26 @@ export function OptionalTag() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* On a field the send button waits for. */
|
||||||
|
export function RequiredTag() {
|
||||||
|
return (
|
||||||
|
<span className="ml-2 rounded-full bg-danger-tint px-2 py-0.5 text-xs font-medium text-danger">
|
||||||
|
Required
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Under a message box: how many more characters it needs, until it
|
||||||
|
has them (the send button stays off until then). */
|
||||||
|
export function MinimumNote({ length, min }: { length: number; min: number }) {
|
||||||
|
if (length >= min) return null;
|
||||||
|
return (
|
||||||
|
<span className="text-xs" style={{ color: MUTED }}>
|
||||||
|
{length === 0 ? `At least ${min} characters` : `${min - length} more character${min - length === 1 ? "" : "s"} needed`}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
export function FieldError({ id, children }) {
|
export function FieldError({ id, children }) {
|
||||||
if (!children) return null;
|
if (!children) return null;
|
||||||
return (
|
return (
|
||||||
|
|
@ -356,6 +376,7 @@ export default function FeedbackForm({ fixedType }: { fixedType?: string } = {})
|
||||||
className="text-base font-semibold text-body"
|
className="text-base font-semibold text-body"
|
||||||
>
|
>
|
||||||
{request ? "Your request" : "Tell us more"}
|
{request ? "Your request" : "Tell us more"}
|
||||||
|
<RequiredTag />
|
||||||
</label>
|
</label>
|
||||||
<p className="mt-1 text-sm" style={{ color: MUTED }}>
|
<p className="mt-1 text-sm" style={{ color: MUTED }}>
|
||||||
{request
|
{request
|
||||||
|
|
@ -381,6 +402,7 @@ export default function FeedbackForm({ fixedType }: { fixedType?: string } = {})
|
||||||
/>
|
/>
|
||||||
<div className="mt-2 flex items-start justify-between gap-4">
|
<div className="mt-2 flex items-start justify-between gap-4">
|
||||||
<FieldError id="feedback-message-error">{fieldErrors.message}</FieldError>
|
<FieldError id="feedback-message-error">{fieldErrors.message}</FieldError>
|
||||||
|
{!fieldErrors.message && <MinimumNote length={message.trim().length} min={MIN_MESSAGE} />}
|
||||||
<span
|
<span
|
||||||
className="ml-auto shrink-0 text-xs tabular-nums"
|
className="ml-auto shrink-0 text-xs tabular-nums"
|
||||||
style={{ color: MUTED }}
|
style={{ color: MUTED }}
|
||||||
|
|
@ -482,8 +504,8 @@ export default function FeedbackForm({ fixedType }: { fixedType?: string } = {})
|
||||||
{!ready && !sending && (
|
{!ready && !sending && (
|
||||||
<p className="text-sm" style={{ color: MUTED }}>
|
<p className="text-sm" style={{ color: MUTED }}>
|
||||||
{request
|
{request
|
||||||
? "Write at least a sentence and give an email address to send."
|
? `Write at least ${MIN_MESSAGE} characters and give an email address to send.`
|
||||||
: "Choose a type and write at least a sentence to send."}
|
: `Choose a type and write at least ${MIN_MESSAGE} characters to send.`}
|
||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ import { ApiError, upload } from "../../lib/api.ts";
|
||||||
import { accentText, BRAND } from "../../lib/color.ts";
|
import { accentText, BRAND } from "../../lib/color.ts";
|
||||||
import { REQUEST_FILES } from "../../lib/site.ts";
|
import { REQUEST_FILES } from "../../lib/site.ts";
|
||||||
import { REQUEST_TYPES, type RequestAction } from "../../data/requestTypes.ts";
|
import { REQUEST_TYPES, type RequestAction } from "../../data/requestTypes.ts";
|
||||||
import { FieldError, OptionalTag, TilePicker, errorFieldClass, fieldClass } from "./FeedbackForm.tsx";
|
import { FieldError, MinimumNote, OptionalTag, RequiredTag, TilePicker, errorFieldClass, fieldClass } from "./FeedbackForm.tsx";
|
||||||
|
|
||||||
const MUTED = "var(--color-muted)";
|
const MUTED = "var(--color-muted)";
|
||||||
const MAX_CHARS = 5000;
|
const MAX_CHARS = 5000;
|
||||||
|
|
@ -206,6 +206,7 @@ export default function RequestForm() {
|
||||||
<div className="mt-8">
|
<div className="mt-8">
|
||||||
<label htmlFor="request-subject" className="text-base font-semibold text-body">
|
<label htmlFor="request-subject" className="text-base font-semibold text-body">
|
||||||
{action === "update" && type.actions.length > 1 ? `Which ${type.label.toLowerCase()}?` : type.subject}
|
{action === "update" && type.actions.length > 1 ? `Which ${type.label.toLowerCase()}?` : type.subject}
|
||||||
|
<RequiredTag />
|
||||||
</label>
|
</label>
|
||||||
<input
|
<input
|
||||||
id="request-subject"
|
id="request-subject"
|
||||||
|
|
@ -262,6 +263,7 @@ export default function RequestForm() {
|
||||||
<div className="mt-8">
|
<div className="mt-8">
|
||||||
<label htmlFor="request-message" className="text-base font-semibold text-body">
|
<label htmlFor="request-message" className="text-base font-semibold text-body">
|
||||||
{action === "update" ? "What should change?" : "Tell us about it"}
|
{action === "update" ? "What should change?" : "Tell us about it"}
|
||||||
|
<RequiredTag />
|
||||||
</label>
|
</label>
|
||||||
<textarea
|
<textarea
|
||||||
id="request-message"
|
id="request-message"
|
||||||
|
|
@ -280,6 +282,7 @@ export default function RequestForm() {
|
||||||
/>
|
/>
|
||||||
<div className="mt-2 flex items-start justify-between gap-4">
|
<div className="mt-2 flex items-start justify-between gap-4">
|
||||||
<FieldError id="request-message-error">{fieldErrors.message}</FieldError>
|
<FieldError id="request-message-error">{fieldErrors.message}</FieldError>
|
||||||
|
{!fieldErrors.message && <MinimumNote length={message.trim().length} min={MIN_MESSAGE} />}
|
||||||
<span className="ml-auto shrink-0 text-xs tabular-nums" style={{ color: MUTED }}>
|
<span className="ml-auto shrink-0 text-xs tabular-nums" style={{ color: MUTED }}>
|
||||||
{message.length} / {MAX_CHARS}
|
{message.length} / {MAX_CHARS}
|
||||||
</span>
|
</span>
|
||||||
|
|
@ -382,7 +385,7 @@ export default function RequestForm() {
|
||||||
</button>
|
</button>
|
||||||
{!ready && !sending && (
|
{!ready && !sending && (
|
||||||
<p className="text-sm" style={{ color: MUTED }}>
|
<p className="text-sm" style={{ color: MUTED }}>
|
||||||
Choose what it's about, give it a name, write at least a sentence and give an email address to send.
|
Choose what it's about, give it a name, write at least {MIN_MESSAGE} characters and give an email address to send.
|
||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue