The Open Standard for Generative UI
Callout component (#53)
subham06985c92bb17
diff --git a/js/packages/react-ui/src/components/Callout/Callout.tsx b/js/packages/react-ui/src/components/Callout/Callout.tsxnew file mode 100644index 000000000..9da2f0485--- /dev/null+++ b/js/packages/react-ui/src/components/Callout/Callout.tsx@@ -0,0 +1,36 @@+import clsx from "clsx";+import React from "react";++type CalloutVariant = "neutral" | "info" | "warning" | "success";++export interface CalloutProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "title"> {+ variant?: CalloutVariant;+ title?: React.ReactNode;+ icon?: React.ReactNode;+ description?: React.ReactNode;+}++const variantMap: Record<CalloutVariant, string> = {+ neutral: "crayon-callout-neutral",+ info: "crayon-callout-info",+ warning: "crayon-callout-warning",+ success: "crayon-callout-success",+};++export const Callout = React.forwardRef<HTMLDivElement, CalloutProps>((props, ref) => {+ const { className, variant = "neutral", title, icon, description, ...rest } = props;++ return (+ <div ref={ref} className={clsx("crayon-callout", variantMap[variant], className)} {...rest}>+ {icon && (+ <div className="crayon-callout-icon">+ <span className="crayon-callout-icon-inner">{icon}</span>+ </div>+ )}+ <div className="crayon-callout-content">+ {title && <span className="crayon-callout-content-title">{title}</span>}+ {description && <span className="crayon-callout-content-description">{description}</span>}+ </div>+ </div>+ );+});diff --git a/js/packages/react-ui/src/components/Callout/callout.scss b/js/packages/react-ui/src/components/Callout/callout.scssnew file mode 100644index 000000000..9e6fcc414--- /dev/null+++ b/js/packages/react-ui/src/components/Callout/callout.scss@@ -0,0 +1,78 @@+@use "../../cssUtils" as cssUtils;++.crayon-callout {+ width: 100%;+ display: flex;+ flex-direction: row;+ gap: cssUtils.$spacing-xs;+ padding: cssUtils.$spacing-m;+ border-radius: cssUtils.$rounded-xl;+ box-sizing: border-box;+ &-neutral {+ background-color: cssUtils.$bg-container-hover;+ border: 1px solid cssUtils.$stroke-default;+ color: cssUtils.$primary-text;+ .crayon-callout-content-title {+ color: cssUtils.$primary-text;+ }+ }++ &-info {+ background-color: cssUtils.$bg-info;+ border: 1px solid cssUtils.$stroke-default;+ color: cssUtils.$info-text;+ .crayon-callout-content-title {+ color: cssUtils.$info-text;+ }+ }++ &-warning {+ background-color: cssUtils.$bg-danger;+ border: 1px solid cssUtils.$stroke-default;+ color: cssUtils.$danger-text;+ .crayon-callout-content-title {+ color: cssUtils.$danger-text;+ }+ }++ &-success {+ background-color: cssUtils.$bg-success;+ border: 1px solid cssUtils.$stroke-default;+ color: cssUtils.$success-text;+ .crayon-callout-content-title {+ color: cssUtils.$success-text;+ }+ }++ &-icon {+ width: 16px;+ height: 16px;+ display: flex;+ align-items: center;+ justify-content: center;+ padding: cssUtils.$spacing-3xs;+ }++ &-icon-inner {+ width: 16px;+ height: 16px;+ display: flex;+ align-items: center;+ justify-content: center;+ }++ &-content {+ display: flex;+ flex-direction: column;+ gap: cssUtils.$spacing-2xs;+ &-title {+ @include cssUtils.typography(title, default);+ color: cssUtils.$primary-text;+ }++ &-description {+ @include cssUtils.typography(body, default);+ color: cssUtils.$secondary-text;+ }+ }+}diff --git a/js/packages/react-ui/src/components/Callout/dependancies.ts b/js/packages/react-ui/src/components/Callout/dependancies.tsnew file mode 100644index 000000000..c6a71056b--- /dev/null+++ b/js/packages/react-ui/src/components/Callout/dependancies.ts@@ -0,0 +1,2 @@+const dependencies = ["Callout"];+export default dependencies;diff --git a/js/packages/react-ui/src/components/Callout/index.ts b/js/packages/react-ui/src/components/Callout/index.tsnew file mode 100644index 000000000..e69de29bbdiff --git a/js/packages/react-ui/src/components/Callout/stories/callout.stories.tsx b/js/packages/react-ui/src/components/Callout/stories/callout.stories.tsxnew file mode 100644index 000000000..e98b34ff0--- /dev/null+++ b/js/packages/react-ui/src/components/Callout/stories/callout.stories.tsx@@ -0,0 +1,67 @@+import type { Meta, StoryObj } from "@storybook/react";+import { Info } from "lucide-react";+import { Callout, CalloutProps } from "../Callout";++const meta: Meta<CalloutProps> = {+ title: "Components/Callout",+ component: Callout,+ parameters: {+ layout: "centered",+ docs: {+ description: {+ component: "```tsx\nimport { Callout } from '@crayon-ui/react-ui';\n```",+ },+ },+ },+ tags: ["!dev", "autodocs"],+ argTypes: {+ variant: {+ control: "select",+ options: ["neutral", "info", "warning", "success"],+ description: "The visual style variant of the callout",+ table: {+ category: "Appearance",+ type: { summary: "CalloutVariant" },+ defaultValue: { summary: "neutral" },+ },+ },+ title: {+ control: "text",+ description: "The title of the callout",+ table: {+ category: "Content",+ defaultValue: { summary: "Important Information" },+ type: { summary: "React.ReactNode" },+ },+ },+ description: {+ control: "text",+ description: "The description text of the callout",+ table: {+ category: "Content",+ defaultValue: { summary: "This is a neutral callout with some important information." },+ type: { summary: "React.ReactNode" },+ },+ },+ icon: {+ control: false,+ description: "Optional icon to display in the callout",+ table: {+ category: "Content",+ type: { summary: "React.ReactNode" },+ },+ },+ },+} satisfies Meta<typeof Callout>;++export default meta;+type Story = StoryObj<typeof meta>;++export const Default: Story = {+ args: {+ title: "Important Information",+ description: "This is a neutral callout with some important information.",+ variant: "neutral",+ icon: <Info width={24} height={24} />,+ },+};diff --git a/js/packages/react-ui/src/components/Steps/steps.scss b/js/packages/react-ui/src/components/Steps/steps.scssindex 52b0dccd6..7877a36d6 100644--- a/js/packages/react-ui/src/components/Steps/steps.scss+++ b/js/packages/react-ui/src/components/Steps/steps.scss@@ -46,7 +46,8 @@border-radius: 50%;background-color: cssUtils.$bg-sunk;color: cssUtils.$secondary-text;- outline: 1px solid cssUtils.$stroke-default;+ border: 1px solid cssUtils.$stroke-default;+ box-sizing: border-box;}.crayon-connector-line {width: 1px;@@ -56,7 +57,7 @@bottom: -20px;left: 10px;z-index: 1;- border-left: 1px solid cssUtils.$stroke-default;+ background-color: cssUtils.$bg-container-hover;}.crayon-step-content {padding-top: cssUtils.$spacing-2xs;diff --git a/js/packages/react-ui/src/components/Tabs/tabs.scss b/js/packages/react-ui/src/components/Tabs/tabs.scssindex 6da9d2edc..c749e6177 100644--- a/js/packages/react-ui/src/components/Tabs/tabs.scss+++ b/js/packages/react-ui/src/components/Tabs/tabs.scss@@ -58,12 +58,13 @@border-radius: cssUtils.$rounded-xs;min-width: 7.3rem;width: 100%;- background-color: cssUtils.$bg-container;- color: cssUtils.$primary-text;+ background-color: transparent;+ color: cssUtils.$secondary-text;@include cssUtils.typography(label, default);&[data-state="active"] {- background-color: cssUtils.$bg-fill;+ background-color: cssUtils.$bg-sunk;border-color: cssUtils.$stroke-default;+ color: cssUtils.$primary-text;}&-text {text-align: center;diff --git a/js/packages/react-ui/src/components/ThemeProvider/ThemeProvider.tsx b/js/packages/react-ui/src/components/ThemeProvider/ThemeProvider.tsxindex 7272dcf9a..d6b3ba0d1 100644--- a/js/packages/react-ui/src/components/ThemeProvider/ThemeProvider.tsx+++ b/js/packages/react-ui/src/components/ThemeProvider/ThemeProvider.tsx@@ -16,9 +16,10 @@ const lightTheme: ColorTheme = {containerFills: "rgb(255, 255, 255)",overlayFills: "rgba(0, 0, 0, 0.4)",sunkFills: "rgba(0, 0, 0, 0.04)",- containerHoverFills: "rgba(255, 255, 255, 0.04)",+ containerHoverFills: "rgba(0, 0, 0, 0.04)",dangerFills: "rgba(217, 45, 32, 0.08)",successFills: "rgba(7, 148, 85, 0.08)",+ infoFills: "rgba(56, 148, 255, 0.08)",// Border colorsstrokeDefault: "rgba(0, 0, 0, 0.06)",@@ -35,7 +36,7 @@ const lightTheme: ColorTheme = {dangerText: "rgba(217, 45, 32, 1)",successText: "rgba(7, 148, 85, 1)",linkText: "rgba(0, 0, 0, 1)",- infoText: "rgba(0, 0, 0, 0.4)",+ infoText: "rgba(56, 148, 255, 1)",} as const;const darkTheme: ColorTheme = {@@ -49,6 +50,7 @@ const darkTheme: ColorTheme = {containerHoverFills: "rgba(255, 255, 255, 0.1)",dangerFills: "rgba(217, 45, 32, 0.1)",successFills: "rgba(7, 148, 85, 0.1)",+ infoFills: "rgba(56, 148, 255, 0.1)",// Border colorsstrokeDefault: "rgba(255, 255, 255, 0.06)",@@ -65,7 +67,7 @@ const darkTheme: ColorTheme = {dangerText: "rgba(253, 162, 155, 1)",successText: "rgba(117, 224, 167, 1)",linkText: "rgba(255, 255, 255, 1)",- infoText: "rgba(255, 255, 255, 0.6)",+ infoText: "rgba(125, 179, 247, 1)",} as const;// Shared theme properties that don't change between light/dark modes@@ -217,6 +219,7 @@ export const ThemeProvider = ({--crayon-container-hover-fills: ${theme.containerHoverFills};--crayon-danger-fills: ${theme.dangerFills};--crayon-success-fills: ${theme.successFills};+ --crayon-info-fills: ${theme.infoFills};--crayon-stroke-default: ${theme.strokeDefault};--crayon-stroke-interactive-el: ${theme.strokeInteractiveEl};diff --git a/js/packages/react-ui/src/components/ThemeProvider/types.ts b/js/packages/react-ui/src/components/ThemeProvider/types.tsindex 82b7202df..5866deab7 100644--- a/js/packages/react-ui/src/components/ThemeProvider/types.ts+++ b/js/packages/react-ui/src/components/ThemeProvider/types.ts@@ -13,7 +13,7 @@ export interface ColorTheme {containerHoverFills?: string;dangerFills?: string;successFills?: string;-+ infoFills?: string;// Border colorsstrokeDefault?: string;strokeInteractiveEl?: string;diff --git a/js/packages/react-ui/src/components/index.scss b/js/packages/react-ui/src/components/index.scssindex ad56af84b..21c785d30 100644--- a/js/packages/react-ui/src/components/index.scss+++ b/js/packages/react-ui/src/components/index.scss@@ -33,3 +33,4 @@@forward "./TextArea/textArea.scss";@forward "./TextContent/textContent.scss";@forward "./Steps/steps.scss";+@forward "./Callout/callout.scss";diff --git a/js/packages/react-ui/src/cssUtils.scss b/js/packages/react-ui/src/cssUtils.scssindex 18725f551..84ce40cb5 100644--- a/js/packages/react-ui/src/cssUtils.scss+++ b/js/packages/react-ui/src/cssUtils.scss@@ -11,6 +11,7 @@ $bg-overlay: var(--crayon-overlay-fills);$bg-sunk: var(--crayon-sunk-fills);$bg-danger: var(--crayon-danger-fills);$bg-success: var(--crayon-success-fills);+$bg-info: var(--crayon-info-fills);// Crayon Stroke Colors