Skip to content

Commit 7ac09ec

Browse files
committed
Add landscape placeholders to configurations component for empty state layout
- for landscape, header is using with special alignment tricks of hidden elements when the prompt field shows status bar. In configurations the empty text should do it as well - [Pasted text] should be rendered rightbelow the empty text - should not repeat [Fragment] - empty_landscape_placeholder_above should render in the same div as 'empty' message
1 parent f6f6e75 commit 7ac09ec

5 files changed

Lines changed: 107 additions & 47 deletions

File tree

‎apps/editor/src/views/prompt/frontend/Main/MainView/MainView.tsx‎

Lines changed: 78 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,29 @@ export const MainView: React.FC<Props> = (props) => {
283283
/>
284284
)
285285

286+
const prompt_attachments = (
287+
<PromptAttachments
288+
token_count={props.selected_files_token_count}
289+
files_count={props.selected_files.length}
290+
theme={
291+
props.target == TARGET.WEB
292+
? props.web_prompt_type == 'edit-files'
293+
? 'blue'
294+
: 'purple'
295+
: props.api_prompt_type == 'edit-files'
296+
? 'blue'
297+
: 'purple'
298+
}
299+
is_alt_pressed={is_alt_pressed}
300+
on_agentic_search={props.on_agentic_search}
301+
translations={{
302+
attaching_file: t('selected-files.attaching-file'),
303+
attaching_files: t('selected-files.attaching-files'),
304+
agentic_search: t('selected-files.agentic-search')
305+
}}
306+
/>
307+
)
308+
286309
const prompt_section = (
287310
<>
288311
<UiSpacer height={is_landscape ? 6 : 2} />
@@ -471,37 +494,70 @@ export const MainView: React.FC<Props> = (props) => {
471494
]}
472495
/>
473496
) : (
474-
<PromptAttachments
475-
token_count={props.selected_files_token_count}
476-
files_count={props.selected_files.length}
477-
theme={
478-
props.target == TARGET.WEB
479-
? props.web_prompt_type == 'edit-files'
480-
? 'blue'
481-
: 'purple'
482-
: props.api_prompt_type == 'edit-files'
483-
? 'blue'
484-
: 'purple'
485-
}
486-
is_alt_pressed={is_alt_pressed}
487-
on_agentic_search={props.on_agentic_search}
488-
translations={{
489-
attaching_file: t('selected-files.attaching-file'),
490-
attaching_files: t('selected-files.attaching-files'),
491-
agentic_search: t('selected-files.agentic-search')
492-
}}
493-
/>
497+
prompt_attachments
494498
)}
495499

496500
{is_landscape && <UiSpacer height={6} />}
497501
</>
498502
)
499503

