···
let postText = $state('');
48
+
let isFocused = $state(false);
49
+
let textareaEl: HTMLTextAreaElement | undefined = $state();
52
+
if (postText.length === 0 || postText.length > 300) return;
post(postText).then((res) => {
onPostSent(res.value.uri, res.value.record);
···
67
+
if (isFocused && textareaEl) {
64
-
class="flex min-h-16 max-w-full items-center rounded-sm border-2 px-1 shadow-lg backdrop-blur-sm"
65
-
style="background: {theme.accent}18; border-color: {theme.accent}66;"
67
-
<div class="w-full p-1">
68
-
{#if info.length > 0}
70
-
class="rounded-sm px-3 py-1.5 text-center font-medium text-nowrap overflow-ellipsis"
71
-
style="background: {theme.accent}22; color: {theme.accent};"
76
-
<div class="flex gap-2">
78
-
bind:value={postText}
79
-
onkeydown={(event) => {
80
-
if (event.key === 'Enter') doPost();
83
-
placeholder="what's on your mind?"
84
-
class="placeholder-opacity-50 flex-1 rounded-sm border-2 px-3 py-2 text-sm font-medium transition-all focus:scale-[1.01] focus:shadow-lg focus:outline-none"
85
-
style="background: {theme.bg}66; border-color: {theme.accent}44; color: {theme.fg};"
89
-
class="rounded-sm border-none px-5 py-2 text-sm font-bold transition-all hover:scale-105 hover:shadow-xl"
90
-
style="background: linear-gradient(120deg, {theme.accent}c0, {theme.accent2}c0); color: {theme.fg}f0;"
73
+
<div class="relative min-h-16">
74
+
<!-- Spacer to maintain layout when focused -->
76
+
<div class="min-h-16"></div>
80
+
class="flex max-w-full rounded-sm border-2 shadow-lg backdrop-blur-lg transition-all duration-300"
81
+
class:min-h-16={!isFocused}
82
+
class:items-center={!isFocused}
83
+
class:shadow-2xl={isFocused}
84
+
class:absolute={isFocused}
85
+
class:top-0={isFocused}
86
+
class:left-0={isFocused}
87
+
class:right-0={isFocused}
88
+
class:z-50={isFocused}
89
+
style="background: {isFocused
91
+
: `${theme.accent}18`}; border-color: {theme.accent}{isFocused ? '' : '66'};"
93
+
<div class="w-full p-2" class:py-3={isFocused}>
94
+
{#if info.length > 0}
96
+
class="rounded-sm px-3 py-1.5 text-center font-medium text-nowrap overflow-ellipsis"
97
+
style="background: {theme.accent}22; color: {theme.accent};"
102
+
<div class="flex flex-col gap-2">
105
+
bind:this={textareaEl}
106
+
bind:value={postText}
107
+
onfocus={() => (isFocused = true)}
108
+
onblur={() => (isFocused = false)}
110
+
const target = e.currentTarget;
111
+
if (target.value.length > 300) {
112
+
target.value = target.value.slice(0, 300);
113
+
postText = target.value;
116
+
onkeydown={(event) => {
117
+
if (event.key === 'Enter' && (event.metaKey || event.ctrlKey)) {
121
+
placeholder="what's on your mind?"
123
+
class="placeholder-opacity-50 w-full resize-none rounded-sm border-2 px-3 py-2 text-sm font-medium transition-all focus:outline-none"
124
+
style="background: {theme.bg}66; border-color: {theme.accent}44; color: {theme.fg};"
126
+
<div class="flex items-center gap-2">
127
+
<div class="grow"></div>
129
+
class="text-sm font-medium"
130
+
style="color: {postText.length > 300 ? '#ef4444' : theme.fg}88;"
132
+
{postText.length} / 300
136
+
disabled={postText.length === 0 || postText.length > 300}
137
+
class="rounded-sm border-none px-5 py-2 text-sm font-bold transition-all hover:scale-105 hover:shadow-xl disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:scale-100"
138
+
style="background: linear-gradient(120deg, {theme.accent}c0, {theme.accent2}c0); color: {theme.fg}f0;"
145
+
bind:value={postText}
146
+
onfocus={() => (isFocused = true)}
147
+
onkeydown={(event) => {
148
+
if (event.key === 'Enter') doPost();
151
+
placeholder="what's on your mind?"
152
+
class="placeholder-opacity-50 flex-1 rounded-sm border-2 px-3 py-2 text-sm font-medium transition-all focus:outline-none"
153
+
style="background: {theme.bg}66; border-color: {theme.accent}44; color: {theme.fg};"