UNPKG

react-mention-input

Version:

A React component for input with @mention functionality.

349 lines (305 loc) 6.04 kB
.mention-container { font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; line-height: 1.5; color: #333; width: 100%; display: flex; flex-direction: column; gap: 12px; } .mention-input-container { display: flex; align-items: center; padding: 8px 12px; border: 1px solid #e0e0e0; border-radius: 24px; background: #fff; transition: all 0.2s; position: relative; width: 100%; box-sizing: border-box; } .mention-input-container:focus-within { border-color: #ddd; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.05); } .mention-input-container.dragging-over { border-color: #2684FF; background-color: rgba(38, 132, 255, 0.05); } .mention-input-container.no-image { min-height: 42px; /* Smaller height when no image is attached */ } .mention-input-wrapper { flex: 1; position: relative; min-width: 0; margin: 0 10px; } .input-header { display: flex; justify-content: flex-end; margin-bottom: 4px; } .input-content { position: relative; flex-grow: 1; } .placeholder { position: absolute; color: #999; font-size: 13px; pointer-events: none; left: 0; top: 50%; transform: translateY(-50%); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; } .mention-input { outline: none; padding: 6px 0; font-size: 13px; min-height: 24px; max-height: 120px; overflow-y: auto; word-break: break-word; width: 100%; } .action-buttons { display: flex; align-items: center; margin-left: 8px; } .image-button, .send-button { background: none; border: none; cursor: pointer; border-radius: 4px; display: flex; align-items: center; justify-content: center; transition: background-color 0.2s; padding: 5px; } .image-button { color: #666; font-size: 14px; } .image-button:hover { background-color: rgba(0, 0, 0, 0.05); } .send-button { display: flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 50%; background-color: #23488C; color: white; border: none; cursor: pointer; font-size: 24px; transition: background-color 0.2s; } .send-button:hover { background-color: #1a3a7a; } /* Suggestion list with proper columnar layout */ .suggestion-container { background: white; border-radius: 8px; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); border: 1px solid #eaeaea; overflow: hidden; width: 250px; max-height: 300px; } .suggestion-list { list-style: none; padding: 0; margin: 0; width: 100%; max-height: 300px; overflow-y: auto; } .suggestion-item { padding: 8px 12px; cursor: pointer; display: flex; align-items: center; width: 100%; box-sizing: border-box; border-bottom: 1px solid #f0f0f0; } .suggestion-item:last-child { border-bottom: none; } .suggestion-item:hover { background-color: #f5f8ff; } .user-icon { width: 28px; height: 28px; min-width: 28px; /* Ensure fixed width */ background-color: #e1e8ff; color: #2684FF; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 500; font-size: 12px; margin-right: 10px; } .user-name { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; } .mention-highlight { background-color: rgba(38, 132, 255, 0.1); color: #2684FF; border-radius: 4px; padding: 1px 4px; font-weight: 500; } .hashtag-highlight { background-color: rgba(255, 165, 0, 0.1); color: #FF8C00; border-radius: 4px; padding: 1px 4px; font-weight: 500; } .link-highlight { color: #2684FF; text-decoration: none; } .link-highlight:hover { text-decoration: underline; } .selected-images { width: 100%; margin-top: 4px; } .image-preview-card { position: relative; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); margin-bottom: 4px; max-width: 250px; background: #fff; border: 1px solid #eaeaea; } .image-preview-card img { display: block; max-width: 100%; max-height: 200px; object-fit: contain; } .remove-image-btn { position: absolute; top: 8px; right: 8px; width: 24px; height: 24px; border-radius: 50%; background: rgba(255, 255, 255, 0.9); color: #ff5252; border: none; display: flex; align-items: center; justify-content: center; font-size: 18px; cursor: pointer; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2); transition: all 0.2s; } .remove-image-btn:hover { background: #fff; transform: scale(1.05); } .image-uploading { padding: 8px; background: #f5f5f5; border-radius: 4px; font-size: 14px; color: #666; margin-top: 8px; } .image-button { background: none; border: none; cursor: pointer; font-size: 20px; padding: 4px 8px; margin-right: 8px; } .image-button:hover { opacity: 0.7; } .mention-input-container .controls { display: flex; align-items: center; width: 100%; margin-top: 8px; } .drag-overlay { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(255, 255, 255, 0.95); display: flex; justify-content: center; align-items: center; z-index: 5; border-radius: 24px; border: 2px dashed #2684FF; } .drag-message { color: #2684FF; font-weight: 500; } .drag-icon { font-size: 24px; margin-bottom: 8px; } .action-buttons button { background: none; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 6px; margin-left: 2px; border-radius: 4px; transition: background-color 0.2s; } .action-buttons button:hover { background-color: rgba(0, 0, 0, 0.05); } /* .suggestion-list { position: absolute; top: 100%; left: 0; right: 0; background-color: #fff; border: 1px solid #ddd; border-radius: 4px; list-style: none; margin: 4px 0; padding: 0; max-height: 150px; overflow-y: auto; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); z-index: 1; } */