Open a finished Rule from its Profile card, and drop it from the browser on Log out.
This commit is contained in:
1 parent
db1599123b
commit
942c7cc9de
17 files changed
+280
-14
No files matched your search
@@ -36,6 +36,7 @@ const RuleContainer = memo<RuleProps>(
|
||||
className = "",
|
||||
onClick,
|
||||
href,
|
||||
ariaLabel: ariaLabelProp,
|
||||
expanded = false,
|
||||
size: sizeProp,
|
||||
categories,
|
||||
@@ -67,7 +68,11 @@ const RuleContainer = memo<RuleProps>(
|
||||
const size = sizeProp ?? "L";
|
||||
const isInteractive = interactive ?? !hasBottomLinks;
|
||||
const t = useTranslation("ruleCard");
|
||||
const cardAriaLabel = t("ariaLabel")?.replace("{title}", title) || title;
|
||||
const trimmedAriaLabel = ariaLabelProp?.trim() ?? "";
|
||||
const cardAriaLabel =
|
||||
trimmedAriaLabel.length > 0
|
||||
? trimmedAriaLabel
|
||||
: t("ariaLabel")?.replace("{title}", title) || title;
|
||||
const recommendedLabel = t("recommendedLabel");
|
||||
|
||||
const handleClick = () => {
|
||||
@@ -111,7 +116,7 @@ const RuleContainer = memo<RuleProps>(
|
||||
icon={icon}
|
||||
backgroundColor={backgroundColor}
|
||||
className={className}
|
||||
href={isInteractive && !hasBottomLinks ? href : undefined}
|
||||
href={href}
|
||||
onClick={isInteractive && !hasBottomLinks ? handleClick : undefined}
|
||||
onKeyDown={
|
||||
isInteractive && !hasBottomLinks && !href ? handleKeyDown : undefined
|
||||
|
||||
@@ -56,9 +56,16 @@ export interface RuleProps {
|
||||
onClick?: () => void;
|
||||
/**
|
||||
* When set, the card is a real link (focusable, Enter, open in a new tab)
|
||||
* instead of a click-only `role="button"` surface.
|
||||
* instead of a click-only `role="button"` surface. Combined with
|
||||
* {@link hasBottomLinks}, the link is a stretched overlay so Invite /
|
||||
* Duplicate / Delete stay separate controls.
|
||||
*/
|
||||
href?: string;
|
||||
/**
|
||||
* Accessible name for the card or its overlay link. Defaults to the
|
||||
* `ruleCard` “Learn more about {title}…” string.
|
||||
*/
|
||||
ariaLabel?: string;
|
||||
expanded?: boolean;
|
||||
size?: RuleSizeValue;
|
||||
categories?: Category[];
|
||||
|
||||
@@ -298,6 +298,7 @@ export function RuleView({
|
||||
<NavigationLink
|
||||
key={link.id}
|
||||
{...shared}
|
||||
className={`${shared.className} pointer-events-auto relative z-10`}
|
||||
href={link.href}
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
/>
|
||||
@@ -307,6 +308,7 @@ export function RuleView({
|
||||
<NavigationLink
|
||||
key={link.id}
|
||||
{...shared}
|
||||
className={`${shared.className} pointer-events-auto relative z-10`}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
link.onClick?.();
|
||||
@@ -319,7 +321,8 @@ export function RuleView({
|
||||
const surfaceStyle = surfaceColor
|
||||
? { backgroundColor: surfaceColor }
|
||||
: undefined;
|
||||
const isLinkCard = Boolean(href) && interactiveCard;
|
||||
const isLinkCard = Boolean(href) && interactiveCard && !hasBottomLinks;
|
||||
const overlayHref = hasBottomLinks && href ? href : undefined;
|
||||
|
||||
const hasCategories = Boolean(categories && categories.length > 0);
|
||||
const expandedDescriptionFrameClass = [
|
||||
@@ -610,6 +613,27 @@ export function RuleView({
|
||||
);
|
||||
}
|
||||
|
||||
if (overlayHref) {
|
||||
return (
|
||||
<div
|
||||
className={`${cardClassName} cursor-pointer`}
|
||||
style={surfaceStyle}
|
||||
role="article"
|
||||
>
|
||||
<NextLink
|
||||
href={overlayHref}
|
||||
className="absolute inset-0 z-0 rounded-[inherit]"
|
||||
aria-label={ariaLabel}
|
||||
/>
|
||||
<div
|
||||
className={`relative z-[1] flex w-full flex-col items-start pointer-events-none ${cardGap}`}
|
||||
>
|
||||
{cardBody}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
className={cardClassName}
|
||||
|
||||
Reference in new issue
Block a user