117 lines
3.2 KiB
Svelte
117 lines
3.2 KiB
Svelte
|
|
<script>
|
||
|
|
// Компактный тизер агента: поле-намёк + минималистичная отправка.
|
||
|
|
// Рамка стабильна: ширина поля фиксирована, «печатающиеся» точки живут
|
||
|
|
// в абсолютном оверлее и ничего не сдвигают.
|
||
|
|
let { onsend = () => {} } = $props();
|
||
|
|
let value = $state('');
|
||
|
|
const armed = $derived(value.trim().length > 0);
|
||
|
|
function submit(e) {
|
||
|
|
e?.preventDefault();
|
||
|
|
onsend(value);
|
||
|
|
value = '';
|
||
|
|
}
|
||
|
|
</script>
|
||
|
|
<form class="mock" onsubmit={submit}>
|
||
|
|
<span class="field">
|
||
|
|
<input
|
||
|
|
type="text"
|
||
|
|
class="input"
|
||
|
|
bind:value
|
||
|
|
aria-label="Что настроить?"
|
||
|
|
autocomplete="off"
|
||
|
|
spellcheck="false"
|
||
|
|
/>
|
||
|
|
{#if !value}
|
||
|
|
<span class="ph" aria-hidden="true">Что настроить ?<span class="dots"></span></span>
|
||
|
|
{/if}
|
||
|
|
</span>
|
||
|
|
<button type="submit" class="send" class:armed aria-label="Отправить запрос">
|
||
|
|
<svg viewBox="0 0 14 14" aria-hidden="true">
|
||
|
|
<path
|
||
|
|
d="M1.8 6.8 L12.2 2.4 L8.7 11.8 L6.5 8.2 Z M6.5 8.2 L12.2 2.4"
|
||
|
|
fill="none"
|
||
|
|
stroke="currentColor"
|
||
|
|
stroke-width="1.2"
|
||
|
|
stroke-linecap="round"
|
||
|
|
stroke-linejoin="round"
|
||
|
|
/>
|
||
|
|
</svg>
|
||
|
|
</button>
|
||
|
|
</form>
|
||
|
|
<style>
|
||
|
|
.mock {
|
||
|
|
display: inline-flex;
|
||
|
|
align-items: center;
|
||
|
|
gap: 4px;
|
||
|
|
padding: 2px 4px 2px 10px;
|
||
|
|
border: 1px solid var(--line);
|
||
|
|
border-radius: 8px;
|
||
|
|
background: rgba(0, 0, 0, 0.35);
|
||
|
|
transition: border-color 0.18s ease;
|
||
|
|
}
|
||
|
|
.mock:focus-within { border-color: var(--line-2); }
|
||
|
|
.field {
|
||
|
|
position: relative;
|
||
|
|
display: inline-flex;
|
||
|
|
align-items: center;
|
||
|
|
overflow: hidden;
|
||
|
|
}
|
||
|
|
.input {
|
||
|
|
width: 138px;
|
||
|
|
max-width: 34vw;
|
||
|
|
padding: 3px 0;
|
||
|
|
border: none;
|
||
|
|
background: none;
|
||
|
|
outline: none;
|
||
|
|
font-family: var(--mono);
|
||
|
|
font-size: 11.5px;
|
||
|
|
color: var(--hi);
|
||
|
|
}
|
||
|
|
/* оверлей-плейсхолдер: не влияет на ширину рамки */
|
||
|
|
.ph {
|
||
|
|
position: absolute;
|
||
|
|
left: 0;
|
||
|
|
top: 50%;
|
||
|
|
transform: translateY(-50%);
|
||
|
|
display: inline-flex;
|
||
|
|
pointer-events: none;
|
||
|
|
font-family: var(--mono);
|
||
|
|
font-size: 11.5px;
|
||
|
|
color: var(--dim);
|
||
|
|
white-space: nowrap;
|
||
|
|
}
|
||
|
|
.dots { display: inline-block; width: 3ch; }
|
||
|
|
.dots::after {
|
||
|
|
content: '...';
|
||
|
|
animation: teaser-dots 1.6s steps(1) infinite;
|
||
|
|
}
|
||
|
|
@keyframes teaser-dots {
|
||
|
|
0% { content: ''; }
|
||
|
|
25% { content: '.'; }
|
||
|
|
50% { content: '..'; }
|
||
|
|
75% { content: '...'; }
|
||
|
|
}
|
||
|
|
/* отправка: серая и незаметная, пока поле пустое */
|
||
|
|
.send {
|
||
|
|
display: inline-flex;
|
||
|
|
align-items: center;
|
||
|
|
justify-content: center;
|
||
|
|
flex-shrink: 0;
|
||
|
|
width: 22px;
|
||
|
|
height: 20px;
|
||
|
|
border: none;
|
||
|
|
border-radius: 6px;
|
||
|
|
background: none;
|
||
|
|
color: var(--dim);
|
||
|
|
cursor: pointer;
|
||
|
|
transition: color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
|
||
|
|
}
|
||
|
|
.send svg { width: 12px; height: 12px; }
|
||
|
|
.send:hover { color: var(--text); background: rgba(255, 255, 255, 0.05); }
|
||
|
|
.send.armed {
|
||
|
|
color: var(--acc);
|
||
|
|
background: var(--acc-soft);
|
||
|
|
box-shadow: 0 0 10px rgba(79, 240, 183, 0.35);
|
||
|
|
}
|
||
|
|
</style>
|