mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-13 20:14:34 +00:00
fix(ui): simplify provider chooser cards
This commit is contained in:
1 parent
3954e445f3
commit
a999adc776
2 files changed
+20
-21
No files matched your search
@@ -116,12 +116,6 @@ const QUICK_TEMPLATE_PRESETS = PROVIDER_PRESETS.filter(
|
|||||||
const QUICK_TEMPLATE_PRESET_IDS = new Set<string>(
|
const QUICK_TEMPLATE_PRESET_IDS = new Set<string>(
|
||||||
QUICK_TEMPLATE_PRESETS.map((preset) => preset.id)
|
QUICK_TEMPLATE_PRESETS.map((preset) => preset.id)
|
||||||
);
|
);
|
||||||
const CARD_META_CLAMP_STYLE = {
|
|
||||||
display: '-webkit-box',
|
|
||||||
WebkitLineClamp: 2,
|
|
||||||
WebkitBoxOrient: 'vertical',
|
|
||||||
overflow: 'hidden',
|
|
||||||
} as const;
|
|
||||||
|
|
||||||
export function ProfileCreateDialog({
|
export function ProfileCreateDialog({
|
||||||
open,
|
open,
|
||||||
@@ -345,6 +339,7 @@ export function ProfileCreateDialog({
|
|||||||
preset={preset}
|
preset={preset}
|
||||||
isSelected={selectedPreset === preset.id}
|
isSelected={selectedPreset === preset.id}
|
||||||
onClick={() => handlePresetSelect(preset.id)}
|
onClick={() => handlePresetSelect(preset.id)}
|
||||||
|
density="featured"
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
<div className="mx-1 hidden w-px rounded-full bg-border/70 sm:block" />
|
<div className="mx-1 hidden w-px rounded-full bg-border/70 sm:block" />
|
||||||
@@ -383,6 +378,7 @@ export function ProfileCreateDialog({
|
|||||||
preset={preset}
|
preset={preset}
|
||||||
isSelected={selectedPreset === preset.id}
|
isSelected={selectedPreset === preset.id}
|
||||||
onClick={() => handlePresetSelect(preset.id)}
|
onClick={() => handlePresetSelect(preset.id)}
|
||||||
|
density="compact"
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
@@ -694,19 +690,23 @@ function CompactPresetCard({
|
|||||||
preset,
|
preset,
|
||||||
isSelected,
|
isSelected,
|
||||||
onClick,
|
onClick,
|
||||||
|
density = 'compact',
|
||||||
}: {
|
}: {
|
||||||
preset: ProviderPreset;
|
preset: ProviderPreset;
|
||||||
isSelected: boolean;
|
isSelected: boolean;
|
||||||
onClick: () => void;
|
onClick: () => void;
|
||||||
|
density?: 'featured' | 'compact';
|
||||||
}) {
|
}) {
|
||||||
const isAnthropicDirect = preset.id === 'anthropic';
|
const isAnthropicDirect = preset.id === 'anthropic';
|
||||||
|
const isFeaturedDensity = density === 'featured';
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
className={cn(
|
className={cn(
|
||||||
'flex h-[78px] w-[168px] flex-none items-start gap-3 rounded-xl border px-3 py-2.5 text-left transition-all',
|
'flex flex-none items-center gap-3 rounded-xl border px-3 py-2.5 text-left transition-all',
|
||||||
|
isFeaturedDensity ? 'h-[68px] w-[236px]' : 'h-[64px] w-[168px]',
|
||||||
isSelected
|
isSelected
|
||||||
? 'border-primary bg-primary/8 shadow-sm ring-1 ring-primary/10'
|
? 'border-primary bg-primary/8 shadow-sm ring-1 ring-primary/10'
|
||||||
: 'border-border/60 bg-background hover:border-primary/40 hover:bg-accent/20'
|
: 'border-border/60 bg-background hover:border-primary/40 hover:bg-accent/20'
|
||||||
@@ -726,13 +726,10 @@ function CompactPresetCard({
|
|||||||
|
|
||||||
<div className="min-w-0 flex-1 space-y-1">
|
<div className="min-w-0 flex-1 space-y-1">
|
||||||
<div className="space-y-1">
|
<div className="space-y-1">
|
||||||
<div
|
<div className="truncate text-[13px] font-semibold leading-tight tracking-[-0.01em]">
|
||||||
className="text-sm font-semibold leading-tight"
|
|
||||||
style={{ ...CARD_META_CLAMP_STYLE, WebkitLineClamp: 2 }}
|
|
||||||
>
|
|
||||||
{preset.name}
|
{preset.name}
|
||||||
</div>
|
</div>
|
||||||
{preset.badge && (
|
{preset.badge && isFeaturedDensity && (
|
||||||
<Badge
|
<Badge
|
||||||
variant="secondary"
|
variant="secondary"
|
||||||
className="inline-flex bg-muted px-1.5 py-0 text-[10px] text-muted-foreground"
|
className="inline-flex bg-muted px-1.5 py-0 text-[10px] text-muted-foreground"
|
||||||
@@ -741,9 +738,14 @@ function CompactPresetCard({
|
|||||||
</Badge>
|
</Badge>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<p className="text-[11px] leading-4 text-muted-foreground" style={CARD_META_CLAMP_STYLE}>
|
{preset.badge && !isFeaturedDensity && (
|
||||||
{preset.description}
|
<Badge
|
||||||
</p>
|
variant="secondary"
|
||||||
|
className="inline-flex w-fit bg-muted px-1.5 py-0 text-[10px] text-muted-foreground"
|
||||||
|
>
|
||||||
|
{preset.badge}
|
||||||
|
</Badge>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</button>
|
</button>
|
||||||
);
|
);
|
||||||
@@ -757,7 +759,7 @@ function CustomPresetCard({ isSelected, onClick }: { isSelected: boolean; onClic
|
|||||||
type="button"
|
type="button"
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
className={cn(
|
className={cn(
|
||||||
'flex h-[78px] w-[188px] flex-none items-start gap-3 rounded-xl border border-dashed px-3 py-2.5 text-left transition-all',
|
'flex h-[68px] w-[236px] flex-none items-center gap-3 rounded-xl border border-dashed px-3 py-2.5 text-left transition-all',
|
||||||
isSelected
|
isSelected
|
||||||
? 'border-primary bg-primary/8 shadow-sm ring-1 ring-primary/10'
|
? 'border-primary bg-primary/8 shadow-sm ring-1 ring-primary/10'
|
||||||
: 'border-muted-foreground/30 bg-background hover:border-primary/40 hover:bg-accent/20'
|
: 'border-muted-foreground/30 bg-background hover:border-primary/40 hover:bg-accent/20'
|
||||||
@@ -766,13 +768,10 @@ function CustomPresetCard({ isSelected, onClick }: { isSelected: boolean; onClic
|
|||||||
<div className="flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-dashed border-current/30 bg-muted/70">
|
<div className="flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-dashed border-current/30 bg-muted/70">
|
||||||
<Settings2 className="h-4 w-4 text-muted-foreground" />
|
<Settings2 className="h-4 w-4 text-muted-foreground" />
|
||||||
</div>
|
</div>
|
||||||
<div className="min-w-0 flex-1 space-y-1">
|
<div className="min-w-0 flex-1">
|
||||||
<div className="text-sm font-semibold leading-tight">
|
<div className="text-sm font-semibold leading-tight">
|
||||||
{t('profileEditor.customEndpoint')}
|
{t('profileEditor.customEndpoint')}
|
||||||
</div>
|
</div>
|
||||||
<p className="text-[11px] leading-4 text-muted-foreground" style={CARD_META_CLAMP_STYLE}>
|
|
||||||
{t('profileEditor.customEndpointDescription')}
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
</button>
|
</button>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ describe('ProfileCreateDialog', () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
expect(screen.getByText('Featured Providers')).toBeInTheDocument();
|
expect(screen.getByText('Featured Providers')).toBeInTheDocument();
|
||||||
expect(screen.getByText('Alibaba Coding Plan')).not.toHaveClass('truncate');
|
expect(screen.getByText('Alibaba Coding Plan')).toBeVisible();
|
||||||
const morePresetsToggle = screen.getByRole('button', { name: /More Presets/i });
|
const morePresetsToggle = screen.getByRole('button', { name: /More Presets/i });
|
||||||
expect(morePresetsToggle).toHaveAttribute('aria-expanded', 'false');
|
expect(morePresetsToggle).toHaveAttribute('aria-expanded', 'false');
|
||||||
expect(document.body.querySelectorAll('.overflow-x-auto')).toHaveLength(1);
|
expect(document.body.querySelectorAll('.overflow-x-auto')).toHaveLength(1);
|
||||||
|
|||||||
Reference in new issue
Block a user