WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit a66fd61

Browse files
wip selector in chat
1 parent 93295f8 commit a66fd61

File tree

4 files changed

+84
-1
lines changed

4 files changed

+84
-1
lines changed

newIDE/app/src/AiGeneration/AiRequestChat/index.js

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import {
3333
} from '../AiRequestUtils';
3434
import TwoStatesButton from '../../UI/TwoStatesButton';
3535
import Help from '../../UI/CustomSvgIcons/Help';
36+
import HelpQuestion from '../../UI/CustomSvgIcons/HelpQuestion';
3637
import Hammer from '../../UI/CustomSvgIcons/Hammer';
3738
import { ChatMessages } from './ChatMessages';
3839
import Send from '../../UI/CustomSvgIcons/Send';
@@ -51,6 +52,8 @@ import GoldCompact from '../../Profile/Subscription/Icons/GoldCompact';
5152
import { SubscriptionContext } from '../../Profile/Subscription/SubscriptionContext';
5253
import { CreditsPackageStoreContext } from '../../AssetStore/CreditsPackages/CreditsPackageStoreContext';
5354
import Paper from '../../UI/Paper';
55+
import SelectOption from '../../UI/SelectOption';
56+
import CompactSelectField from '../../UI/CompactSelectField';
5457

5558
const TOO_MANY_USER_MESSAGES_WARNING_COUNT = 10;
5659
const TOO_MANY_USER_MESSAGES_ERROR_COUNT = 15;
@@ -1042,8 +1045,29 @@ export const AiRequestChat = React.forwardRef<Props, AiRequestChatInterface>(
10421045
noMargin
10431046
expand
10441047
alignItems="center"
1045-
justifyContent="flex-end"
1048+
justifyContent="space-between"
10461049
>
1050+
<CompactSelectField
1051+
disabled={isWorking}
1052+
value={aiRequestMode}
1053+
onChange={value => {
1054+
if (value !== 'chat' && value !== 'agent') {
1055+
return;
1056+
}
1057+
setAiState({ mode: value, aiRequestId });
1058+
}}
1059+
renderOptionIcon={className =>
1060+
aiRequestMode === 'chat' ? (
1061+
<HelpQuestion className={className} />
1062+
) : (
1063+
<Hammer className={className} />
1064+
)
1065+
}
1066+
rounded
1067+
>
1068+
<SelectOption key="chat" value="chat" label={t`Ask`} />
1069+
<SelectOption key="agent" value="agent" label={t`Build`} />
1070+
</CompactSelectField>
10471071
{isForAnotherProjectText || errorText || priceAndRequestsText}
10481072
</Line>
10491073
}

newIDE/app/src/UI/CompactSelectField/CompactSelectField.module.css

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
align-items: center;
44
min-width: 0px;
55
}
6+
.container.rounded {
7+
border-radius: 24px;
8+
}
69

710
.compactSelectField {
811
border-radius: 4px;
@@ -79,6 +82,10 @@
7982
min-width: 0px;
8083
}
8184

