style: adjust copilot chat style (#2915)
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import { Button, Input } from '@affine/component';
|
import { IconButton } from '@affine/component';
|
||||||
|
import { SendIcon } from '@blocksuite/icons';
|
||||||
import { rootStore } from '@toeverything/plugin-infra/manager';
|
import { rootStore } from '@toeverything/plugin-infra/manager';
|
||||||
import type { PluginUIAdapter } from '@toeverything/plugin-infra/type';
|
import type { PluginUIAdapter } from '@toeverything/plugin-infra/type';
|
||||||
import { Provider, useAtomValue, useSetAtom } from 'jotai';
|
import { Provider, useAtomValue, useSetAtom } from 'jotai';
|
||||||
@@ -12,8 +13,8 @@ import { openAIApiKeyAtom, useChatAtoms } from '../core/hooks';
|
|||||||
import {
|
import {
|
||||||
detailContentActionsStyle,
|
detailContentActionsStyle,
|
||||||
detailContentStyle,
|
detailContentStyle,
|
||||||
inputStyle,
|
|
||||||
sendButtonStyle,
|
sendButtonStyle,
|
||||||
|
textareaStyle,
|
||||||
} from './index.css';
|
} from './index.css';
|
||||||
|
|
||||||
if (typeof window === 'undefined') {
|
if (typeof window === 'undefined') {
|
||||||
@@ -71,22 +72,23 @@ const Actions = () => {
|
|||||||
<>
|
<>
|
||||||
<FollowingUp questions={questions} />
|
<FollowingUp questions={questions} />
|
||||||
<div className={detailContentActionsStyle}>
|
<div className={detailContentActionsStyle}>
|
||||||
<Input
|
<textarea
|
||||||
className={inputStyle}
|
className={textareaStyle}
|
||||||
value={input}
|
value={input}
|
||||||
onChange={text => {
|
placeholder="Type here ask Copilot some thing..."
|
||||||
setInput(text);
|
onChange={e => {
|
||||||
|
setInput(e.target.value);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<Button
|
<IconButton
|
||||||
className={sendButtonStyle}
|
className={sendButtonStyle}
|
||||||
onClick={useCallback(async () => {
|
onClick={useCallback(async () => {
|
||||||
await call(input);
|
await call(input);
|
||||||
await generateFollowingUp();
|
await generateFollowingUp();
|
||||||
}, [call, generateFollowingUp, input])}
|
}, [call, generateFollowingUp, input])}
|
||||||
>
|
>
|
||||||
send
|
<SendIcon />
|
||||||
</Button>
|
</IconButton>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -13,15 +13,31 @@ export const detailContentStyle = style({
|
|||||||
|
|
||||||
export const detailContentActionsStyle = style({
|
export const detailContentActionsStyle = style({
|
||||||
marginTop: 'auto',
|
marginTop: 'auto',
|
||||||
alignItems: 'flex-end',
|
|
||||||
marginBottom: '10px',
|
marginBottom: '10px',
|
||||||
fontSize: 'var(--affine-font-xs)',
|
fontSize: 'var(--affine-font-xs)',
|
||||||
|
display: 'flex',
|
||||||
|
width: '100%',
|
||||||
|
justifyContent: 'space-between',
|
||||||
});
|
});
|
||||||
export const inputStyle = style({
|
export const textareaStyle = style({
|
||||||
fontSize: 'var(--affine-font-xs)',
|
fontSize: 'var(--affine-font-xs)',
|
||||||
|
border: '1px solid var(--affine-border-color)',
|
||||||
|
width: '100%',
|
||||||
|
borderRadius: '4px',
|
||||||
|
background: 'var(--affine-hover-color)',
|
||||||
|
height: '117px',
|
||||||
|
padding: '8px 10px',
|
||||||
|
'::placeholder': {
|
||||||
|
color: 'var(--affine-text-secondary-color)',
|
||||||
|
},
|
||||||
});
|
});
|
||||||
export const sendButtonStyle = style({
|
export const sendButtonStyle = style({
|
||||||
marginTop: '10px',
|
|
||||||
borderRadius: '8px',
|
|
||||||
fontSize: 'var(--affine-font-xs)',
|
fontSize: 'var(--affine-font-xs)',
|
||||||
|
width: '16px',
|
||||||
|
height: '16px',
|
||||||
|
marginLeft: '8px',
|
||||||
|
':hover': {
|
||||||
|
cursor: 'pointer',
|
||||||
|
backgroundColor: 'transparent',
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { style } from '@vanilla-extract/css';
|
|||||||
export const conversationListStyle = style({
|
export const conversationListStyle = style({
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
flexDirection: 'column',
|
flexDirection: 'column',
|
||||||
gap: '30px',
|
gap: '24px',
|
||||||
height: 'calc(100% - 100px)',
|
height: 'calc(100% - 100px)',
|
||||||
overflow: 'auto',
|
overflow: 'auto',
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,18 +1,80 @@
|
|||||||
import { style } from '@vanilla-extract/css';
|
import { globalStyle, style } from '@vanilla-extract/css';
|
||||||
|
|
||||||
|
export const containerStyle = style({
|
||||||
|
display: 'flex',
|
||||||
|
width: '100%',
|
||||||
|
padding: '0 16px',
|
||||||
|
gap: '10px',
|
||||||
|
});
|
||||||
export const conversationStyle = style({
|
export const conversationStyle = style({
|
||||||
padding: '10px 18px',
|
padding: '10px 18px',
|
||||||
border: '1px solid var(--affine-border-color)',
|
border: '1px solid var(--affine-border-color)',
|
||||||
fontSize: 'var(--affine-font-xs)',
|
fontSize: 'var(--affine-font-xs)',
|
||||||
lineHeight: '16px',
|
lineHeight: '16px',
|
||||||
|
borderRadius: '18px',
|
||||||
|
position: 'relative',
|
||||||
|
});
|
||||||
|
export const conversationContainerStyle = style({
|
||||||
|
maxWidth: '90%',
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
|
position: 'relative',
|
||||||
|
});
|
||||||
|
export const insertButtonsStyle = style({
|
||||||
|
width: '100%',
|
||||||
|
marginTop: '10px',
|
||||||
|
display: 'flex',
|
||||||
|
flexWrap: 'wrap',
|
||||||
|
gap: '8px',
|
||||||
|
});
|
||||||
|
export const insertButtonStyle = style({
|
||||||
|
maxWidth: '100%',
|
||||||
|
padding: '16px 8px',
|
||||||
|
fontSize: 'var(--affine-font-xs)',
|
||||||
|
borderRadius: '8px',
|
||||||
|
border: '1px solid var(--affine-border-color)',
|
||||||
|
cursor: 'pointer',
|
||||||
|
backgroundColor: 'var(--affine-white)',
|
||||||
|
gap: '8px',
|
||||||
|
':hover': {
|
||||||
|
background: 'var(--affine-white),var(--affine-hover-color)',
|
||||||
|
borderColor: 'var(--affine-border-color)',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
export const avatarRightStyle = style({
|
||||||
|
flexDirection: 'row-reverse',
|
||||||
});
|
});
|
||||||
|
|
||||||
export const aiMessageStyle = style({
|
export const aiMessageStyle = style({
|
||||||
backgroundColor: 'rgba(207, 252, 255, 0.3)',
|
backgroundColor: 'rgba(207, 252, 255, 0.3)',
|
||||||
borderRadius: '18px 18px 18px 2px',
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export const humanMessageStyle = style({
|
export const humanMessageStyle = style({
|
||||||
borderRadius: '18px 18px 2px 18px',
|
|
||||||
backgroundColor: 'var(--affine-white-90)',
|
backgroundColor: 'var(--affine-white-90)',
|
||||||
});
|
});
|
||||||
|
export const regenerateButtonStyle = style({
|
||||||
|
position: 'absolute',
|
||||||
|
display: 'none',
|
||||||
|
right: '12px',
|
||||||
|
top: '-16px',
|
||||||
|
padding: '4px 8px',
|
||||||
|
fontSize: 'var(--affine-font-xs)',
|
||||||
|
borderRadius: '8px',
|
||||||
|
border: '1px solid var(--affine-border-color)',
|
||||||
|
cursor: 'pointer',
|
||||||
|
backgroundColor: 'var(--affine-white)',
|
||||||
|
':hover': {
|
||||||
|
background:
|
||||||
|
'linear-gradient(var(--affine-white),var(--affine-white)),var(--affine-hover-color)',
|
||||||
|
backgroundBlendMode: 'overlay',
|
||||||
|
display: 'flex',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
export const resetIconStyle = style({
|
||||||
|
fontSize: 'var(--affine-font-sm)',
|
||||||
|
display: 'inline-flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
marginRight: '4px',
|
||||||
|
});
|
||||||
|
globalStyle(`${conversationStyle}:hover ${regenerateButtonStyle}`, {
|
||||||
|
display: 'flex',
|
||||||
|
});
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
import { Button } from '@affine/component';
|
||||||
|
import { WorkspaceAvatar } from '@affine/component/workspace-avatar';
|
||||||
|
import { PlusIcon, ResetIcon } from '@blocksuite/icons';
|
||||||
import { clsx } from 'clsx';
|
import { clsx } from 'clsx';
|
||||||
import type { MessageType } from 'langchain/schema';
|
import type { MessageType } from 'langchain/schema';
|
||||||
import { marked } from 'marked';
|
import { marked } from 'marked';
|
||||||
@@ -5,11 +8,7 @@ import { gfmHeadingId } from 'marked-gfm-heading-id';
|
|||||||
import { mangle } from 'marked-mangle';
|
import { mangle } from 'marked-mangle';
|
||||||
import { type ReactElement, useMemo } from 'react';
|
import { type ReactElement, useMemo } from 'react';
|
||||||
|
|
||||||
import {
|
import * as styles from './index.css';
|
||||||
aiMessageStyle,
|
|
||||||
conversationStyle,
|
|
||||||
humanMessageStyle,
|
|
||||||
} from './index.css';
|
|
||||||
|
|
||||||
marked.use(
|
marked.use(
|
||||||
gfmHeadingId({
|
gfmHeadingId({
|
||||||
@@ -28,13 +27,53 @@ export const Conversation = (props: ConversationProps): ReactElement => {
|
|||||||
const html = useMemo(() => marked.parse(props.text), [props.text]);
|
const html = useMemo(() => marked.parse(props.text), [props.text]);
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={clsx(conversationStyle, {
|
className={clsx(styles.containerStyle, {
|
||||||
[aiMessageStyle]: props.type === 'ai',
|
[styles.avatarRightStyle]: props.type === 'human',
|
||||||
[humanMessageStyle]: props.type === 'human',
|
|
||||||
})}
|
})}
|
||||||
|
>
|
||||||
|
<WorkspaceAvatar workspace={null} />
|
||||||
|
<div className={styles.conversationContainerStyle}>
|
||||||
|
<div
|
||||||
|
className={clsx(styles.conversationStyle, {
|
||||||
|
[styles.aiMessageStyle]: props.type === 'ai',
|
||||||
|
[styles.humanMessageStyle]: props.type === 'human',
|
||||||
|
})}
|
||||||
|
>
|
||||||
|
{props.type === 'ai' ? (
|
||||||
|
<div className={styles.regenerateButtonStyle}>
|
||||||
|
<div className={styles.resetIconStyle}>
|
||||||
|
<ResetIcon />
|
||||||
|
</div>
|
||||||
|
Regenerate
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
|
<div
|
||||||
dangerouslySetInnerHTML={{
|
dangerouslySetInnerHTML={{
|
||||||
__html: html,
|
__html: html,
|
||||||
}}
|
}}
|
||||||
></div>
|
></div>
|
||||||
|
</div>
|
||||||
|
{props.type === 'ai' ? (
|
||||||
|
<div className={styles.insertButtonsStyle}>
|
||||||
|
<Button
|
||||||
|
icon={<PlusIcon />}
|
||||||
|
size="small"
|
||||||
|
className={styles.insertButtonStyle}
|
||||||
|
hoverColor="var(--affine-text-primary-color)"
|
||||||
|
>
|
||||||
|
Insert list block only
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
icon={<PlusIcon />}
|
||||||
|
size="small"
|
||||||
|
className={styles.insertButtonStyle}
|
||||||
|
hoverColor="var(--affine-text-primary-color)"
|
||||||
|
>
|
||||||
|
Insert all
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user