Working!!!!!!!!!!!!!!! SIGMA MALE ATTITUDE JERKMATE RANKED GYATT
This commit is contained in:
103
src/app/page.tsx
103
src/app/page.tsx
@@ -1,42 +1,83 @@
|
|||||||
import { Textarea } from "@/components/ui/textarea"
|
"use client";
|
||||||
import {Checkbox} from "@/components/ui/checkbox";
|
|
||||||
import {Stats} from "@/components/Stats";
|
import { useEffect, useState } from "react";
|
||||||
|
import { Textarea } from "@/components/ui/textarea";
|
||||||
|
import { Checkbox } from "@/components/ui/checkbox";
|
||||||
|
import { Stats } from "@/components/Stats";
|
||||||
import LetterDensity from "@/components/LetterDensity";
|
import LetterDensity from "@/components/LetterDensity";
|
||||||
|
|
||||||
|
const config = {
|
||||||
|
includeSpaces: true,
|
||||||
|
charLimit: 500,
|
||||||
|
theme: "dark",
|
||||||
|
};
|
||||||
|
|
||||||
export default function Home() {
|
export default function Home() {
|
||||||
return (
|
const [text, setText] = useState("");
|
||||||
<div className="max-w-6xl m-auto min-h-screen flex flex-col ">
|
const [analysis, setAnalysis] = useState<any>(null);
|
||||||
<h1 className="text-6xl font-semibold text-center">Analyze your Text<br/>in real-time.</h1>
|
const [includeSpaces, setIncludeSpaces] = useState(true);
|
||||||
<Textarea className="h-72" placeholder="Start typing here...(or paste your text)" />
|
|
||||||
|
|
||||||
<div className="flex flex-row space-x-2 pt-2 justify-between">
|
useEffect(() => {
|
||||||
<div>
|
const result: any = {};
|
||||||
<Checkbox id="terms" />
|
const inputText = text;
|
||||||
<label
|
|
||||||
htmlFor="terms"
|
|
||||||
className="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
|
|
||||||
>
|
|
||||||
Exclude Spaces
|
|
||||||
</label>
|
|
||||||
|
|
||||||
|
result.charCount = includeSpaces ? inputText.length : inputText.replace(/\s/g, "").length;
|
||||||
|
result.wordCount = (inputText.match(/[a-zA-ZäöüÄÖÜß]+/g) || []).length;
|
||||||
|
result.sentenceCount = (inputText.match(/[\w\s][.?!](?=\s|$)/g) || []).length;
|
||||||
|
result.exceedsLimit = result.charCount > config.charLimit;
|
||||||
|
result.readingTimeMinutes = Math.ceil(result.wordCount / 200);
|
||||||
|
|
||||||
<Checkbox id="terms" />
|
const letters = inputText.toLowerCase().match(/[a-z]/g) || [];
|
||||||
<label
|
const totalLetters = letters.length;
|
||||||
htmlFor="terms"
|
result.letterDensity = {};
|
||||||
className="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
|
|
||||||
>
|
|
||||||
Set Character Limit
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
for (let char of letters) {
|
||||||
<p>Approx. reading time:</p>
|
result.letterDensity[char] = (result.letterDensity[char] || 0) + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let char in result.letterDensity) {
|
||||||
|
result.letterDensity[char] = +(result.letterDensity[char] / totalLetters).toFixed(3);
|
||||||
|
}
|
||||||
|
|
||||||
|
setAnalysis(result);
|
||||||
|
}, [text, includeSpaces]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="max-w-6xl m-auto min-h-screen flex flex-col">
|
||||||
|
<h1 className="text-6xl font-semibold text-center">
|
||||||
|
Analyze your Text<br />in real-time.
|
||||||
|
</h1>
|
||||||
|
|
||||||
|
<Textarea
|
||||||
|
className="h-72"
|
||||||
|
placeholder="Start typing here...(or paste your text)"
|
||||||
|
onChange={(e) => setText(e.target.value)}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<div className="flex flex-row space-x-2 pt-2 justify-between">
|
||||||
|
<div>
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<Checkbox id="spaces" checked={includeSpaces} onCheckedChange={setIncludeSpaces} />
|
||||||
|
<label htmlFor="spaces" className="text-sm font-medium leading-none">
|
||||||
|
Exclude Spaces
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<p>Approx. reading time: {analysis?.readingTimeMinutes ?? 0} min</p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{analysis && (
|
||||||
|
<>
|
||||||
|
<Stats
|
||||||
|
charCount={analysis.charCount}
|
||||||
|
wordCount={analysis.wordCount}
|
||||||
|
sentenceCount={analysis.sentenceCount}
|
||||||
|
/>
|
||||||
|
<LetterDensity density={analysis.letterDensity} />
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
<Stats/>
|
);
|
||||||
<LetterDensity/>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,29 +1,25 @@
|
|||||||
"use client";
|
"use client";
|
||||||
import {Progress} from "@/components/ui/progress";
|
import { Progress } from "@/components/ui/progress";
|
||||||
|
|
||||||
export default function LetterDensity(){
|
type LetterDensityProps = {
|
||||||
return(
|
density: Record<string, number>;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default function LetterDensity({ density }: LetterDensityProps) {
|
||||||
|
const sorted = Object.entries(density).sort((a, b) => b[1] - a[1]);
|
||||||
|
|
||||||
|
return (
|
||||||
<div className="h-auto w-full pt-8">
|
<div className="h-auto w-full pt-8">
|
||||||
<h2 className="text-2xl">Letter Density</h2>
|
<h2 className="text-2xl">Letter Density</h2>
|
||||||
<div className="flex flex-col py-4 gap-2">
|
<div className="flex flex-col py-4 gap-2">
|
||||||
<div className="flex flex-row items-center">
|
{sorted.map(([letter, value]) => (
|
||||||
<p className="pr-4 text-lg">A</p>
|
<div className="flex flex-row items-center" key={letter}>
|
||||||
<Progress className="h-4" value={33}/>
|
<p className="pr-4 text-lg uppercase">{letter}</p>
|
||||||
<p className="pl-4">40(16.06%)</p>
|
<Progress className="h-4 flex-1" value={value * 100} />
|
||||||
</div>
|
<p className="pl-4">{(value * 100).toFixed(2)}%</p>
|
||||||
<div className="flex flex-row items-center">
|
</div>
|
||||||
<p className="pr-4 text-lg">A</p>
|
))}
|
||||||
<Progress className="h-4" value={33}/>
|
|
||||||
<p className="pl-4">40(16.06%)</p>
|
|
||||||
</div>
|
|
||||||
<div className="flex flex-row items-center">
|
|
||||||
<p className="pr-4 text-lg">A</p>
|
|
||||||
<Progress className="h-4" value={33}/>
|
|
||||||
<p className="pl-4">40(16.06%)</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<h3>See more</h3>
|
|
||||||
</div>
|
</div>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,44 +1,32 @@
|
|||||||
import { TrendingDownIcon, TrendingUpIcon } from "lucide-react"
|
import {Card, CardDescription, CardHeader, CardTitle} from "@/components/ui/card";
|
||||||
|
|
||||||
import { Badge } from "@/components/ui/badge"
|
interface StatsProps {
|
||||||
import {
|
charCount: number;
|
||||||
Card,
|
wordCount: number;
|
||||||
CardDescription,
|
sentenceCount: number;
|
||||||
CardFooter,
|
}
|
||||||
CardHeader,
|
|
||||||
CardTitle,
|
|
||||||
} from "@/components/ui/card"
|
|
||||||
|
|
||||||
export function Stats() {
|
export function Stats({ charCount, wordCount, sentenceCount }: StatsProps) {
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-row space-x-4 gap-4 h-32">
|
<div className="flex flex-row space-x-4 gap-4 h-32">
|
||||||
<Card className="w-full">
|
<Card className="w-full">
|
||||||
<CardHeader className="relative">
|
<CardHeader className="relative">
|
||||||
|
<CardTitle className="text-6xl font-semibold tabular-nums">{charCount}</CardTitle>
|
||||||
<CardTitle className="text-6xl font-semibold tabular-nums">
|
|
||||||
03
|
|
||||||
</CardTitle>
|
|
||||||
<CardDescription>Total Characters</CardDescription>
|
<CardDescription>Total Characters</CardDescription>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
</Card>
|
</Card>
|
||||||
<Card className="w-full">
|
<Card className="w-full">
|
||||||
<CardHeader className="relative">
|
<CardHeader className="relative">
|
||||||
|
<CardTitle className="text-6xl font-semibold tabular-nums">{wordCount}</CardTitle>
|
||||||
<CardTitle className="text-6xl font-semibold tabular-nums">
|
|
||||||
03
|
|
||||||
</CardTitle>
|
|
||||||
<CardDescription>Word Count</CardDescription>
|
<CardDescription>Word Count</CardDescription>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
</Card>
|
</Card>
|
||||||
<Card className="w-full">
|
<Card className="w-full">
|
||||||
<CardHeader className="relative">
|
<CardHeader className="relative">
|
||||||
|
<CardTitle className="text-6xl font-semibold tabular-nums">{sentenceCount}</CardTitle>
|
||||||
<CardTitle className="text-6xl font-semibold tabular-nums">
|
|
||||||
03
|
|
||||||
</CardTitle>
|
|
||||||
<CardDescription>Sentence Count</CardDescription>
|
<CardDescription>Sentence Count</CardDescription>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
</Card>
|
</Card>
|
||||||
</div>
|
</div>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user