styling changes
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { useAuth } from '../contexts/AuthContext'
|
||||
import { Link } from 'react-router-dom'
|
||||
import { useState } from 'react'
|
||||
import { useState, useRef } from 'react'
|
||||
import { createEntry } from '../lib/api'
|
||||
import { encryptEntry } from '../lib/crypto'
|
||||
import BottomNav from '../components/BottomNav'
|
||||
@@ -11,6 +11,9 @@ export default function HomePage() {
|
||||
const [title, setTitle] = useState('')
|
||||
const [saving, setSaving] = useState(false)
|
||||
const [message, setMessage] = useState<{ type: 'success' | 'error'; text: string } | null>(null)
|
||||
|
||||
const titleInputRef = useRef<HTMLInputElement>(null)
|
||||
const contentTextareaRef = useRef<HTMLTextAreaElement>(null)
|
||||
|
||||
if (loading) {
|
||||
return (
|
||||
@@ -23,7 +26,7 @@ export default function HomePage() {
|
||||
if (!user) {
|
||||
return (
|
||||
<div className="home-page" style={{ alignItems: 'center', justifyContent: 'center', gap: '1rem' }}>
|
||||
<h1 style={{ fontFamily: 'Playfair Display, Georgia, serif', color: '#1a1a1a' }}>Grateful Journal</h1>
|
||||
<h1 style={{ fontFamily: '"Sniglet", system-ui', color: '#1a1a1a' }}>Grateful Journal</h1>
|
||||
<p style={{ color: '#6b7280' }}>Sign in to start your journal.</p>
|
||||
<Link to="/login" className="home-login-link">Go to login</Link>
|
||||
</div>
|
||||
@@ -36,6 +39,20 @@ export default function HomePage() {
|
||||
.toLocaleDateString('en-US', { weekday: 'long', month: 'short', day: 'numeric' })
|
||||
.toUpperCase()
|
||||
|
||||
const handleTitleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
|
||||
if (e.key === 'Enter' && title.trim()) {
|
||||
e.preventDefault()
|
||||
contentTextareaRef.current?.focus()
|
||||
}
|
||||
}
|
||||
|
||||
const handleContentKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {
|
||||
if (e.key === 'Enter' && entry.trim()) {
|
||||
e.preventDefault()
|
||||
handleWrite()
|
||||
}
|
||||
}
|
||||
|
||||
const handleWrite = async () => {
|
||||
if (!userId || !title.trim() || !entry.trim()) {
|
||||
setMessage({ type: 'error', text: 'Please add a title and entry content' })
|
||||
@@ -109,13 +126,17 @@ export default function HomePage() {
|
||||
placeholder="Title your thoughts..."
|
||||
value={title}
|
||||
onChange={(e) => setTitle(e.target.value)}
|
||||
onKeyDown={handleTitleKeyDown}
|
||||
ref={titleInputRef}
|
||||
disabled={saving}
|
||||
/>
|
||||
<textarea
|
||||
className="journal-entry-textarea"
|
||||
placeholder=""
|
||||
placeholder="Start writing your entry here..."
|
||||
value={entry}
|
||||
onChange={(e) => setEntry(e.target.value)}
|
||||
onKeyDown={handleContentKeyDown}
|
||||
ref={contentTextareaRef}
|
||||
disabled={saving}
|
||||
/>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user