@betterinternship/components 3.1.3 → 3.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { type ComponentProps, type ReactNode } from "react";
|
|
2
2
|
import type { LucideIcon } from "lucide-react";
|
|
3
3
|
type BannerVariant = "neutral" | "primary" | "warning" | "destructive" | "banner";
|
|
4
|
-
declare function Banner({ icon: Icon, media, visual, visualClassName, title, description, action, actionClassName, variant, compact, className, ...props }: ComponentProps<"div"> & {
|
|
4
|
+
declare function Banner({ icon: Icon, media, visual, visualClassName, title, description, action, actionClassName, variant, compact, className, ...props }: Omit<ComponentProps<"div">, "title"> & {
|
|
5
5
|
/** Accepts a Lucide icon component or any custom React node. */
|
|
6
6
|
icon?: LucideIcon | ReactNode;
|
|
7
7
|
media?: ReactNode;
|
|
8
8
|
visual?: ReactNode;
|
|
9
9
|
visualClassName?: string;
|
|
10
|
+
/** Any node, e.g. an icon inline with the text (not the HTML title attribute). */
|
|
10
11
|
title: ReactNode;
|
|
11
12
|
description?: ReactNode;
|
|
12
13
|
action?: ReactNode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"banner.js","sources":["../../src/components/banner.tsx"],"sourcesContent":["import { isValidElement, type ComponentProps, type ReactNode } from \"react\";\nimport type { LucideIcon } from \"lucide-react\";\nimport { cn } from \"@/utils\";\n\ntype BannerVariant = \"neutral\" | \"primary\" | \"warning\" | \"destructive\" | \"banner\";\n\nconst variantClasses: Record<\n BannerVariant,\n { container: string; icon: string }\n> = {\n banner: {\n container: 'border-secondary-border bg-secondary text-secondary-foreground',\n icon: 'bg-secondary text-secondary-foreground',\n },\n neutral: {\n container: 'border-landing-control bg-background text-landing-nav',\n icon: 'bg-v2-surface-subtle text-landing-nav',\n },\n primary: {\n container:\n \"border-primary/25 bg-primary/[0.035] transition-colors duration-state ease-out-strong hover:bg-primary/[0.06] motion-reduce:transition-none\",\n icon: \"bg-primary/5 text-primary\",\n },\n warning: {\n container:\n \"border-warning/30 bg-warning/10 transition-colors duration-state ease-out-strong hover:bg-warning/15 motion-reduce:transition-none\",\n icon: \"bg-warning/10 text-warning\",\n },\n destructive: {\n container:\n \"border-destructive/30 bg-destructive/5 transition-colors duration-state ease-out-strong hover:bg-destructive/10 motion-reduce:transition-none\",\n icon: \"bg-destructive/10 text-destructive\",\n },\n};\n\nfunction Banner({\n icon: Icon,\n media,\n visual,\n visualClassName,\n title,\n description,\n action,\n actionClassName,\n variant = \"primary\",\n compact = false,\n className,\n ...props\n}: ComponentProps<\"div\"> & {\n /** Accepts a Lucide icon component or any custom React node. */\n icon?: LucideIcon | ReactNode;\n media?: ReactNode;\n visual?: ReactNode;\n visualClassName?: string;\n title: ReactNode;\n description?: ReactNode;\n action?: ReactNode;\n actionClassName?: string;\n variant?: BannerVariant;\n compact?: boolean;\n}) {\n const styles = variantClasses[variant];\n // The icon is optional: without one (or a custom media node) the slot is\n // dropped entirely rather than leaving an empty tinted square.\n const IconComponent = typeof Icon === 'function' || (Icon && typeof Icon === 'object' && !isValidElement(Icon)) ? Icon as LucideIcon : undefined;\n const leadingVisual = visual ?? media;\n const hasIconSlot = Boolean(leadingVisual || Icon);\n\n return (\n <div\n data-slot=\"banner\"\n className={cn(\n \"group/banner flex flex-col rounded-control-lg border\",\n compact\n ? \"items-start gap-3 p-3 sm:flex-row sm:items-start sm:gap-2\"\n : \"gap-4 px-4 py-4 sm:flex-row sm:items-stretch sm:gap-3 sm:px-5\",\n styles.container,\n className,\n )}\n {...props}\n >\n <div\n className={cn(\n \"flex min-w-0 flex-1 items-start gap-3 sm:items-stretch sm:gap-3\",\n compact && \"gap-2 sm:items-start sm:gap-2\",\n )}\n >\n {hasIconSlot && (\n <span\n className={cn(\n \"flex shrink-0 items-center justify-center rounded-control-lg\",\n compact ? \"size-8\" : \"size-10 sm:self-center\",\n styles.icon,\n visualClassName,\n )}\n >\n {leadingVisual ??\n (IconComponent ? (\n <IconComponent\n className={compact ? \"size-4\" : \"size-5\"}\n aria-hidden=\"true\"\n />\n ) : isValidElement(Icon) ? Icon : (Icon as ReactNode))}\n </span>\n )}\n <div\n className={cn(\n \"min-w-0 flex-1\",\n description ? \"space-y-0.5\" : \"flex flex-col justify-center\",\n )}\n >\n <p className={cn(\"text-sm font-medium\", variant === 'banner' ? 'text-secondary-foreground' : 'text-foreground')}>{title}</p>\n {description && (\n <div className={cn(\"text-sm\", variant === 'banner' ? 'text-secondary-foreground' : 'text-muted-foreground')}>{description}</div>\n )}\n </div>\n </div>\n {action && (\n <div\n className={cn(\n \"w-full shrink-0 sm:w-auto sm:self-center\",\n actionClassName,\n )}\n >\n {action}\n </div>\n )}\n </div>\n );\n}\n\nexport { Banner, type BannerVariant };\n"],"names":["_jsxs","_jsx"],"mappings":";;;;AAMA,MAAM,cAAc,GAGhB;AACF,IAAA,MAAM,EAAE;AACN,QAAA,SAAS,EAAE,gEAAgE;AAC3E,QAAA,IAAI,EAAE,wCAAwC;AAC/C,KAAA;AACD,IAAA,OAAO,EAAE;AACP,QAAA,SAAS,EAAE,uDAAuD;AAClE,QAAA,IAAI,EAAE,uCAAuC;AAC9C,KAAA;AACD,IAAA,OAAO,EAAE;AACP,QAAA,SAAS,EACL,6IAA6I;AACjJ,QAAA,IAAI,EAAE,2BAA2B;AAClC,KAAA;AACD,IAAA,OAAO,EAAE;AACP,QAAA,SAAS,EACL,oIAAoI;AACxI,QAAA,IAAI,EAAE,4BAA4B;AACnC,KAAA;AACD,IAAA,WAAW,EAAE;AACX,QAAA,SAAS,EACL,+IAA+I;AACnJ,QAAA,IAAI,EAAE,oCAAoC;AAC3C,KAAA;CACF;AAED,SAAS,MAAM,CAAC,EACd,IAAI,EAAE,IAAI,EACV,KAAK,EACL,MAAM,EACN,eAAe,EACf,KAAK,EACL,WAAW,EACX,MAAM,EACN,eAAe,EACf,OAAO,GAAG,SAAS,EACnB,OAAO,GAAG,KAAK,EACf,SAAS,EACT,GAAG,KAAK,
|
|
1
|
+
{"version":3,"file":"banner.js","sources":["../../src/components/banner.tsx"],"sourcesContent":["import { isValidElement, type ComponentProps, type ReactNode } from \"react\";\nimport type { LucideIcon } from \"lucide-react\";\nimport { cn } from \"@/utils\";\n\ntype BannerVariant = \"neutral\" | \"primary\" | \"warning\" | \"destructive\" | \"banner\";\n\nconst variantClasses: Record<\n BannerVariant,\n { container: string; icon: string }\n> = {\n banner: {\n container: 'border-secondary-border bg-secondary text-secondary-foreground',\n icon: 'bg-secondary text-secondary-foreground',\n },\n neutral: {\n container: 'border-landing-control bg-background text-landing-nav',\n icon: 'bg-v2-surface-subtle text-landing-nav',\n },\n primary: {\n container:\n \"border-primary/25 bg-primary/[0.035] transition-colors duration-state ease-out-strong hover:bg-primary/[0.06] motion-reduce:transition-none\",\n icon: \"bg-primary/5 text-primary\",\n },\n warning: {\n container:\n \"border-warning/30 bg-warning/10 transition-colors duration-state ease-out-strong hover:bg-warning/15 motion-reduce:transition-none\",\n icon: \"bg-warning/10 text-warning\",\n },\n destructive: {\n container:\n \"border-destructive/30 bg-destructive/5 transition-colors duration-state ease-out-strong hover:bg-destructive/10 motion-reduce:transition-none\",\n icon: \"bg-destructive/10 text-destructive\",\n },\n};\n\nfunction Banner({\n icon: Icon,\n media,\n visual,\n visualClassName,\n title,\n description,\n action,\n actionClassName,\n variant = \"primary\",\n compact = false,\n className,\n ...props\n}: Omit<ComponentProps<\"div\">, \"title\"> & {\n /** Accepts a Lucide icon component or any custom React node. */\n icon?: LucideIcon | ReactNode;\n media?: ReactNode;\n visual?: ReactNode;\n visualClassName?: string;\n /** Any node, e.g. an icon inline with the text (not the HTML title attribute). */\n title: ReactNode;\n description?: ReactNode;\n action?: ReactNode;\n actionClassName?: string;\n variant?: BannerVariant;\n compact?: boolean;\n}) {\n const styles = variantClasses[variant];\n // The icon is optional: without one (or a custom media node) the slot is\n // dropped entirely rather than leaving an empty tinted square.\n const IconComponent = typeof Icon === 'function' || (Icon && typeof Icon === 'object' && !isValidElement(Icon)) ? Icon as LucideIcon : undefined;\n const leadingVisual = visual ?? media;\n const hasIconSlot = Boolean(leadingVisual || Icon);\n\n return (\n <div\n data-slot=\"banner\"\n className={cn(\n \"group/banner flex flex-col rounded-control-lg border\",\n compact\n ? \"items-start gap-3 p-3 sm:flex-row sm:items-start sm:gap-2\"\n : \"gap-4 px-4 py-4 sm:flex-row sm:items-stretch sm:gap-3 sm:px-5\",\n styles.container,\n className,\n )}\n {...props}\n >\n <div\n className={cn(\n \"flex min-w-0 flex-1 items-start gap-3 sm:items-stretch sm:gap-3\",\n compact && \"gap-2 sm:items-start sm:gap-2\",\n )}\n >\n {hasIconSlot && (\n <span\n className={cn(\n \"flex shrink-0 items-center justify-center rounded-control-lg\",\n compact ? \"size-8\" : \"size-10 sm:self-center\",\n styles.icon,\n visualClassName,\n )}\n >\n {leadingVisual ??\n (IconComponent ? (\n <IconComponent\n className={compact ? \"size-4\" : \"size-5\"}\n aria-hidden=\"true\"\n />\n ) : isValidElement(Icon) ? Icon : (Icon as ReactNode))}\n </span>\n )}\n <div\n className={cn(\n \"min-w-0 flex-1\",\n description ? \"space-y-0.5\" : \"flex flex-col justify-center\",\n )}\n >\n <p className={cn(\"text-sm font-medium\", variant === 'banner' ? 'text-secondary-foreground' : 'text-foreground')}>{title}</p>\n {description && (\n <div className={cn(\"text-sm\", variant === 'banner' ? 'text-secondary-foreground' : 'text-muted-foreground')}>{description}</div>\n )}\n </div>\n </div>\n {action && (\n <div\n className={cn(\n \"w-full shrink-0 sm:w-auto sm:self-center\",\n actionClassName,\n )}\n >\n {action}\n </div>\n )}\n </div>\n );\n}\n\nexport { Banner, type BannerVariant };\n"],"names":["_jsxs","_jsx"],"mappings":";;;;AAMA,MAAM,cAAc,GAGhB;AACF,IAAA,MAAM,EAAE;AACN,QAAA,SAAS,EAAE,gEAAgE;AAC3E,QAAA,IAAI,EAAE,wCAAwC;AAC/C,KAAA;AACD,IAAA,OAAO,EAAE;AACP,QAAA,S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