Skip to content

Commit fb858a1

Browse files
authored
Tweaks to AIChatButton and AIChatInput (#3539)
1 parent cc2e615 commit fb858a1

File tree

8 files changed

+28
-26
lines changed

8 files changed

+28
-26
lines changed

.changeset/honest-eagles-judge.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"gitbook": patch
3+
---
4+
5+
Tweaks to AIChatButton and AIChatInput

packages/gitbook/e2e/internal.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ const searchTestCases: Test[] = [
227227
}),
228228
screenshot: false,
229229
run: async (page) => {
230-
await page.keyboard.press('ControlOrMeta+J');
230+
await page.keyboard.press('ControlOrMeta+I');
231231
await expect(page.getByTestId('ai-chat')).toBeVisible();
232232
await expect(page.getByTestId('ai-chat-input')).toBeFocused();
233233
},

packages/gitbook/src/components/AIChat/AIChat.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
type AIChatState,
1010
useAIChatController,
1111
useAIChatState,
12-
} from '../AI/useAIChat';
12+
} from '../AI';
1313
import { useNow } from '../hooks';
1414
import { Button } from '../primitives';
1515
import { DropdownMenu, DropdownMenuItem } from '../primitives/DropdownMenu';
@@ -24,7 +24,7 @@ export function AIChat(props: { trademark: boolean }) {
2424
const chatController = useAIChatController();
2525

2626
useHotkeys(
27-
'mod+j',
27+
'mod+i',
2828
(e) => {
2929
e.preventDefault();
3030
chatController.open();

packages/gitbook/src/components/AIChat/AIChatButton.tsx

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { useLanguage } from '@/intl/client';
33
import { t } from '@/intl/translate';
44
import { tcls } from '@/lib/tailwind';
5-
import { useAIChatController, useAIChatState } from '../AI/useAIChat';
5+
import { useAIChatController } from '../AI';
66
import { Button } from '../primitives';
77
import { KeyboardShortcut } from '../primitives/KeyboardShortcut';
88
import { getAIChatName } from './AIChat';
@@ -14,7 +14,6 @@ import { AIChatIcon } from './AIChatIcon';
1414
export function AIChatButton(props: { trademark: boolean }) {
1515
const { trademark } = props;
1616
const chatController = useAIChatController();
17-
const chat = useAIChatState();
1817
const language = useLanguage();
1918

2019
return (
@@ -28,15 +27,11 @@ export function AIChatButton(props: { trademark: boolean }) {
2827
label={
2928
<div className="flex items-center gap-2">
3029
{t(language, 'ai_chat_ask', getAIChatName(trademark))}
31-
<KeyboardShortcut keys={['mod', 'j']} className="border-tint-11 text-tint-1" />
30+
<KeyboardShortcut keys={['mod', 'i']} className="border-tint-11 text-tint-1" />
3231
</div>
3332
}
3433
onClick={() => {
35-
if (chat.opened) {
36-
chatController.close();
37-
} else {
38-
chatController.open();
39-
}
34+
chatController.open();
4035
}}
4136
/>
4237
);

packages/gitbook/src/components/AIChat/AIChatInput.tsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export function AIChatInput(props: {
4545
}, [disabled, loading]);
4646

4747
useHotkeys(
48-
'mod+j',
48+
'mod+i',
4949
(e) => {
5050
e.preventDefault();
5151
inputRef.current?.focus();
@@ -54,7 +54,7 @@ export function AIChatInput(props: {
5454
);
5555

5656
return (
57-
<div className="relative flex flex-col overflow-hidden circular-corners:rounded-2xl rounded-corners:rounded-md bg-tint-base/9 ring-1 ring-tint-subtle backdrop-blur-lg transition-all depth-subtle:has-[textarea:focus]:shadow-lg has-[textarea:focus]:ring-2 has-[textarea:focus]:ring-primary-hover contrast-more:bg-tint-base">
57+
<div className="depth-subtle:has-[textarea:focus]:-translate-y-px relative flex flex-col overflow-hidden circular-corners:rounded-2xl rounded-corners:rounded-md bg-tint-base/9 depth-subtle:shadow-sm shadow-tint/6 ring-1 ring-tint-subtle backdrop-blur-lg transition-all depth-subtle:has-[textarea:focus]:shadow-lg has-[textarea:focus]:shadow-primary-subtle has-[textarea:focus]:ring-2 has-[textarea:focus]:ring-primary-hover contrast-more:bg-tint-base dark:shadow-tint-1">
5858
<textarea
5959
ref={inputRef}
6060
disabled={disabled || loading}
@@ -99,10 +99,12 @@ export function AIChatInput(props: {
9999
}
100100
}}
101101
/>
102-
<div className="absolute top-2.5 right-3 animate-[fadeIn_0.2s_0.5s_ease-in-out_both] peer-focus:hidden">
103-
<KeyboardShortcut keys={['mod', 'j']} />
104-
</div>
105-
<div className="absolute inset-x-0 bottom-0 flex items-center px-2 py-2">
102+
{!disabled ? (
103+
<div className="absolute top-2.5 right-3 animate-[fadeIn_0.2s_0.5s_ease-in-out_both] peer-focus:hidden">
104+
<KeyboardShortcut keys={['mod', 'i']} className="bg-tint-base" />
105+
</div>
106+
) : null}
107+
<div className="absolute inset-x-0 bottom-0 flex items-center gap-2 px-2 py-2">
106108
<Tooltip
107109
label={
108110
<div className="flex flex-col gap-3 p-2">
@@ -126,11 +128,11 @@ export function AIChatInput(props: {
126128
}
127129
arrow
128130
>
129-
<div className="flex cursor-help items-center gap-1 circular-corners:rounded-2xl rounded-corners:rounded-md px-2 py-1 text-tint/7 text-xs transition-all hover:bg-tint">
131+
<div className="flex cursor-help items-center gap-1 circular-corners:rounded-2xl rounded-corners:rounded-md px-2.5 py-1.5 text-tint/7 text-xs transition-all hover:bg-tint">
130132
<span className="-ml-1 circular-corners:rounded-2xl rounded-corners:rounded-sm bg-tint-11/7 px-1 py-0.5 font-mono font-semibold text-[0.65rem] text-contrast-tint-11 leading-none">
131133
{t(language, 'ai_chat_context_badge')}
132134
</span>{' '}
133-
<span>{t(language, 'ai_chat_context_title')}</span>
135+
<span className="leading-none">{t(language, 'ai_chat_context_title')}</span>
134136
</div>
135137
</Tooltip>
136138
<Button

packages/gitbook/src/components/AIChat/AIChatMessages.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { tcls } from '@/lib/tailwind';
22
import { AIMessageRole } from '@gitbook/api';
33
import type React from 'react';
4-
import type { AIChatController, AIChatState } from '../AI/useAIChat';
4+
import type { AIChatController, AIChatState } from '../AI';
55
import { AIResponseFeedback } from './AIResponseFeedback';
66
import { AIChatFollowupSuggestions } from './AiChatFollowupSuggestions';
77

packages/gitbook/src/components/AIChat/AIChatSuggestedQuestions.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { tString, useLanguage } from '@/intl/client';
2-
import type { AIChatController } from '../AI/useAIChat';
2+
import type { AIChatController } from '../AI';
33
import { Button } from '../primitives';
44

55
export default function AIChatSuggestedQuestions(props: { chatController: AIChatController }) {

packages/gitbook/src/components/primitives/Button.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,16 @@ export const variantClasses = {
3131
'hover:text-contrast-primary-solid-hover',
3232
'border-0',
3333
'contrast-more:border',
34-
'disabled:bg-tint',
35-
'disabled:text-tint/8',
34+
'disabled:bg-primary-subtle',
35+
'disabled:text-primary/8',
3636
],
3737
blank: [
3838
'bg-transparent',
3939
'text-tint',
4040
'border-0',
4141
'shadow-none!',
42-
'hover:bg-primary-hover',
43-
'hover:text-primary-strong',
42+
'hover:bg-tint-hover',
43+
'hover:text-tint-strong',
4444
'contrast-more:bg-tint-subtle',
4545
'hover:depth-subtle:translate-y-0',
4646
'disabled:text-tint/8',
@@ -52,7 +52,7 @@ export const variantClasses = {
5252
'text-tint',
5353
'hover:bg-tint-hover',
5454
'hover:depth-flat:bg-tint-hover',
55-
'hover:text-primary',
55+
'hover:text-tint',
5656
'contrast-more:bg-tint-subtle',
5757
'disabled:bg-transparent',
5858
'disabled:text-tint/8',

0 commit comments

Comments
 (0)