Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added height to README Preview #161

Merged
merged 1 commit into from
Jul 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 42 additions & 24 deletions src/app/customizer/Readme-generator/page.jsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
"use client";

import React, { useState } from 'react';
import snarkdown from 'snarkdown';
import React, { useState } from "react";
import snarkdown from "snarkdown";
import Nav from "@/app/components/nav";

export default function ButtonCustomizer() {
const [title, setTitle] = useState('');
const [description, setDescription] = useState('');
const [installation, setInstallation] = useState('');
const [usage, setUsage] = useState('');
const [license, setLicense] = useState('');
const [badges, setBadges] = useState('');
const [title, setTitle] = useState("");
const [description, setDescription] = useState("");
const [installation, setInstallation] = useState("");
const [usage, setUsage] = useState("");
const [license, setLicense] = useState("");
const [badges, setBadges] = useState("");
const [isDarkMode, setIsDarkMode] = useState(false);

const generateMarkdown = () => {
const badgeMarkdown = badges
.split('\n')
.map(badge => badge.trim())
.filter(badge => badge)
.join('\n');
.split("\n")
.map((badge) => badge.trim())
.filter((badge) => badge)
.join("\n");

return `${badgeMarkdown}

Expand All @@ -40,7 +40,7 @@ ${license}

const downloadReadme = () => {
const element = document.createElement("a");
const file = new Blob([generateMarkdown()], { type: 'text/markdown' });
const file = new Blob([generateMarkdown()], { type: "text/markdown" });
element.href = URL.createObjectURL(file);
element.download = "README.md";
document.body.appendChild(element); // Required for this to work in FireFox
Expand All @@ -52,12 +52,16 @@ ${license}
};

return (
<div className={`${isDarkMode ? "bg-gray-900 text-gray-400" : "bg-gray-100 text-gray-800"} min-h-screen flex-col justify-center w-screen`}>
<div
className={`${isDarkMode ? "bg-gray-900 text-gray-400" : "bg-gray-100 text-gray-800"} min-h-screen flex-col justify-center w-screen`}
>
<Nav isDarkMode={isDarkMode} toggleTheme={toggleTheme} />
<div className="w-2/3 mx-auto">
<h1 className="text-4xl font-bold mb-6">GitHub README Generator</h1>
<div className="mb-4">
<label className="block text-lg font-medium mb-2" htmlFor="title">Project Title</label>
<label className="block text-lg font-medium mb-2" htmlFor="title">
Project Title
</label>
<input
id="title"
type="text"
Expand All @@ -67,7 +71,12 @@ ${license}
/>
</div>
<div className="mb-4">
<label className="block text-lg font-medium mb-2" htmlFor="description">Description</label>
<label
className="block text-lg font-medium mb-2"
htmlFor="description"
>
Description
</label>
<textarea
id="description"
className={`${isDarkMode ? "bg-gray-800 text-gray-200" : "bg-white text-gray-900 border-gray-400"} w-full p-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500`}
Expand All @@ -77,7 +86,12 @@ ${license}
/>
</div>
<div className="mb-4">
<label className="block text-lg font-medium mb-2" htmlFor="installation">Installation</label>
<label
className="block text-lg font-medium mb-2"
htmlFor="installation"
>
Installation
</label>
<textarea
id="installation"
className={`${isDarkMode ? "bg-gray-800 text-gray-200" : "bg-white text-gray-900 border-gray-400"} w-full p-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500`}
Expand All @@ -87,7 +101,9 @@ ${license}
/>
</div>
<div className="mb-4">
<label className="block text-lg font-medium mb-2" htmlFor="usage">Usage</label>
<label className="block text-lg font-medium mb-2" htmlFor="usage">
Usage
</label>
<textarea
id="usage"
className={`${isDarkMode ? "bg-gray-800 text-gray-200" : "bg-white text-gray-900 border-gray-400"} w-full p-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500`}
Expand All @@ -97,7 +113,9 @@ ${license}
/>
</div>
<div className="mb-4">
<label className="block text-lg font-medium mb-2" htmlFor="license">License</label>
<label className="block text-lg font-medium mb-2" htmlFor="license">
License
</label>
<input
id="license"
type="text"
Expand All @@ -107,7 +125,9 @@ ${license}
/>
</div>
<div className="mb-4">
<label className="block text-lg font-medium mb-2" htmlFor="badges">Badges (URLs, one per line)</label>
<label className="block text-lg font-medium mb-2" htmlFor="badges">
Badges (URLs, one per line)
</label>
<textarea
id="badges"
className={`${isDarkMode ? "bg-gray-800 text-gray-200" : "bg-white text-gray-900 border-gray-400"} w-full p-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500`}
Expand All @@ -123,9 +143,9 @@ ${license}
Download README
</button>
<h2 className="text-2xl font-bold mt-8 mb-4">Preview</h2>
<div className="p-4 border rounded-lg border-gray-400">
<div className=" h-[700px] p-4 border rounded-lg border-gray-400">
<iframe
className={`w-full h-full ${isDarkMode ? "bg-gray-800 text-white" : "bg-white text-black"}`}
className={`w-full h-[670px] ${isDarkMode ? "bg-gray-800 text-white" : "bg-white text-black"}`}
title="Parsed Markdown"
srcDoc={`<!DOCTYPE html><html><head><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/github-markdown-css/5.2.0/github-markdown.min.css"><style>body { margin: 0; padding: 16px; background-color: ${isDarkMode ? "#1a202c" : "white"}; color: ${isDarkMode ? "white" : "black"}; }</style></head><body class="markdown-body">${snarkdown(
generateMarkdown(),
Expand All @@ -136,5 +156,3 @@ ${license}
</div>
);
}


Loading