Skip to content
Closed
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Welcome to **React Kolkata**! This project provides a robust foundation for Next
- **Docker Support**: Easy containerization and deployment
- **Internationalization (i18n)**: Built-in multi-language support with next-intl
- **Playwright & Vitest**: E2E, unit, and integration testing
- **Newsletter Subscription**: Engage community members with updates and announcements
- **Community Events**: [React Kolkata on lu.ma](https://lu.ma/reactkolkata)

---
Expand Down
120 changes: 120 additions & 0 deletions src/app/[locale]/playground/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
"use client";

import { useState } from "react";
import { useTranslations } from "next-intl";
import { CodeEditor } from "@/components/custom/code-editor";
import { LivePreview } from "@/components/custom/live-preview";
import { PlaygroundControls } from "@/components/custom/playground-controls";
import { DEFAULT_REACT_CODE } from "@/types/playground";

export default function PlaygroundPage() {
const t = useTranslations("Playground");
const [code, setCode] = useState(DEFAULT_REACT_CODE);
const [previewCode, setPreviewCode] = useState(DEFAULT_REACT_CODE);
const [isSaved, setIsSaved] = useState(false);
const [isBookmarked, setIsBookmarked] = useState(false);
const [error, setError] = useState<string | undefined>();

const handleRun = () => {
setError(undefined);
setPreviewCode(code);
};

const handleSave = () => {
// TODO: Implement actual save to backend/localStorage
console.log("Saving code:", code);
setIsSaved(true);
setTimeout(() => setIsSaved(false), 2000);
};

const handleReset = () => {
setCode(DEFAULT_REACT_CODE);
setPreviewCode(DEFAULT_REACT_CODE);
setError(undefined);
};

const handleShare = () => {
// TODO: Implement actual sharing logic
console.log("Sharing code:", code);
};

const handleToggleBookmark = () => {
setIsBookmarked(!isBookmarked);
};

const handleCodeChange = (newCode: string) => {
setCode(newCode);
setIsSaved(false);
};

return (
<div className="min-h-screen bg-background">
{/* Header */}
<div className="border-b border-border bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60 sticky top-0 z-10">
<div className="container mx-auto px-4 py-4">
<h1 className="text-2xl font-bold">{t("title")}</h1>
<p className="text-muted-foreground mt-1">{t("description")}</p>
</div>
</div>

{/* Controls */}
<PlaygroundControls
onRun={handleRun}
onSave={handleSave}
onReset={handleReset}
onShare={handleShare}
code={code}
isSaved={isSaved}
isBookmarked={isBookmarked}
onToggleBookmark={handleToggleBookmark}
/>

{/* Editor and Preview */}
<div className="container mx-auto p-4">
<div className="grid grid-cols-1 lg:grid-cols-2 gap-4 h-[calc(100vh-220px)]">
{/* Code Editor */}
<div className="h-full">
<CodeEditor
initialCode={code}
language="jsx"
onChange={handleCodeChange}
/>
</div>

{/* Live Preview */}
<div className="h-full">
<LivePreview code={previewCode} error={error} />
</div>
</div>
</div>

{/* Info Section */}
<div className="container mx-auto px-4 py-6 border-t border-border mt-6">
<div className="grid grid-cols-1 md:grid-cols-3 gap-6 text-sm">
<div>
<h3 className="font-semibold mb-2">{t("tips.keyboard.title")}</h3>
<ul className="text-muted-foreground space-y-1">
<li>• Tab - {t("tips.keyboard.tab")}</li>
<li>• Ctrl+S - {t("tips.keyboard.save")}</li>
<li>• Ctrl+Enter - {t("tips.keyboard.run")}</li>
</ul>
</div>
<div>
<h3 className="font-semibold mb-2">{t("tips.features.title")}</h3>
<ul className="text-muted-foreground space-y-1">
<li>• {t("tips.features.autoRun")}</li>
<li>• {t("tips.features.share")}</li>
<li>• {t("tips.features.bookmark")}</li>
</ul>
</div>
<div>
<h3 className="font-semibold mb-2">{t("tips.community.title")}</h3>
<p className="text-muted-foreground">
{t("tips.community.description")}
</p>
</div>
</div>
</div>
</div>
);
}
2 changes: 2 additions & 0 deletions src/base/data/dummy/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { EVENT_TYPES } from "@/types/event";

export { snippets } from "./snippets";

export const events = [
{
id: "rk-nov-2025",
Expand Down
Loading