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

Bug: Fixed responsiveness fixed in code preview tabs successfully issue 520 #521

Merged
merged 3 commits into from
Jul 28, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion frontend/src/components/PostCodeWindow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function PostCodeWindow({
: "border border-sky-500 text-sky-500 dark:text-white"
}`}
>
JavaScript
JS
</button>
)}
</div>
Expand Down
26 changes: 17 additions & 9 deletions frontend/src/components/PostCodeWithPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import PostCodeWindow from "./PostCodeWindow";
import PostPreview from "./PostPreview";
import { Link } from "react-router-dom";
import toast from "react-hot-toast";
import { FaRegCopy, FaRegEdit, FaRobot } from "react-icons/fa";

type Props = {
id: string;
Expand All @@ -26,7 +27,6 @@ const PostCodeWithPreview = ({
const [activeTab, setActiveTab] = useState<"html" | "js">("html");
const [isPreview, setIsPreview] = useState(false);


const handleCopy = () => {
if (codeSnippet && activeTab === "html") {
navigator.clipboard.writeText(codeSnippet);
Expand Down Expand Up @@ -75,31 +75,39 @@ const PostCodeWithPreview = ({
{isOwner ? (
<Link
to={`/app/posts/edit/${id}`}
className="px-2 py-1 bg-blue-600 hover:bg-blue-700 text-white text-sm rounded"
className="px-2 py-2 md:py-1 bg-blue-600 hover:bg-blue-700 rounded text-white flex items-center"
>
Edit
<FaRegEdit className="inline md:hidden" />
<span className="hidden md:inline">Edit</span>
</Link>
) : null}
<button
onClick={handleCopy}
className="px-2 py-1 bg-blue-600 hover:bg-blue-700 text-white text-sm rounded"
className="px-2 py-2 md:py-1 bg-blue-600 hover:bg-blue-700 rounded text-white flex items-center"
>
Copy
<FaRegCopy className="inline md:hidden" />
<span className="hidden md:inline">Copy</span>
</button>
{showCustomizeAiOption && (
<button
onClick={handleCustomizeAi}
className="px-2 py-1 rounded-md text-white bg-green-600 hover:bg-green-700 text-sm"
className="px-2 py-2 md:py-1 rounded-md bg-green-600 hover:bg-green-700 text-white flex items-center"
>
Customize AI
<FaRobot className="inline md:hidden" />
<span className="hidden md:inline">Customize AI</span>
</button>
)}
{!showTogether && (
<button
onClick={() => {setIsPreview(val => !val)}}
onClick={() => setIsPreview((val) => !val)}
className="px-2 py-1 rounded-md text-white bg-green-600 hover:bg-green-700 text-sm"
>
{isPreview ? "Show Code" : "Preview"}
<span className="inline md:hidden">
{isPreview ? "Code" : "Preview"}
</span>
<span className="hidden md:inline">
{isPreview ? "Show Code" : "Show Preview"}
</span>
</button>
)}
</div>
Expand Down
Loading