504+
const configurations_placeholder_above = (
505+
<>
506+
{props.target == TARGET.WEB && !browser_connection.is_closed && (
507+
<>
508+
<UiStatusBar
509+
icon="codicon-debug-disconnect"
510+
label=""
511+
actions={[
512+
{
513+
id: 'install',
514+
icon: 'codicon-add',
515+
label: '',
516+
title: '',
517+
on_click: () => {}
518+
}
519+
]}
520+
/>
521+
<UiSpacer height={6} />
522+
</>
523+
)}
524+
{props.target == TARGET.API && is_api_warning_visible && (
525+
<>
526+
<UiStatusBar
527+
icon="codicon-warning"
528+
label=""
529+
actions={[
530+
{
531+
id: 'settings',
532+
icon: 'codicon-gear',
533+
label: '',
534+
title: '',
535+
on_click: () => {}
536+
}
537+
]}
538+
/>
539+
<UiSpacer height={6} />
540+
</>
541+
)}
542+
</>
543+
)
544+
545+
const configurations_placeholder_below = (
546+
<>
547+
{props.target == TARGET.WEB && !browser_connection.is_closed && (
548+
<div style={{ visibility: 'hidden', pointerEvents: 'none' }}>
549+
{prompt_attachments}
550+
</div>
551+
)}
552+
</>
553+
)
554+
500555
const configurations_section = (
501556
<>
502557
{props.target == TARGET.WEB && (
503558
<UiConfigurations
504559
configurations={web_configurations}
560+
empty_landscape_placeholder_above={configurations_placeholder_above}
505561
is_dimmed={is_context_empty || !props.is_connected}
506562
on_create={(params) => {
507563
props.on_create_web_configuration(params)
@@ -553,6 +609,8 @@ export const MainView: React.FC<Props> = (props) => {
553609
on_delete={props.on_delete_api_configuration}
554610
selected_configuration_id={props.selected_api_configuration_id}
555611
on_create={props.on_create_api_configuration}
612+
empty_landscape_placeholder_above={configurations_placeholder_above}
613+
empty_landscape_placeholder_below={configurations_placeholder_below}
556614
translations={{
557615
empty: t('configurations.empty'),
558616
add_new: t('action.add-new'),

‎apps/editor/src/views/prompt/frontend/Prompt.module.scss‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
.container {
2-
position: absolute;
3-
width: 100%;
4-
height: 100%;
5-
background-color: var(--vscode-sideBar-background);
6-
}
7-
81
.slot {
92
position: absolute;
103
z-index: 1;

‎apps/editor/src/views/prompt/frontend/Prompt.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ export const Prompt = () => {
254254

255255
return (
256256
<LayoutContext.Provider value={layout_context_value}>
257-
<div className={styles.container} data-modern-ui={is_modern_ui}>
257+
<div data-modern-ui={is_modern_ui}>
258258
<div className={styles.slot}>
259259
<Layout on_history_click={handle_history_click}>
260260
<div

‎packages/ui/src/components/editor/prompt/Configurations/Configurations.module.scss‎

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -118,19 +118,32 @@
118118

119119
.empty {
120120
display: flex;
121+
flex-direction: column;
121122
align-items: center;
122123
text-align: center;
123124
font-style: italic;
124125
justify-content: center;
125126
padding: 4px 12px 3px 12px;
126127
flex: 1;
128+
gap: 12px;
127129
color: var(--cwc-text-color-dimmed);
128130

129131
@include modern-ui {
130132
padding: 4px 10px 3px 10px;
131133
}
132134
}
133135

136+
.landscape-placeholder {
137+
display: none;
138+
visibility: hidden;
139+
pointer-events: none;
140+
141+
@include landscape {
142+
display: flex;
143+
flex-direction: column;
144+
}
145+
}
146+
134147
.footer {
135148
display: flex;
136149
padding: 10px 12px 0 12px;
@@ -142,14 +155,4 @@
142155
> button {
143156
flex: 1;
144157
}
145-
146-
&--landscape-placeholder {
147-
display: none;
148-
visibility: hidden;
149-
pointer-events: none;
150-
151-
@include landscape {
152-
display: flex;
153-
}
154-
}
155158
}

‎packages/ui/src/components/editor/prompt/Configurations/Configurations.tsx‎

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ export namespace Configurations {
2727
on_edit: (id: string) => void
2828
on_delete: (id: string) => void
2929
is_dimmed?: boolean
30+
empty_landscape_placeholder_above?: React.ReactNode
31+
empty_landscape_placeholder_below?: React.ReactNode
3032
translations: {
3133
empty: string
3234
add_new: string
@@ -139,13 +141,6 @@ export const Configurations: React.FC<Configurations.Props> = (props) => {
139141

140142
return (
141143
<div className={styles.container}>
142-
{props.configurations.length == 0 && (
143-
<div
144-
className={cn(styles.footer, styles['footer--landscape-placeholder'])}
145-
>
146-
<Button>{props.translations.add_new}</Button>
147-
</div>
148-
)}
149144
<div className={styles.list}>
150145
{pinned_configurations.length > 0 && (
151146
<>
@@ -154,16 +149,27 @@ export const Configurations: React.FC<Configurations.Props> = (props) => {
154149
render_configuration_item(
155150
i,
156151
true,
157-
props.configurations.findIndex((c) => c.id === i.id)
152+
props.configurations.findIndex((c) => c.id == i.id)
158153
)
159154
)}
160155
</div>
161156
<div className={styles.separator} />
162157
</>
163158
)}
164159
{props.configurations.length == 0 && (
165-
<div className={styles.empty}>{props.translations.empty}</div>
160+
<div className={styles.empty}>
161+
<div className={styles['landscape-placeholder']}>
162+
{props.empty_landscape_placeholder_above}
163+
</div>
164+
{props.translations.empty}
165+
{props.empty_landscape_placeholder_below && (
166+
<div className={styles['landscape-placeholder']}>
167+
{props.empty_landscape_placeholder_below}
168+
</div>
169+
)}
170+
</div>
166171
)}
172+
167173
<div className={styles.configurations}>
168174
<ReactSortable
169175
list={props.configurations}

0 commit comments

Comments
 (0)