mirror of
https://github.com/lucasrcsantana/story-generator.git
synced 2025-12-17 22:07:52 +00:00
style: padroniza visual da criação de redações
- Alinha estilo dos cards com CreateStoryPage - Adiciona suporte a texto adaptativo - Melhora feedback visual e estados interativos - Implementa loading states animados
This commit is contained in:
parent
63498e92c6
commit
b767d60c50
@ -3,7 +3,12 @@ import { useNavigate } from 'react-router-dom';
|
|||||||
import { supabase } from '@/lib/supabase';
|
import { supabase } from '@/lib/supabase';
|
||||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
|
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import { ArrowLeft } from 'lucide-react';
|
import { ArrowLeft, Sparkles } from 'lucide-react';
|
||||||
|
import { useSession } from '@/hooks/useSession';
|
||||||
|
import { useUppercasePreference } from '@/hooks/useUppercasePreference';
|
||||||
|
import { AdaptiveText, AdaptiveTitle, AdaptiveParagraph } from '@/components/ui/adaptive-text';
|
||||||
|
import { TextCaseToggle } from '@/components/ui/text-case-toggle';
|
||||||
|
import { cn } from '@/lib/utils';
|
||||||
|
|
||||||
interface EssayType {
|
interface EssayType {
|
||||||
id: string;
|
id: string;
|
||||||
@ -31,6 +36,8 @@ export function NewEssay() {
|
|||||||
const [types, setTypes] = useState<EssayType[]>([]);
|
const [types, setTypes] = useState<EssayType[]>([]);
|
||||||
const [genres, setGenres] = useState<EssayGenre[]>([]);
|
const [genres, setGenres] = useState<EssayGenre[]>([]);
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
|
const { session } = useSession();
|
||||||
|
const { isUpperCase, toggleUppercase, isLoading } = useUppercasePreference(session?.user?.id);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
loadTypes();
|
loadTypes();
|
||||||
@ -102,9 +109,11 @@ export function NewEssay() {
|
|||||||
{types.map((type) => (
|
{types.map((type) => (
|
||||||
<Card
|
<Card
|
||||||
key={type.id}
|
key={type.id}
|
||||||
className={`cursor-pointer hover:shadow-lg transition-shadow ${
|
className={cn(
|
||||||
selectedType?.id === type.id ? 'ring-2 ring-primary' : ''
|
"cursor-pointer hover:shadow-lg transition-all duration-200",
|
||||||
}`}
|
"bg-white border border-gray-200",
|
||||||
|
selectedType?.id === type.id && "ring-2 ring-purple-600 bg-purple-50"
|
||||||
|
)}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setSelectedType(type);
|
setSelectedType(type);
|
||||||
loadGenres(type.id);
|
loadGenres(type.id);
|
||||||
@ -113,10 +122,22 @@ export function NewEssay() {
|
|||||||
>
|
>
|
||||||
<CardHeader>
|
<CardHeader>
|
||||||
<CardTitle className="flex items-center gap-2">
|
<CardTitle className="flex items-center gap-2">
|
||||||
<span>{type.icon}</span>
|
<div className="p-2 bg-purple-100 rounded-lg">
|
||||||
{type.title}
|
<span className="text-2xl">{type.icon}</span>
|
||||||
|
</div>
|
||||||
|
<AdaptiveText
|
||||||
|
text={type.title}
|
||||||
|
isUpperCase={isUpperCase}
|
||||||
|
className="font-bold"
|
||||||
|
/>
|
||||||
</CardTitle>
|
</CardTitle>
|
||||||
<CardDescription>{type.description}</CardDescription>
|
<CardDescription>
|
||||||
|
<AdaptiveText
|
||||||
|
text={type.description}
|
||||||
|
isUpperCase={isUpperCase}
|
||||||
|
className="text-gray-600"
|
||||||
|
/>
|
||||||
|
</CardDescription>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
</Card>
|
</Card>
|
||||||
))}
|
))}
|
||||||
@ -131,26 +152,48 @@ export function NewEssay() {
|
|||||||
{genres.map((genre) => (
|
{genres.map((genre) => (
|
||||||
<Card
|
<Card
|
||||||
key={genre.id}
|
key={genre.id}
|
||||||
className="cursor-pointer hover:shadow-lg transition-shadow"
|
className="cursor-pointer hover:shadow-lg transition-all duration-200 bg-white border border-gray-200"
|
||||||
onClick={() => createEssay(genre.id)}
|
onClick={() => createEssay(genre.id)}
|
||||||
>
|
>
|
||||||
<CardHeader>
|
<CardHeader>
|
||||||
<CardTitle className="flex items-center gap-2">
|
<CardTitle className="flex items-center gap-2">
|
||||||
<span>{genre.icon}</span>
|
<div className="p-2 bg-purple-100 rounded-lg">
|
||||||
{genre.title}
|
<span className="text-2xl">{genre.icon}</span>
|
||||||
|
</div>
|
||||||
|
<AdaptiveText
|
||||||
|
text={genre.title}
|
||||||
|
isUpperCase={isUpperCase}
|
||||||
|
className="font-bold"
|
||||||
|
/>
|
||||||
</CardTitle>
|
</CardTitle>
|
||||||
<CardDescription>{genre.description}</CardDescription>
|
<CardDescription>
|
||||||
|
<AdaptiveText
|
||||||
|
text={genre.description}
|
||||||
|
isUpperCase={isUpperCase}
|
||||||
|
className="text-gray-600"
|
||||||
|
/>
|
||||||
|
</CardDescription>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
<div className="text-sm text-muted-foreground">
|
<div className="space-y-4">
|
||||||
<p>Mínimo: {genre.requirements.min_words} palavras</p>
|
<div className="bg-purple-50 p-4 rounded-lg border border-purple-100">
|
||||||
<p>Máximo: {genre.requirements.max_words} palavras</p>
|
<h4 className="text-sm font-medium text-purple-900 mb-2">Requisitos</h4>
|
||||||
<p className="mt-2">Elementos necessários:</p>
|
<div className="space-y-2 text-sm text-purple-800">
|
||||||
<ul className="list-disc list-inside">
|
<p>Mínimo: {genre.requirements.min_words} palavras</p>
|
||||||
{genre.requirements.required_elements.map((element, index) => (
|
<p>Máximo: {genre.requirements.max_words} palavras</p>
|
||||||
<li key={index}>{element}</li>
|
<p className="mt-2 font-medium">Elementos necessários:</p>
|
||||||
))}
|
<ul className="list-disc list-inside space-y-1">
|
||||||
</ul>
|
{genre.requirements.required_elements.map((element, index) => (
|
||||||
|
<li key={index}>
|
||||||
|
<AdaptiveText
|
||||||
|
text={element}
|
||||||
|
isUpperCase={isUpperCase}
|
||||||
|
/>
|
||||||
|
</li>
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
@ -161,11 +204,38 @@ export function NewEssay() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="container mx-auto p-6">
|
<div className="container mx-auto p-6">
|
||||||
<div className="flex items-center gap-4 mb-6">
|
<div className="bg-white rounded-xl shadow-sm border border-gray-200 p-6">
|
||||||
|
<div className="flex items-center gap-3 mb-8">
|
||||||
|
<div className="p-2 bg-purple-100 rounded-lg">
|
||||||
|
<Sparkles className="h-6 w-6 text-purple-600" />
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<AdaptiveTitle
|
||||||
|
text="Nova Redação"
|
||||||
|
isUpperCase={isUpperCase}
|
||||||
|
className="text-2xl font-bold text-gray-900"
|
||||||
|
/>
|
||||||
|
<AdaptiveParagraph
|
||||||
|
text={step === 'type'
|
||||||
|
? "Selecione o tipo textual para começar"
|
||||||
|
: "Escolha o gênero textual da sua redação"}
|
||||||
|
isUpperCase={isUpperCase}
|
||||||
|
className="text-gray-600"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<TextCaseToggle
|
||||||
|
isUpperCase={isUpperCase}
|
||||||
|
onToggle={toggleUppercase}
|
||||||
|
isLoading={isLoading}
|
||||||
|
className="ml-auto"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
{step === 'genre' && (
|
{step === 'genre' && (
|
||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
onClick={() => setStep('type')}
|
onClick={() => setStep('type')}
|
||||||
|
className="mb-6"
|
||||||
trackingId="essay-new-back-button"
|
trackingId="essay-new-back-button"
|
||||||
trackingProperties={{
|
trackingProperties={{
|
||||||
action: 'back_to_type_selection',
|
action: 'back_to_type_selection',
|
||||||
@ -174,26 +244,22 @@ export function NewEssay() {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<ArrowLeft className="mr-2 h-4 w-4" />
|
<ArrowLeft className="mr-2 h-4 w-4" />
|
||||||
Voltar
|
Voltar para tipos textuais
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
<div>
|
|
||||||
<h1 className="text-3xl font-bold">Nova Redação</h1>
|
|
||||||
<p className="text-muted-foreground">
|
|
||||||
{step === 'type'
|
|
||||||
? 'Selecione o tipo textual'
|
|
||||||
: 'Selecione o gênero textual'}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{loading ? (
|
{loading ? (
|
||||||
<div>Carregando...</div>
|
<div className="animate-pulse space-y-4">
|
||||||
) : step === 'type' ? (
|
<div className="h-48 bg-gray-100 rounded-lg" />
|
||||||
renderTypeSelection()
|
<div className="h-48 bg-gray-100 rounded-lg" />
|
||||||
) : (
|
<div className="h-48 bg-gray-100 rounded-lg" />
|
||||||
renderGenreSelection()
|
</div>
|
||||||
)}
|
) : step === 'type' ? (
|
||||||
|
renderTypeSelection()
|
||||||
|
) : (
|
||||||
|
renderGenreSelection()
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user