Skip to content

Commit c2faa55

Browse files
committed
chore: Add screenshot area to the prompt-input screen
1 parent 8093e3f commit c2faa55

File tree

1 file changed

+78
-75
lines changed

1 file changed

+78
-75
lines changed

pages/prompt-input/simple.page.tsx

Lines changed: 78 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
import AppContext, { AppContextType } from '../app/app-context';
2020
import labels from '../app-layout/utils/labels';
2121
import { i18nStrings } from '../file-upload/shared';
22+
import ScreenshotArea from '../utils/screenshot-area';
2223

2324
const MAX_CHARS = 2000;
2425

@@ -187,93 +188,95 @@ export default function PromptInputPage() {
187188
label={<span>User prompt</span>}
188189
i18nStrings={{ errorIconAriaLabel: 'Error' }}
189190
>
190-
<PromptInput
191-
data-testid="prompt-input"
192-
ariaLabel="Chat input"
193-
actionButtonIconName="send"
194-
actionButtonAriaLabel="Submit prompt"
195-
value={textareaValue}
196-
onChange={(event: any) => setTextareaValue(event.detail.value)}
197-
onAction={event => window.alert(`Submitted the following: ${event.detail.value}`)}
198-
placeholder="Ask a question"
199-
maxRows={hasInfiniteMaxRows ? -1 : 4}
200-
disabled={isDisabled}
201-
readOnly={isReadOnly}
202-
invalid={isInvalid || textareaValue.length > MAX_CHARS}
203-
warning={hasWarning}
204-
ref={ref}
205-
disableSecondaryActionsPaddings={true}
206-
customPrimaryAction={
207-
hasPrimaryActions ? (
208-
<ButtonGroup
209-
variant="icon"
210-
items={[
211-
{
212-
type: 'icon-button',
213-
id: 'record',
214-
text: 'Record',
215-
iconName: 'microphone',
216-
disabled: isDisabled || isReadOnly,
217-
},
218-
{
219-
type: 'icon-button',
220-
id: 'submit',
221-
text: 'Submit',
222-
iconName: 'send',
223-
disabled: isDisabled || isReadOnly,
224-
},
225-
]}
226-
/>
227-
) : undefined
228-
}
229-
secondaryActions={
230-
hasSecondaryActions ? (
231-
<Box padding={{ left: 'xxs', top: 'xs' }}>
191+
<ScreenshotArea disableAnimations={true}>
192+
<PromptInput
193+
data-testid="prompt-input"
194+
ariaLabel="Chat input"
195+
actionButtonIconName="send"
196+
actionButtonAriaLabel="Submit prompt"
197+
value={textareaValue}
198+
onChange={(event: any) => setTextareaValue(event.detail.value)}
199+
onAction={event => window.alert(`Submitted the following: ${event.detail.value}`)}
200+
placeholder="Ask a question"
201+
maxRows={hasInfiniteMaxRows ? -1 : 4}
202+
disabled={isDisabled}
203+
readOnly={isReadOnly}
204+
invalid={isInvalid || textareaValue.length > MAX_CHARS}
205+
warning={hasWarning}
206+
ref={ref}
207+
disableSecondaryActionsPaddings={true}
208+
customPrimaryAction={
209+
hasPrimaryActions ? (
232210
<ButtonGroup
233-
ref={buttonGroupRef}
234-
ariaLabel="Chat actions"
235-
onFilesChange={({ detail }) => detail.id.includes('files') && setFiles(detail.files)}
211+
variant="icon"
236212
items={[
237-
{
238-
type: 'icon-file-input',
239-
id: 'files',
240-
text: 'Upload files',
241-
multiple: true,
242-
},
243213
{
244214
type: 'icon-button',
245-
id: 'expand',
246-
iconName: 'expand',
247-
text: 'Go full page',
215+
id: 'record',
216+
text: 'Record',
217+
iconName: 'microphone',
248218
disabled: isDisabled || isReadOnly,
249219
},
250220
{
251221
type: 'icon-button',
252-
id: 'remove',
253-
iconName: 'remove',
254-
text: 'Remove',
222+
id: 'submit',
223+
text: 'Submit',
224+
iconName: 'send',
255225
disabled: isDisabled || isReadOnly,
256226
},
257227
]}
258-
variant="icon"
259228
/>
260-
</Box>
261-
) : undefined
262-
}
263-
secondaryContent={
264-
hasSecondaryContent && files.length > 0 ? (
265-
<FileTokenGroup
266-
items={files.map(file => ({
267-
file,
268-
}))}
269-
showFileThumbnail={true}
270-
onDismiss={onDismiss}
271-
i18nStrings={i18nStrings}
272-
alignment="horizontal"
273-
/>
274-
) : undefined
275-
}
276-
/>
229+
) : undefined
230+
}
231+
secondaryActions={
232+
hasSecondaryActions ? (
233+
<Box padding={{ left: 'xxs', top: 'xs' }}>
234+
<ButtonGroup
235+
ref={buttonGroupRef}
236+
ariaLabel="Chat actions"
237+
onFilesChange={({ detail }) => detail.id.includes('files') && setFiles(detail.files)}
238+
items={[
239+
{
240+
type: 'icon-file-input',
241+
id: 'files',
242+
text: 'Upload files',
243+
multiple: true,
244+
},
245+
{
246+
type: 'icon-button',
247+
id: 'expand',
248+
iconName: 'expand',
249+
text: 'Go full page',
250+
disabled: isDisabled || isReadOnly,
251+
},
252+
{
253+
type: 'icon-button',
254+
id: 'remove',
255+
iconName: 'remove',
256+
text: 'Remove',
257+
disabled: isDisabled || isReadOnly,
258+
},
259+
]}
260+
variant="icon"
261+
/>
262+
</Box>
263+
) : undefined
264+
}
265+
secondaryContent={
266+
hasSecondaryContent && files.length > 0 ? (
267+
<FileTokenGroup
268+
items={files.map(file => ({
269+
file,
270+
}))}
271+
showFileThumbnail={true}
272+
onDismiss={onDismiss}
273+
i18nStrings={i18nStrings}
274+
alignment="horizontal"
275+
/>
276+
) : undefined
277+
}
278+
/>
279+
</ScreenshotArea>
277280
</FormField>
278281
<div />
279282
</ColumnLayout>

0 commit comments

Comments
 (0)