Skip to content

Commit 9a76aa4

Browse files
💄 style: Add collapseOffset
1 parent ae271c4 commit 9a76aa4

5 files changed

Lines changed: 29 additions & 4 deletions

File tree

src/react/ChatInput/demos/ActionToolbar.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const ActionToolbar = memo<ActionToolbarProps>(
2727
<ChatInputActionBar
2828
left={
2929
<ChatInputActions
30+
collapseOffset={48}
3031
items={[
3132
{
3233
icon: showTypobar ? RemoveFormattingIcon : TypeIcon,

src/react/ChatInputActions/ChatInputActions.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { useStyles } from './style';
1111
import type { ActionItem, ChatInputActionsProps, CollapseItem, DividerItem } from './type';
1212

1313
const ChatInputActions = memo<ChatInputActionsProps>(
14-
({ gap = 2, disabled, items = [], onActionClick, className, ...rest }) => {
14+
({ gap = 2, disabled, items = [], onActionClick, className, collapseOffset = 0, ...rest }) => {
1515
const { cx, styles } = useStyles();
1616
const [maxCount, setMaxCount] = useState(items.length);
1717
const [collapsed, setCollapsed] = useState(false);
@@ -34,14 +34,14 @@ const ChatInputActions = memo<ChatInputActionsProps>(
3434
useEffect(() => {
3535
if (!size?.width) return;
3636
const length = flatItems.length + 1;
37-
const calcMaxCount = Math.floor(size.width / 48);
37+
const calcMaxCount = Math.floor((size.width - collapseOffset) / 38);
3838
setMaxCount(calcMaxCount);
3939
if (calcMaxCount < length) {
4040
setCollapsed(true);
4141
} else {
4242
setCollapsed(false);
4343
}
44-
}, [size, flatItems.length]);
44+
}, [size, flatItems.length, collapseOffset]);
4545

4646
const calcItem = useMemo(() => {
4747
if (!collapsed) return items;

src/react/ChatInputActions/type.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export type DropdownItem = Omit<ActionItem, 'children' | 'type'> & {
3131
export type ChatInputActionItem = ActionItem | DividerItem | CollapseItem | DropdownItem;
3232

3333
export interface ChatInputActionsProps extends Omit<FlexboxProps, 'children'> {
34+
collapseOffset?: number;
3435
disabled?: boolean;
3536
items?: ChatInputActionItem[];
3637
onActionClick?: (action: ChatInputActionEvent) => void;

src/react/SendButton/SendButton.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const SendButton = memo<SendButtonProps>(
2222
shape,
2323
onSend,
2424
onStop,
25+
disabled,
2526
onClick,
2627
...rest
2728
}) => {
@@ -67,7 +68,8 @@ const SendButton = memo<SendButtonProps>(
6768
if (!menu)
6869
return (
6970
<Button
70-
className={cx(styles.button, className)}
71+
className={cx(styles.button, disabled && styles.disabled, className)}
72+
disabled={disabled}
7173
icon={<SendIcon />}
7274
onClick={(e) => {
7375
e.stopPropagation();
@@ -86,9 +88,11 @@ const SendButton = memo<SendButtonProps>(
8688
<Dropdown.Button
8789
className={cx(
8890
styles.dropdownButton,
91+
disabled && styles.disabled,
8992
shape === 'round' && styles.dropdownButtonRound,
9093
className,
9194
)}
95+
disabled={disabled}
9296
icon={<Icon icon={ChevronDownIcon} />}
9397
menu={menu}
9498
onClick={(e) => {

src/react/SendButton/style.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,25 @@ export const useStyles = createStyles(({ css, token, prefixCls }, size: number)
1010
padding-inline: 0 !important;
1111
}
1212
`,
13+
disabled: css`
14+
&.${prefixCls}-btn {
15+
cursor: default;
16+
border-color: ${token.colorBorderSecondary};
17+
background: transparent;
18+
}
19+
20+
.${prefixCls}-btn-compact-first-item {
21+
cursor: default;
22+
border-color: ${token.colorBorderSecondary};
23+
background: transparent;
24+
}
25+
.${prefixCls}-dropdown-trigger {
26+
cursor: default;
27+
border-color: ${token.colorBorderSecondary};
28+
border-inline-start-color: transparent;
29+
background: transparent;
30+
}
31+
`,
1332
dropdownButton: css`
1433
flex: none;
1534
width: fit-content;

0 commit comments

Comments
 (0)