85+
.compactSelectField.withOptionIcon select {
86+
padding-left: 30px;
87+
}
88+
8289
.compactSelectField select::placeholder {
8390
color: var(--theme-text-field-placeholder-color);
8491
}
@@ -146,3 +153,18 @@ svg.leftIcon {
146153
.container:not(.disabled):focus-within .leftIcon {
147154
color: var(--theme-text-default-color);
148155
}
156+
157+
.optionIconContainer {
158+
pointer-events: none;
159+
position: absolute;
160+
top: 2px;
161+
left: 4px;
162+
display: flex;
163+
align-items: center;
164+
}
165+
.optionIcon {
166+
font-size: 18px;
167+
}
168+
.container.disabled .optionIcon {
169+
color: var(--theme-text-field-disabled-color);
170+
}

newIDE/app/src/UI/CompactSelectField/index.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ type Props = {|
1414
children: React.Node,
1515
renderLeftIcon?: (className: string) => React.Node,
1616
leftIconTooltip?: React.Node,
17+
renderOptionIcon?: (className: string) => React.Node,
18+
rounded?: boolean,
1719
|};
1820

1921
const CompactSelectField = ({
@@ -24,14 +26,17 @@ const CompactSelectField = ({
2426
errored,
2527
children,
2628
renderLeftIcon,
29+
renderOptionIcon,
2730
leftIconTooltip,
31+
rounded,
2832
}: Props) => {
2933
return (
3034
<div
3135
className={classNames({
3236
[classes.container]: true,
3337
[classes.disabled]: disabled,
3438
[classes.errored]: errored,
39+
[classes.rounded]: rounded,
3540
})}
3641
>
3742
{renderLeftIcon && (
@@ -60,8 +65,14 @@ const CompactSelectField = ({
6065
<div
6166
className={classNames({
6267
[classes.compactSelectField]: true,
68+
[classes.withOptionIcon]: !!renderOptionIcon,
6369
})}
6470
>
71+
{renderOptionIcon && (
72+
<div className={classes.optionIconContainer}>
73+
{renderOptionIcon(classes.optionIcon)}
74+
</div>
75+
)}
6576
<select
6677
id={id}
6778
disabled={disabled}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import React from 'react';
2+
import SvgIcon from '@material-ui/core/SvgIcon';
3+
4+
export default React.memo(props => (
5+
<SvgIcon
6+
{...props}
7+
width="16"
8+
height="16"
9+
viewBox="0 0 16 16"
10+
fill="none"
11+
xmlns="http://www.w3.org/2000/svg"
12+
>
13+
<path
14+
d="M7.50004 9.33337C7.50004 8.75897 7.62133 8.3179 7.82556 7.95706C8.02491 7.60489 8.28686 7.36064 8.49874 7.16996C8.72526 6.9661 8.87687 6.8355 8.99028 6.6654C9.08917 6.51707 9.16671 6.32278 9.16671 6.00003C9.16671 5.56077 8.99983 5.2639 8.77022 5.06904C8.5297 4.86497 8.19128 4.75003 7.83337 4.75003C7.47547 4.75003 7.13704 4.86497 6.89653 5.06904C6.66692 5.2639 6.50004 5.56076 6.50004 6.00003C6.50004 6.27618 6.27618 6.50003 6.00004 6.50003C5.7239 6.50003 5.50004 6.27618 5.50004 6.00003C5.50004 5.27269 5.79154 4.6945 6.24939 4.30602C6.69636 3.92681 7.27464 3.75003 7.83337 3.75003C8.3921 3.75003 8.97039 3.92681 9.41736 4.30602C9.87521 4.6945 10.1667 5.27269 10.1667 6.00003C10.1667 6.51062 10.0359 6.89968 9.82231 7.22009C9.62323 7.5187 9.35815 7.74232 9.16801 7.91344C8.96324 8.09773 8.80849 8.2494 8.69535 8.44925C8.58712 8.64047 8.50004 8.90782 8.50004 9.33337C8.50001 9.60948 8.27616 9.83337 8.00004 9.83337C7.72392 9.83337 7.50007 9.60948 7.50004 9.33337Z"
15+
fill="currentColor"
16+
/>
17+
<path
18+
d="M7.63546 11.6647C7.82023 11.4597 8.13605 11.443 8.34119 11.6276C8.54633 11.8124 8.56306 12.1288 8.3783 12.3339L8.37179 12.3411C8.18697 12.5463 7.87057 12.563 7.66541 12.3782C7.46024 12.1934 7.44348 11.877 7.6283 11.6718L7.63546 11.6647Z"
19+
fill="currentColor"
20+
/>
21+
<path
22+
d="M14.1667 8.00004C14.1667 4.59428 11.4058 1.83337 8.00004 1.83337C4.59428 1.83337 1.83337 4.59428 1.83337 8.00004C1.83337 9.12401 2.13389 10.1762 2.65824 11.0827C2.718 11.186 2.73868 11.3079 2.71684 11.4252L2.29171 13.7077L4.57491 13.2832L4.66345 13.2748C4.75193 13.2742 4.83985 13.297 4.91736 13.3418C5.82386 13.8662 6.87608 14.1667 8.00004 14.1667C11.4058 14.1667 14.1667 11.4058 14.1667 8.00004ZM15.1667 8.00004C15.1667 11.958 11.958 15.1667 8.00004 15.1667C6.76239 15.1667 5.59699 14.852 4.58012 14.2989L1.7585 14.8249C1.59647 14.8551 1.42974 14.8034 1.31319 14.6869C1.19665 14.5703 1.145 14.4036 1.17517 14.2416L1.70056 11.4193C1.14763 10.4026 0.833374 9.23737 0.833374 8.00004C0.833374 4.042 4.042 0.833374 8.00004 0.833374C11.958 0.833374 15.1667 4.042 15.1667 8.00004Z"
23+
fill="currentColor"
24+
/>
25+
</SvgIcon>
26+
));

0 commit comments

Comments
 (0)