Skip setup questions on the template path and collect name, photo, and description without recommendations.
Customize opens a dialog then walks the template decks; Use without changes lands on final review with Has Name Field. Template cards stay first, the engine is not called, and the catalog no longer shows a recommended tag.
This commit is contained in:
1 parent
53d236d0d5
commit
6498d52541
37 files changed
+1450
-733
No files matched your search
@@ -52,6 +52,17 @@ const RuleContainer = memo<RuleProps>(
|
||||
fluidWidth = false,
|
||||
descriptionAtBottom = false,
|
||||
surfaceColor,
|
||||
hasNameField = false,
|
||||
nameValue,
|
||||
nameLabel,
|
||||
namePlaceholder,
|
||||
onNameChange,
|
||||
descriptionLabel,
|
||||
descriptionPlaceholder,
|
||||
descriptionHelperText,
|
||||
onDescriptionChange,
|
||||
onLogoClick,
|
||||
logoUploadAriaLabel,
|
||||
}) => {
|
||||
const size = sizeProp ?? "L";
|
||||
const isInteractive = interactive ?? !hasBottomLinks;
|
||||
@@ -123,6 +134,17 @@ const RuleContainer = memo<RuleProps>(
|
||||
surfaceColor={surfaceColor}
|
||||
cardAriaLabel={cardAriaLabel}
|
||||
recommendedLabel={recommendedLabel}
|
||||
hasNameField={hasNameField}
|
||||
nameValue={nameValue}
|
||||
nameLabel={nameLabel}
|
||||
namePlaceholder={namePlaceholder}
|
||||
onNameChange={onNameChange}
|
||||
descriptionLabel={descriptionLabel}
|
||||
descriptionPlaceholder={descriptionPlaceholder}
|
||||
descriptionHelperText={descriptionHelperText}
|
||||
onDescriptionChange={onDescriptionChange}
|
||||
onLogoClick={onLogoClick}
|
||||
logoUploadAriaLabel={logoUploadAriaLabel}
|
||||
/>
|
||||
);
|
||||
},
|
||||
|
||||
@@ -103,6 +103,21 @@ export interface RuleProps {
|
||||
* {@link backgroundColor}.
|
||||
*/
|
||||
surfaceColor?: string;
|
||||
/**
|
||||
* Figma Has Name Field: inline community name, optional logo upload, and
|
||||
* labeled description. Used on the template-path final review.
|
||||
*/
|
||||
hasNameField?: boolean;
|
||||
nameValue?: string;
|
||||
nameLabel?: string;
|
||||
namePlaceholder?: string;
|
||||
onNameChange?: (_value: string) => void;
|
||||
descriptionLabel?: string;
|
||||
descriptionPlaceholder?: string;
|
||||
descriptionHelperText?: string;
|
||||
onDescriptionChange?: (_value: string) => void;
|
||||
onLogoClick?: () => void;
|
||||
logoUploadAriaLabel?: string;
|
||||
}
|
||||
|
||||
export interface RuleViewProps {
|
||||
@@ -138,4 +153,15 @@ export interface RuleViewProps {
|
||||
/** Interactive card aria-label; supplied by the container from `ruleCard` messages. */
|
||||
cardAriaLabel: string;
|
||||
recommendedLabel: string;
|
||||
hasNameField?: boolean;
|
||||
nameValue?: string;
|
||||
nameLabel?: string;
|
||||
namePlaceholder?: string;
|
||||
onNameChange?: (_value: string) => void;
|
||||
descriptionLabel?: string;
|
||||
descriptionPlaceholder?: string;
|
||||
descriptionHelperText?: string;
|
||||
onDescriptionChange?: (_value: string) => void;
|
||||
onLogoClick?: () => void;
|
||||
logoUploadAriaLabel?: string;
|
||||
}
|
||||
@@ -4,8 +4,11 @@ import Image from "next/image";
|
||||
import NextLink from "next/link";
|
||||
import MultiSelect from "../../controls/MultiSelect";
|
||||
import InlineTextButton from "../../buttons/InlineTextButton";
|
||||
import TextInput from "../../controls/TextInput";
|
||||
import TextArea from "../../controls/TextArea";
|
||||
import NavigationLink from "../../navigation/Link";
|
||||
import Tag from "../../utility/Tag";
|
||||
import InputLabel from "../../type/InputLabel";
|
||||
import type { RuleBottomLink, RuleViewProps } from "./Rule.types";
|
||||
|
||||
export function RuleView({
|
||||
@@ -40,6 +43,17 @@ export function RuleView({
|
||||
surfaceColor,
|
||||
cardAriaLabel,
|
||||
recommendedLabel,
|
||||
hasNameField = false,
|
||||
nameValue = "",
|
||||
nameLabel,
|
||||
namePlaceholder,
|
||||
onNameChange,
|
||||
descriptionLabel,
|
||||
descriptionPlaceholder,
|
||||
descriptionHelperText,
|
||||
onDescriptionChange,
|
||||
onLogoClick,
|
||||
logoUploadAriaLabel,
|
||||
}: RuleViewProps) {
|
||||
const ariaLabel = cardAriaLabel;
|
||||
const interactiveCard = interactive ?? !hasBottomLinks;
|
||||
@@ -229,9 +243,39 @@ export function RuleView({
|
||||
);
|
||||
}
|
||||
|
||||
if (hasNameField) {
|
||||
return (
|
||||
<span
|
||||
className={`${logoContainerClass} flex items-center justify-center rounded-full border border-dashed border-[var(--color-content-invert-primary)] text-[24px] leading-none text-[var(--color-content-invert-primary)]`}
|
||||
aria-hidden={onLogoClick ? true : undefined}
|
||||
>
|
||||
+
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
const renderLogoControl = () => {
|
||||
const inner = renderLogo();
|
||||
if (!inner) return null;
|
||||
if (!onLogoClick) return inner;
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
className="cursor-pointer rounded-full p-0"
|
||||
aria-label={logoUploadAriaLabel}
|
||||
onClick={(event) => {
|
||||
event.stopPropagation();
|
||||
onLogoClick();
|
||||
}}
|
||||
>
|
||||
{inner}
|
||||
</button>
|
||||
);
|
||||
};
|
||||
|
||||
// Border radius - use CSS classes if provided via className, otherwise use size-based logic
|
||||
const borderRadiusClass = className?.includes("rounded-")
|
||||
? "" // If className already has border radius, don't add size-based one
|
||||
@@ -291,12 +335,36 @@ export function RuleView({
|
||||
.join(" ");
|
||||
|
||||
const showExpandedDescription = Boolean(
|
||||
hasNameField ||
|
||||
description ||
|
||||
(onDescriptionClick && typeof descriptionEmptyHint === "string"),
|
||||
);
|
||||
const expandedDescription = showExpandedDescription ? (
|
||||
<div className={expandedDescriptionFrameClass}>
|
||||
{onDescriptionClick ? (
|
||||
{hasNameField && onDescriptionChange ? (
|
||||
<div
|
||||
className="flex w-full min-w-0 flex-col gap-[6px]"
|
||||
data-testid="rule-description-field"
|
||||
onClick={(event) => event.stopPropagation()}
|
||||
>
|
||||
<InputLabel
|
||||
label={descriptionLabel ?? ""}
|
||||
helpIcon={false}
|
||||
helperText={descriptionHelperText}
|
||||
size="s"
|
||||
/>
|
||||
<TextArea
|
||||
label={descriptionLabel}
|
||||
placeholder={descriptionPlaceholder}
|
||||
value={description ?? ""}
|
||||
onChange={(event) => onDescriptionChange(event.target.value)}
|
||||
size="small"
|
||||
formHeader={false}
|
||||
showHelpIcon={false}
|
||||
rows={2}
|
||||
/>
|
||||
</div>
|
||||
) : onDescriptionClick ? (
|
||||
<InlineTextButton
|
||||
type="button"
|
||||
underline={false}
|
||||
@@ -333,12 +401,12 @@ export function RuleView({
|
||||
w-full shrink-0 items-center gap-px
|
||||
"
|
||||
>
|
||||
{renderLogo() && (
|
||||
{(renderLogoControl() || hasNameField) && (
|
||||
<div className={headerIconCellClass}>
|
||||
{renderLogo()}
|
||||
{renderLogoControl()}
|
||||
</div>
|
||||
)}
|
||||
{title && (
|
||||
{(title || hasNameField) && (
|
||||
<div
|
||||
className={`
|
||||
flex min-w-0 flex-1 flex-col justify-center
|
||||
@@ -365,7 +433,31 @@ export function RuleView({
|
||||
{recommendedLabel}
|
||||
</Tag>
|
||||
) : null}
|
||||
{onTitleClick ? (
|
||||
{hasNameField && onNameChange ? (
|
||||
<div
|
||||
className="flex w-full min-w-0 flex-col gap-[6px]"
|
||||
data-testid="rule-name-field"
|
||||
onClick={(event) => event.stopPropagation()}
|
||||
>
|
||||
<InputLabel
|
||||
label={nameLabel ?? ""}
|
||||
helpIcon={false}
|
||||
asterisk
|
||||
size="s"
|
||||
/>
|
||||
<TextInput
|
||||
label={nameLabel}
|
||||
placeholder={namePlaceholder}
|
||||
value={nameValue}
|
||||
onChange={(event) => onNameChange(event.target.value)}
|
||||
inputSize="small"
|
||||
formHeader={false}
|
||||
showHelpIcon={false}
|
||||
required
|
||||
autoFocus={nameValue.trim().length === 0}
|
||||
/>
|
||||
</div>
|
||||
) : onTitleClick ? (
|
||||
<InlineTextButton
|
||||
type="button"
|
||||
underline={false}
|
||||
|
||||
Reference in new issue
Block a user