Skip to content

The Open Standard for Generative UI

[TH-690] feat(Header): Add support for custom right-aligned content in Header component (#162)

Shivam Budhiaab36450f5f3f
diff --git a/js/packages/react-ui/package.json b/js/packages/react-ui/package.json
index 362433457..18a7eed27 100644
--- a/js/packages/react-ui/package.json
+++ b/js/packages/react-ui/package.json
@@ -38,7 +38,7 @@
"build:plugin": "tsc src/lib/tailwind/tailwind --outDir dist/lib/tailwind --module esnext --allowSyntheticDefaultImports --moduleResolution bundler --declaration",
"storybook": "storybook dev -p 6006",
"build:storybook": "storybook build -o ../../../docs/static/ui",
- "watch": "concurrently \"pnpm run build:tsc --watch\" \"pnpm run build:scss --watch\"",
+ "watch": "concurrently \"pnpm run build --watch\" \"pnpm run build:tsc --watch\" \"pnpm run build:scss --watch\"",
"lint:check": "eslint ./src",
"lint:fix": "eslint ./src --fix",
"format:fix": "prettier --write ./src",
@@ -103,6 +103,7 @@
"@types/react-dom": ">=17.0.0",
"@types/react-syntax-highlighter": "^15.5.13",
"@typescript-eslint/eslint-plugin": "^8.18.0",
+ "concurrently": "^9.2.0",
"eslint": "^9.17.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.2.1",
diff --git a/js/packages/react-ui/src/components/CopilotShell/Header.tsx b/js/packages/react-ui/src/components/CopilotShell/Header.tsx
index dd98297c2..7e9446cbb 100644
--- a/js/packages/react-ui/src/components/CopilotShell/Header.tsx
+++ b/js/packages/react-ui/src/components/CopilotShell/Header.tsx
@@ -1,7 +1,14 @@
import clsx from "clsx";
+import { ReactNode } from "react";
import { useShellStore } from "../Shell/store";
-export const Header = ({ className }: { className?: string }) => {
+interface HeaderProps {
+ className?: string;
+ /** Custom content to render on the rightmost side of the logo container */
+ rightChildren?: ReactNode;
+}
+
+export const Header = ({ className, rightChildren }: HeaderProps) => {
const { logoUrl, agentName } = useShellStore((state) => ({
logoUrl: state.logoUrl,
agentName: state.agentName,
@@ -13,6 +20,9 @@ export const Header = ({ className }: { className?: string }) => {
<img className="crayon-copilot-shell-header-logo" src={logoUrl} alt="Logo" />
<span className="crayon-copilot-shell-header-agent-name">{agentName}</span>
</div>
+ {rightChildren && (
+ <div className="crayon-copilot-shell-header-right-content">{rightChildren}</div>
+ )}
</div>
);
};
diff --git a/js/packages/react-ui/src/components/Shell/MobileHeader.tsx b/js/packages/react-ui/src/components/Shell/MobileHeader.tsx
index 926cbbabf..2eeff6283 100644
--- a/js/packages/react-ui/src/components/Shell/MobileHeader.tsx
+++ b/js/packages/react-ui/src/components/Shell/MobileHeader.tsx
@@ -1,10 +1,16 @@
import { useThreadListActions } from "@crayonai/react-core";
import clsx from "clsx";
import { Menu, Plus } from "lucide-react";
+import { ReactNode } from "react";
import { IconButton } from "../IconButton";
import { useShellStore } from "./store";
-export const MobileHeader = ({ className }: { className?: string }) => {
+interface MobileHeaderProps {
+ className?: string;
+ rightChildren?: ReactNode;
+}
+
+export const MobileHeader = ({ className, rightChildren }: MobileHeaderProps) => {
const { switchToNewThread } = useThreadListActions();
const { logoUrl, agentName, setIsSidebarOpen } = useShellStore((state) => ({
logoUrl: state.logoUrl,
@@ -24,12 +30,15 @@ export const MobileHeader = ({ className }: { className?: string }) => {
<img className="crayon-shell-mobile-header-logo" src={logoUrl} alt="Logo" />
<span className="crayon-shell-mobile-header-agent-name">{agentName}</span>
</div>
- <IconButton
- size="medium"
- icon={<Plus size="1em" />}
- onClick={switchToNewThread}
- variant="secondary"
- />
+ <div className="crayon-shell-mobile-header-actions">
+ {rightChildren}
+ <IconButton
+ size="medium"
+ icon={<Plus size="1em" />}
+ onClick={switchToNewThread}
+ variant="secondary"
+ />
+ </div>
</div>
);
};
diff --git a/js/packages/react-ui/src/components/Shell/mobileHeader.scss b/js/packages/react-ui/src/components/Shell/mobileHeader.scss
index 770cf4f50..881868c7a 100644
--- a/js/packages/react-ui/src/components/Shell/mobileHeader.scss
+++ b/js/packages/react-ui/src/components/Shell/mobileHeader.scss
@@ -17,6 +17,9 @@
align-items: center;
gap: cssUtils.$spacing-m;
@include cssUtils.typography(title, medium);
+ position: absolute;
+ left: 50%;
+ transform: translateX(-50%);
}
.crayon-shell-mobile-header-logo {
@@ -29,3 +32,9 @@
@include cssUtils.typography(title, medium);
color: cssUtils.$primary-text;
}
+
+.crayon-shell-mobile-header-actions {
+ display: flex;
+ align-items: center;
+ gap: cssUtils.$spacing-s;
+}
diff --git a/js/pnpm-lock.yaml b/js/pnpm-lock.yaml
index d8de50d09..86ba67fdc 100644
--- a/js/pnpm-lock.yaml
+++ b/js/pnpm-lock.yaml
@@ -259,6 +259,9 @@ importers:
'@typescript-eslint/eslint-plugin':
specifier: ^8.18.0
+ concurrently:
+ specifier: ^9.2.0
+ version: 9.2.0
eslint:
specifier: ^9.17.0
version: 9.29.0([email protected])
@@ -2207,6 +2210,10 @@ packages:
resolution: {integrity: sha512-rNjApaLzuwaOTjCiT8lSDdGN1APCiqkChLMJxJPWLunPAt5fy8xgU9/jNOchV84wfIxrA0lRQB7oCT8jrn/wrQ==}
engines: {node: '>=6.0'}
+ resolution: {integrity: sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==}
+ engines: {node: '>=12'}
+
resolution: {integrity: sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==}
engines: {node: '>=6'}
@@ -2242,6 +2249,11 @@ packages:
resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==}
+ resolution: {integrity: sha512-IsB/fiXTupmagMW4MNp2lx2cdSN2FfZq78vF90LBB+zZHArbIQZjQtzXCiXnvTxCZSvXanTqFLWBjw2UkLx1SQ==}
+ engines: {node: '>=18'}
+ hasBin: true
+
resolution: {integrity: sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==}
@@ -2667,6 +2679,10 @@ packages:
resolution: {integrity: sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==}
engines: {node: '>=6.9.0'}
+ resolution: {integrity: sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==}
+ engines: {node: 6.* || 8.* || >= 10.*}
+
resolution: {integrity: sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==}
engines: {node: '>= 0.4'}
@@ -3577,6 +3593,10 @@ packages:
resolution: {integrity: sha512-1OSmLd3awB/t8qdoEOMazZkNsfVTeY4fTsgzcQFdXNq8ToTN4ZGwrMnlda4K6smTFKD+GRV6O48i6Z4iKgPPpw==}
+ resolution: {integrity: sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==}
+ engines: {node: '>=0.10.0'}
+
resolution: {integrity: sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==}
engines: {node: '>=0.10.0'}
@@ -3605,6 +3625,9 @@ packages:
resolution: {integrity: sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==}
+ resolution: {integrity: sha512-dhKf903U/PQZY6boNNtAGdWbG85WAbjT/1xYoZIC7FAY0yWapOBQVsVrDl58W86//e1VpMNBtRV4MaXfdMySFA==}
+
resolution: {integrity: sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==}
@@ -3648,6 +3671,10 @@ packages:
resolution: {integrity: sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==}
engines: {node: '>=8'}
+ resolution: {integrity: sha512-ObmnIF4hXNg1BqhnHmgbDETF8dLPCggZWBjkQfhZpbszZnYur5DUljTcCHii5LC3J5E0yeO/1LIMyH+UvHQgyw==}
+ engines: {node: '>= 0.4'}
+
resolution: {integrity: sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==}
engines: {node: '>=14'}
@@ -3804,6 +3831,10 @@ packages:
resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==}
engines: {node: '>=8.0'}
+ resolution: {integrity: sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==}
+ hasBin: true
+
resolution: {integrity: sha512-kRj8B+YHZCc9kQYdWfJB2/oUl9rA99qbowYYBtr4ui4mZyAQ2JpvVBd/6U2YloATfqBhBTSMhTpgBHtU0Mf3Rg==}
@@ -4038,6 +4069,10 @@ packages:
resolution: {integrity: sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==}
engines: {node: '>=0.4'}
+ resolution: {integrity: sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==}
+ engines: {node: '>=10'}
+
resolution: {integrity: sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==}
@@ -4046,6 +4081,14 @@ packages:
engines: {node: '>= 14.6'}
hasBin: true
+ resolution: {integrity: sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==}
+ engines: {node: '>=12'}
+
+ resolution: {integrity: sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==}
+ engines: {node: '>=12'}
+
resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==}
engines: {node: '>=10'}
@@ -5879,6 +5922,12 @@ snapshots:
+ dependencies:
+ string-width: 4.2.3
+ strip-ansi: 6.0.1
+ wrap-ansi: 7.0.0
+
@@ -5903,6 +5952,16 @@ snapshots:
+ dependencies:
+ chalk: 4.1.2
+ lodash: 4.17.21
+ rxjs: 7.8.2
+ shell-quote: 1.8.3
+ supports-color: 8.1.1
+ tree-kill: 1.2.2
+ yargs: 17.7.2
+
@@ -6333,6 +6392,8 @@ snapshots:
+
dependencies:
call-bind-apply-helpers: 1.0.2
@@ -7536,6 +7597,8 @@ snapshots:
mdast-util-to-markdown: 2.1.2
unified: 11.0.5
+
@@ -7580,6 +7643,10 @@ snapshots:
dependencies:
queue-microtask: 1.2.3
+ dependencies:
+ tslib: 2.8.1
+
@@ -7628,6 +7695,8 @@ snapshots:
+
@@ -7795,6 +7864,8 @@ snapshots:
dependencies:
is-number: 7.0.0
+
@@ -8044,10 +8115,24 @@ snapshots:
+
+
+ dependencies:
+ cliui: 8.0.1
+ escalade: 3.2.0
+ get-caller-file: 2.0.5
+ require-directory: 2.1.1
+ string-width: 4.2.3
+ y18n: 5.0.8
+ yargs-parser: 21.1.1
+