mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-16 12:14:55 +00:00
feat(dashboard): promote CCS Bar globally
This commit is contained in:
1 parent
8e73ee0acc
commit
b9356a7ce6
13 files changed
+306
-182
No files matched your search
@@ -10,6 +10,7 @@ import { ConnectionIndicator } from '@/components/shared/connection-indicator';
|
||||
import { LocalhostDisclaimer } from '@/components/shared/localhost-disclaimer';
|
||||
import { Skeleton } from '@/components/ui/skeleton';
|
||||
import { ClaudeKitBadge } from '@/components/shared/claudekit-badge';
|
||||
import { CcsBarButton } from '@/components/shared/ccs-bar-button';
|
||||
import { SponsorButton } from '@/components/shared/sponsor-button';
|
||||
import { ProjectSelectionDialog } from '@/components/shared/project-selection-dialog';
|
||||
import { DeviceCodeDialog } from '@/components/shared/device-code-dialog';
|
||||
@@ -44,6 +45,7 @@ export function Layout() {
|
||||
<header className="flex h-14 items-center justify-between px-6 border-b shrink-0 bg-background shadow-sm z-20">
|
||||
<div className="flex items-center gap-3">
|
||||
<ClaudeKitBadge />
|
||||
<CcsBarButton />
|
||||
<SponsorButton />
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
|
||||
@@ -1,101 +0,0 @@
|
||||
/**
|
||||
* CCS Bar Feature Banner
|
||||
* Dismissible announcement banner promoting the native macOS menu-bar app.
|
||||
*
|
||||
* Rendered only on macOS: the CTA is an install action (`ccs bar install`) that
|
||||
* has no effect on other platforms, so showing it elsewhere would be misleading.
|
||||
*/
|
||||
|
||||
/* eslint-disable react-hooks/set-state-in-effect */
|
||||
import { useState, useEffect } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { X, MonitorDot, ExternalLink } from 'lucide-react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
|
||||
const BANNER_DISMISSED_KEY = 'ccs:ccs-bar-banner-dismissed';
|
||||
|
||||
// User-facing docs page for CCS Bar (flat Markdown in the ccs/cli docs tree).
|
||||
const CCS_BAR_DOCS_URL = 'https://github.com/kaitranntt/ccs/blob/main/docs/ccs-bar.md';
|
||||
|
||||
// Lightweight, dependency-free macOS detection. Kept inline because no other
|
||||
// component needs platform detection; a shared hook would be premature.
|
||||
const isMacOS =
|
||||
typeof navigator !== 'undefined' &&
|
||||
/Mac|iPhone|iPad/i.test(navigator.userAgent || navigator.platform || '');
|
||||
|
||||
interface CcsBarBannerProps {
|
||||
onInstallClick?: () => void;
|
||||
}
|
||||
|
||||
export function CcsBarBanner({ onInstallClick }: CcsBarBannerProps) {
|
||||
const { t } = useTranslation();
|
||||
const [dismissed, setDismissed] = useState(true); // Start hidden to avoid flash
|
||||
|
||||
// Check localStorage on mount
|
||||
useEffect(() => {
|
||||
const isDismissed = localStorage.getItem(BANNER_DISMISSED_KEY) === 'true';
|
||||
setDismissed(isDismissed);
|
||||
}, []);
|
||||
|
||||
const handleDismiss = () => {
|
||||
localStorage.setItem(BANNER_DISMISSED_KEY, 'true');
|
||||
setDismissed(true);
|
||||
};
|
||||
|
||||
if (!isMacOS) return null;
|
||||
if (dismissed) return null;
|
||||
|
||||
return (
|
||||
<div className="bg-gradient-to-r from-accent to-accent/90 text-white px-4 py-3 relative shrink-0">
|
||||
<div className="flex items-center justify-between gap-4 max-w-screen-xl mx-auto">
|
||||
<div className="flex items-center gap-3 flex-1 min-w-0">
|
||||
<div className="p-1.5 bg-white/20 rounded-md shrink-0">
|
||||
<MonitorDot className="w-4 h-4" />
|
||||
</div>
|
||||
<div className="flex-1 min-w-0">
|
||||
<p className="font-medium text-sm">
|
||||
{t('ccsBarBanner.new')}: {t('ccsBarBanner.title')}
|
||||
</p>
|
||||
<p className="text-xs text-white/80 truncate">
|
||||
{t('ccsBarBanner.description')}{' '}
|
||||
<code className="bg-white/15 rounded px-1 py-0.5 font-mono text-[11px]">
|
||||
ccs bar install
|
||||
</code>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-2 shrink-0">
|
||||
{onInstallClick && (
|
||||
<Button
|
||||
size="sm"
|
||||
variant="secondary"
|
||||
onClick={onInstallClick}
|
||||
className="bg-white text-accent hover:bg-white/90 h-8"
|
||||
>
|
||||
{t('ccsBarBanner.install')}
|
||||
</Button>
|
||||
)}
|
||||
<a
|
||||
href={CCS_BAR_DOCS_URL}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="text-xs text-white/80 hover:text-white hidden sm:flex items-center gap-1"
|
||||
>
|
||||
Learn more
|
||||
<ExternalLink className="w-3 h-3" />
|
||||
</a>
|
||||
<Button
|
||||
size="icon"
|
||||
variant="ghost"
|
||||
onClick={handleDismiss}
|
||||
className="h-7 w-7 text-white/70 hover:text-white hover:bg-white/20"
|
||||
>
|
||||
<X className="w-4 h-4" />
|
||||
<span className="sr-only">Dismiss</span>
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
/**
|
||||
* CCS Bar Promo Card
|
||||
* Permanent promotional card for the native macOS menu-bar app, shown in the
|
||||
* providers sidebar footer.
|
||||
*
|
||||
* Rendered only on macOS: the install CTA has no effect elsewhere.
|
||||
*/
|
||||
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { MonitorDot } from 'lucide-react';
|
||||
|
||||
// Lightweight, dependency-free macOS detection (see ccs-bar-banner.tsx).
|
||||
const isMacOS =
|
||||
typeof navigator !== 'undefined' &&
|
||||
/Mac|iPhone|iPad/i.test(navigator.userAgent || navigator.platform || '');
|
||||
|
||||
interface CcsBarPromoCardProps {
|
||||
onInstallClick: () => void;
|
||||
}
|
||||
|
||||
export function CcsBarPromoCard({ onInstallClick }: CcsBarPromoCardProps) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
if (!isMacOS) return null;
|
||||
|
||||
return (
|
||||
<div className="p-3 border-t bg-gradient-to-r from-accent/5 to-accent/10 dark:from-accent/10 dark:to-accent/15">
|
||||
<div className="flex items-center gap-2">
|
||||
<div className="p-1.5 bg-accent/10 dark:bg-accent/20 rounded shrink-0">
|
||||
<MonitorDot className="w-4 h-4 text-accent" />
|
||||
</div>
|
||||
<div className="flex-1 min-w-0">
|
||||
<p className="text-xs font-medium text-accent dark:text-accent-foreground">
|
||||
{t('ccsBarPromo.title')}
|
||||
</p>
|
||||
<p className="text-[10px] text-muted-foreground truncate">
|
||||
{t('ccsBarPromo.description')}
|
||||
</p>
|
||||
</div>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
onClick={onInstallClick}
|
||||
className="h-7 px-2 text-accent hover:text-accent hover:bg-accent/10 dark:hover:bg-accent/20"
|
||||
>
|
||||
<MonitorDot className="w-3 h-3 mr-1" />
|
||||
<span className="text-xs">{t('ccsBarPromo.install')}</span>
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -21,9 +21,5 @@ export { OpenRouterPromoCard } from './openrouter-promo-card';
|
||||
export { OpenRouterQuickStart } from './openrouter-quick-start';
|
||||
export { AlibabaCodingPlanPromoCard } from './alibaba-coding-plan-promo-card';
|
||||
|
||||
// CCS Bar (native macOS menu-bar app) promo components
|
||||
export { CcsBarBanner } from './ccs-bar-banner';
|
||||
export { CcsBarPromoCard } from './ccs-bar-promo-card';
|
||||
|
||||
export { ModelTierMapping } from './model-tier-mapping';
|
||||
export type { TierMapping } from './model-tier-mapping';
|
||||
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* CCS Bar Button
|
||||
*
|
||||
* Compact navbar link for the native macOS menu-bar app docs.
|
||||
*/
|
||||
|
||||
import { MonitorDot } from 'lucide-react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip';
|
||||
|
||||
const CCS_BAR_DOCS_URL = 'https://docs.ccs.kaitran.ca/features/dashboard/ccs-bar';
|
||||
|
||||
export function CcsBarButton() {
|
||||
const { t } = useTranslation();
|
||||
|
||||
return (
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
asChild
|
||||
className="h-8 gap-1.5 border-accent/40 bg-accent/5 px-2.5 text-accent hover:bg-accent hover:text-accent-foreground"
|
||||
>
|
||||
<a
|
||||
href={CCS_BAR_DOCS_URL}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
title={t('ccsBarButton.title')}
|
||||
>
|
||||
<MonitorDot className="w-4 h-4" />
|
||||
<span className="hidden text-xs font-bold sm:inline">{t('ccsBarButton.label')}</span>
|
||||
</a>
|
||||
</Button>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent side="bottom" align="start" className="max-w-64">
|
||||
{t('ccsBarButton.tooltip')}
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
);
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
*/
|
||||
|
||||
export { CcsLogo } from './ccs-logo';
|
||||
export { CcsBarButton } from './ccs-bar-button';
|
||||
export { ClaudeKitBadge } from './claudekit-badge';
|
||||
export { CodeEditor } from './code-editor';
|
||||
export { CommandBuilder } from './command-builder';
|
||||
|
||||
+25
-11
@@ -1636,6 +1636,11 @@ const resources = {
|
||||
githubLink: {
|
||||
title: 'Report an issue on GitHub',
|
||||
},
|
||||
ccsBarButton: {
|
||||
title: 'Open CCS Bar docs',
|
||||
label: 'CCS Bar',
|
||||
tooltip: 'Native macOS menu-bar quota, cost, and account controls',
|
||||
},
|
||||
globalEnvIndicator: {
|
||||
injectedCount_one: '{{count}} global env var will be injected at runtime',
|
||||
injectedCount_other: '{{count}} global env vars will be injected at runtime',
|
||||
@@ -2489,17 +2494,6 @@ const resources = {
|
||||
title: 'OpenRouter',
|
||||
description: 'Access hundreds of models from one API endpoint.',
|
||||
},
|
||||
ccsBarBanner: {
|
||||
new: 'NEW',
|
||||
title: 'CCS Bar for macOS',
|
||||
description: 'See live subscription quota and usage from your menu bar. Install with',
|
||||
install: 'Install',
|
||||
},
|
||||
ccsBarPromo: {
|
||||
title: 'CCS Bar (macOS)',
|
||||
description: 'Live quota and usage in your menu bar.',
|
||||
install: 'Install',
|
||||
},
|
||||
profileCard: {
|
||||
profile: 'Profile',
|
||||
openRouter: 'OpenRouter profile',
|
||||
@@ -4286,6 +4280,11 @@ const resources = {
|
||||
githubLink: {
|
||||
title: '在 GitHub 上报告问题',
|
||||
},
|
||||
ccsBarButton: {
|
||||
title: '打开 CCS Bar 文档',
|
||||
label: 'CCS Bar',
|
||||
tooltip: '原生 macOS 菜单栏配额、成本和账号控制',
|
||||
},
|
||||
globalEnvIndicator: {
|
||||
injectedCount_one: '{{count}} 个全局环境变量将在运行时注入',
|
||||
injectedCount_other: '{{count}} 个全局环境变量将在运行时注入',
|
||||
@@ -6984,6 +6983,11 @@ const resources = {
|
||||
githubLink: {
|
||||
title: 'Báo cáo vấn đề trên GitHub',
|
||||
},
|
||||
ccsBarButton: {
|
||||
title: 'Mở tài liệu CCS Bar',
|
||||
label: 'CCS Bar',
|
||||
tooltip: 'Điều khiển hạn mức, chi phí và tài khoản trên thanh menu macOS',
|
||||
},
|
||||
globalEnvIndicator: {
|
||||
injectedCount_one: '{{count}} biến env toàn cục sẽ được áp dụng khi chạy',
|
||||
injectedCount_other: '{{count}} biến env toàn cục sẽ được áp dụng khi chạy',
|
||||
@@ -10665,6 +10669,11 @@ const resources = {
|
||||
title: 'GitHub でこのプロジェクトをスポンサー',
|
||||
sponsor: 'スポンサー',
|
||||
},
|
||||
ccsBarButton: {
|
||||
title: 'CCS Bar ドキュメントを開く',
|
||||
label: 'CCS Bar',
|
||||
tooltip: 'macOS メニューバーでクォータ、コスト、アカウントを確認',
|
||||
},
|
||||
supportEntryCard: {
|
||||
actionRequired: '対応が必要',
|
||||
},
|
||||
@@ -12431,6 +12440,11 @@ const resources = {
|
||||
githubLink: {
|
||||
title: 'GitHub에서 이슈 보고',
|
||||
},
|
||||
ccsBarButton: {
|
||||
title: 'CCS Bar 문서 열기',
|
||||
label: 'CCS Bar',
|
||||
tooltip: 'macOS 메뉴 막대에서 할당량, 비용, 계정 제어 확인',
|
||||
},
|
||||
globalEnvIndicator: {
|
||||
injectedCount_one: '런타임에 글로벌 환경 변수 {{count}}개가 주입됩니다',
|
||||
injectedCount_other: '런타임에 글로벌 환경 변수 {{count}}개가 주입됩니다',
|
||||
|
||||
@@ -22,8 +22,6 @@ import { OpenRouterBanner } from '@/components/profiles/openrouter-banner';
|
||||
import { OpenRouterQuickStart } from '@/components/profiles/openrouter-quick-start';
|
||||
import { OpenRouterPromoCard } from '@/components/profiles/openrouter-promo-card';
|
||||
import { AlibabaCodingPlanPromoCard } from '@/components/profiles/alibaba-coding-plan-promo-card';
|
||||
import { CcsBarBanner } from '@/components/profiles/ccs-bar-banner';
|
||||
import { CcsBarPromoCard } from '@/components/profiles/ccs-bar-promo-card';
|
||||
import {
|
||||
useProfiles,
|
||||
useDeleteProfile,
|
||||
@@ -43,15 +41,6 @@ import { useTranslation } from 'react-i18next';
|
||||
import { toast } from 'sonner';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
|
||||
// CCS Bar is installed via the `ccs bar install` CLI command, not from the
|
||||
// dashboard. The promo CTA therefore opens the user-facing docs page where the
|
||||
// install/launch steps live, rather than triggering an in-app action.
|
||||
const CCS_BAR_DOCS_URL = 'https://github.com/kaitranntt/ccs/blob/main/docs/ccs-bar.md';
|
||||
|
||||
function openCcsBarDocs() {
|
||||
window.open(CCS_BAR_DOCS_URL, '_blank', 'noopener,noreferrer');
|
||||
}
|
||||
|
||||
export function ApiPage() {
|
||||
const { t } = useTranslation();
|
||||
const navigate = useNavigate();
|
||||
@@ -224,7 +213,6 @@ export function ApiPage() {
|
||||
return (
|
||||
<div className="flex h-full min-h-0 flex-col overflow-hidden">
|
||||
<OpenRouterBanner onCreateClick={() => setCreateDialogOpen(true)} />
|
||||
<CcsBarBanner onInstallClick={() => openCcsBarDocs()} />
|
||||
<div className="flex-1 flex min-h-0 overflow-hidden">
|
||||
<div className="w-80 border-r flex flex-col bg-muted/30">
|
||||
<div className="p-4 border-b bg-background">
|
||||
@@ -375,7 +363,6 @@ export function ApiPage() {
|
||||
setCreateDialogOpen(true);
|
||||
}}
|
||||
/>
|
||||
<CcsBarPromoCard onInstallClick={() => openCcsBarDocs()} />
|
||||
</div>
|
||||
|
||||
<div className="flex min-h-0 flex-1 flex-col min-w-0 overflow-hidden">
|
||||
|
||||
Reference in new issue
Block a user