From f0e75d76b3693749d20a74a243231d96fd3ac748 Mon Sep 17 00:00:00 2001 From: Mathias Wagner Date: Fri, 4 Aug 2023 22:21:18 +0200 Subject: [PATCH] Created the CharCounter.jsx --- .../tools/text/CharCounter/CharCounter.jsx | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 client/src/pages/tools/text/CharCounter/CharCounter.jsx diff --git a/client/src/pages/tools/text/CharCounter/CharCounter.jsx b/client/src/pages/tools/text/CharCounter/CharCounter.jsx new file mode 100644 index 0000000..7ebc1e8 --- /dev/null +++ b/client/src/pages/tools/text/CharCounter/CharCounter.jsx @@ -0,0 +1,42 @@ +import InfoArea from "@/common/components/InfoArea"; +import Button from "@/common/components/Button"; +import {faShare} from "@fortawesome/free-solid-svg-icons"; +import TextArea from "@/pages/tools/base64/components/TextArea"; +import {useState} from "react"; +import "./styles.sass"; +import {useSearchParams} from "react-router-dom"; + +export const CharCounter = () => { + const [searchParams] = useSearchParams(); + const [inputString, setInputString] = useState(searchParams.get("input") || ""); + + const calculateWords = () => inputString.split("\n").filter(line => line !== "").map(line => line.split(" ") + .filter(word => word !== "").length).reduce((a, b) => a + b, 0); + + const shareLink = () => { + const url = new URL(window.location.href); + url.searchParams.set("input", inputString); + navigator.clipboard.writeText(url.href); + } + + return ( + <> + +