Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | 1x 1x 1x 3x 3x 3x 3x 3x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 5x 5x 5x 5x 2x 2x 2x 1x | <template>
<div class="message-input-container">
<p
v-if="error"
class="send-error"
role="alert"
data-testid="chat-send-error"
>
{{ error }}
</p>
<div class="input-wrapper">
<input
v-model="message"
type="text"
placeholder="Type a message..."
class="message-input"
:disabled="disabled"
@keyup.enter="sendMessage"
maxlength="500"
/>
<button
@click="sendMessage"
:disabled="disabled || !message.trim()"
class="send-button"
>
<span class="send-icon">➤</span>
</button>
</div>
</div>
</template>
<script setup>
import { ref } from 'vue';
const props = defineProps({
disabled: {
type: Boolean,
default: false,
},
// Why the last post failed, in words for the composer (SB-1324).
error: {
type: String,
default: '',
},
});
const emit = defineEmits(['send']);
const message = ref('');
// The draft stays until the parent confirms the post, so a refused message
// (or one held for the chat rules prompt) is not lost.
function sendMessage() {
if (!message.value.trim() || props.disabled) return;
emit('send', message.value.trim());
}
function clear() {
message.value = '';
}
defineExpose({ clear });
</script>
<style scoped>
.message-input-container {
position: fixed;
bottom: 0;
left: 0;
right: 0;
background: #16213e;
padding: 12px 16px;
border-top: 1px solid #333;
z-index: 100;
}
.send-error {
max-width: 640px;
margin: 0 auto 8px;
font-size: 13px;
color: #ff6b6b;
}
.input-wrapper {
display: flex;
gap: 12px;
max-width: 640px;
margin: 0 auto;
}
.message-input {
flex: 1;
padding: 12px 16px;
border: 2px solid #333;
border-radius: 24px;
background: #1a1a2e;
color: white;
font-size: 16px;
min-height: 48px;
}
.message-input:focus {
outline: none;
border-color: #2196f3;
}
.message-input::placeholder {
color: #666;
}
.message-input:disabled {
opacity: 0.5;
}
.send-button {
width: 48px;
height: 48px;
border: none;
border-radius: 50%;
background: #2196f3;
color: white;
font-size: 20px;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
transition: background-color 0.2s;
}
.send-button:hover:not(:disabled) {
background: #1e88e5;
}
.send-button:disabled {
background: #444;
cursor: not-allowed;
}
.send-icon {
transform: rotate(-45deg);
}
/* Responsive */
@media (min-width: 640px) {
.message-input-container {
padding: 16px;
}
}
@media (min-width: 1024px) {
.input-wrapper {
max-width: 800px;
}
}
</style>
|