Skip to content

Commit 7ded003

Browse files
authored
Merge pull request #16033 from Budibase/feat/ai-js-styling
AI JS styling fixes
2 parents 1360185 + 96b17b3 commit 7ded003

File tree

3 files changed

+87
-52
lines changed

3 files changed

+87
-52
lines changed

packages/builder/src/components/common/CodeEditor/AIGen.svelte

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@
8787
function reset() {
8888
suggestedCode = null
8989
previousContents = null
90+
promptText = ""
91+
expanded = false
9092
}
9193
9294
function calculateExpandedWidth() {
@@ -112,7 +114,6 @@
112114
placeholder="Generate with AI"
113115
onSubmit={generateJs}
114116
bind:expanded
115-
on:collapse={rejectSuggestion}
116117
readonly={!!suggestedCode}
117118
{expandedOnly}
118119
/>
@@ -130,21 +131,11 @@
130131
overflow: visible;
131132
}
132133
133-
@keyframes border-fade-in {
134-
from {
135-
opacity: 0;
136-
}
137-
to {
138-
opacity: 1;
139-
}
140-
}
141-
142134
.floating-actions {
143135
position: absolute;
144136
display: flex;
145137
gap: var(--spacing-s);
146138
bottom: calc(100% + 5px);
147-
left: 5px;
148139
z-index: 2;
149140
animation: fade-in 0.2s ease-out forwards;
150141
}

packages/builder/src/components/common/CodeEditor/CodeEditor.svelte

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
let isEditorInitialised = false
8989
let queuedRefresh = false
9090
let editorWidth: number | null = null
91+
let isAIGeneratedContent = false
9192
9293
// Theming!
9394
let currentTheme = $themeStore?.theme
@@ -429,6 +430,7 @@
429430
editor.dispatch({
430431
changes: { from: 0, to: editor.state.doc.length, insert: code },
431432
})
433+
isAIGeneratedContent = true
432434
}
433435
434436
onMount(() => {
@@ -462,7 +464,12 @@
462464
</div>
463465
{/if}
464466

465-
<div class={`code-editor ${mode?.name || ""}`} bind:this={editorEle}>
467+
<div
468+
class={`code-editor ${mode?.name || ""} ${
469+
isAIGeneratedContent ? "ai-generated" : ""
470+
}`}
471+
bind:this={editorEle}
472+
>
466473
<div tabindex="-1" bind:this={textarea} />
467474
</div>
468475

@@ -475,13 +482,15 @@
475482
on:accept={() => {
476483
dispatch("change", editor.state.doc.toString())
477484
dispatch("blur", editor.state.doc.toString())
485+
isAIGeneratedContent = false
478486
}}
479487
on:reject={event => {
480488
const { code } = event.detail
481489
value = code || ""
482490
editor.dispatch({
483491
changes: { from: 0, to: editor.state.doc.length, insert: code || "" },
484492
})
493+
isAIGeneratedContent = false
485494
}}
486495
/>
487496
{/if}
@@ -691,4 +700,19 @@
691700
text-overflow: ellipsis !important;
692701
white-space: nowrap !important;
693702
}
703+
704+
.code-editor.ai-generated :global(.cm-editor) {
705+
background: var(--spectrum-global-color-blue-50) !important;
706+
}
707+
708+
.code-editor.ai-generated :global(.cm-content) {
709+
background: transparent !important;
710+
}
711+
712+
.code-editor.ai-generated :global(.cm-line) {
713+
background: #765ffe1a !important;
714+
display: inline-block;
715+
min-width: fit-content;
716+
padding-right: 2px !important;
717+
}
694718
</style>

packages/builder/src/components/common/ai/AIInput.svelte

Lines changed: 60 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
export const submit = onPromptSubmit
1515
1616
$: expanded = expandedOnly || expanded
17-
1817
const dispatch = createEventDispatcher()
1918
2019
let promptInput: HTMLInputElement
@@ -154,11 +153,11 @@
154153
</Modal>
155154
{:else}
156155
<Icon
157-
color={promptLoading
156+
color={promptInput
158157
? "#6E56FF"
159158
: "var(--spectrum-global-color-gray-600)"}
160159
size="S"
161-
disabled={!canSubmit}
160+
disabled={!canSubmit || promptLoading}
162161
hoverable={!readonly}
163162
hoverColor="#6E56FF"
164163
name={promptLoading ? "StopCircle" : "PlayCircle"}
@@ -171,31 +170,43 @@
171170

172171
<style>
173172
.spectrum-ActionButton {
174-
--offset: 1px;
175173
position: relative;
176174
display: flex;
177175
align-items: center;
178176
justify-content: space-between;
179177
box-sizing: border-box;
180178
padding: var(--spacing-s);
181-
border: 1px solid var(--spectrum-alias-border-color);
182179
border-radius: 30px;
183180
transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
184181
width: 100%;
185182
height: 40px;
186183
overflow: hidden;
187184
cursor: pointer;
188185
background-color: var(--spectrum-global-color-gray-75);
186+
border: none;
189187
}
190188
191189
.spectrum-ActionButton::before {
192190
content: "";
193191
position: absolute;
194-
top: -1px;
195-
left: -1px;
196-
width: calc(100% + 2px);
197-
height: calc(100% + 2px);
198-
border-radius: inherit;
192+
inset: 0;
193+
border-radius: 30px;
194+
padding: 1px;
195+
background: var(--spectrum-alias-border-color);
196+
-webkit-mask: linear-gradient(#fff 0 0) content-box,
197+
linear-gradient(#fff 0 0);
198+
mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
199+
-webkit-mask-composite: xor;
200+
mask-composite: exclude;
201+
pointer-events: none;
202+
}
203+
204+
.animate-border::after {
205+
content: "";
206+
position: absolute;
207+
inset: 0;
208+
border-radius: 30px;
209+
padding: 1px;
199210
background: linear-gradient(
200211
125deg,
201212
transparent -10%,
@@ -205,38 +216,40 @@
205216
transparent 35%,
206217
transparent 110%
207218
);
219+
-webkit-mask: linear-gradient(#fff 0 0) content-box,
220+
linear-gradient(#fff 0 0);
221+
mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
222+
mask-composite: exclude;
208223
pointer-events: none;
209-
z-index: 0;
210-
}
211-
212-
.spectrum-ActionButton:not(.animate-border)::before {
213-
content: none;
224+
animation: border-flow 1.5s cubic-bezier(0.17, 0.67, 0.83, 0.67) forwards;
214225
}
215226
216-
.animate-border::before {
217-
animation: border-fade-in 1s cubic-bezier(0.17, 0.67, 0.83, 0.67);
218-
animation-fill-mode: forwards;
219-
}
220-
221-
@keyframes border-fade-in {
222-
from {
223-
opacity: 0;
227+
@keyframes border-flow {
228+
0% {
229+
clip-path: polygon(0% 0%, 10% 0%, 8% 100%, 0% 100%);
224230
}
225-
to {
226-
opacity: 1;
231+
30% {
232+
clip-path: polygon(0% 0%, 35% 0%, 26% 100%, 0% 100%);
233+
}
234+
50% {
235+
clip-path: polygon(0% 0%, 55% 0%, 41% 100%, 0% 100%);
236+
}
237+
70% {
238+
clip-path: polygon(0% 0%, 70% 0%, 53% 100%, 0% 100%);
239+
}
240+
85% {
241+
clip-path: polygon(0% 0%, 80% 0%, 60% 100%, 0% 100%);
242+
}
243+
95% {
244+
clip-path: polygon(0% 0%, 86% 0%, 65% 100%, 0% 100%);
245+
}
246+
100% {
247+
clip-path: polygon(0% 0%, 90% 0%, 68% 100%, 0% 100%);
227248
}
228249
}
229250
230-
.spectrum-ActionButton::after {
231-
content: "";
232-
background: inherit;
233-
position: absolute;
234-
top: 50%;
235-
left: 50%;
236-
inset: var(--offset);
237-
height: calc(100% - 2 * var(--offset));
238-
width: calc(100% - 2 * var(--offset));
239-
border-radius: inherit;
251+
.spectrum-ActionButton:not(.animate-border)::after {
252+
content: none;
240253
}
241254
242255
@keyframes fade-in {
@@ -269,10 +282,12 @@
269282
.ai-icon {
270283
width: 18px;
271284
height: 18px;
272-
margin-left: 4px;
273-
margin-right: 8px;
285+
margin-left: var(--spacing-xs);
286+
margin-right: var(--spacing-s);
274287
flex-shrink: 0;
275288
cursor: var(--ai-icon-cursor, pointer);
289+
position: relative;
290+
z-index: 2;
276291
}
277292
278293
.ai-gen-text {
@@ -281,10 +296,12 @@
281296
text-overflow: ellipsis;
282297
transition: opacity 0.2s ease-out;
283298
margin-right: var(--spacing-xs);
299+
position: relative;
300+
z-index: 2;
284301
}
285302
286303
.prompt-input {
287-
font-size: 14px;
304+
font-size: inherit;
288305
flex: 1;
289306
border: none;
290307
background: transparent;
@@ -294,6 +311,8 @@
294311
min-width: 0;
295312
resize: none;
296313
overflow: hidden;
314+
position: relative;
315+
z-index: 2;
297316
}
298317
299318
.prompt-input::placeholder {
@@ -304,14 +323,15 @@
304323
.action-buttons {
305324
display: flex;
306325
gap: var(--spacing-s);
307-
z-index: 4;
326+
z-index: 5;
308327
flex-shrink: 0;
309328
margin-right: var(--spacing-s);
329+
position: relative;
310330
}
311331
312332
.button-content-wrapper {
313333
position: relative;
314-
z-index: 1;
334+
z-index: 2;
315335
display: flex;
316336
align-items: center;
317337
overflow: hidden;

0 commit comments

Comments
 (0)