407 lines
11 KiB
HTML
407 lines
11 KiB
HTML
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
<link rel="icon" type="image/png" href="/favicon.png" />
|
|
<title>Create a Space — rSpace</title>
|
|
<script>(function(){var t=localStorage.getItem('canvas-theme');if(!t)t=matchMedia('(prefers-color-scheme:light)').matches?'light':'dark';document.documentElement.setAttribute('data-theme',t)})()</script>
|
|
<link rel="stylesheet" href="/theme.css">
|
|
<link rel="stylesheet" href="/shell.css">
|
|
<style>
|
|
* {
|
|
margin: 0;
|
|
padding: 0;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
body {
|
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
background: var(--rs-bg-page);
|
|
color: var(--rs-text-primary);
|
|
min-height: 100vh;
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
padding-top: 56px;
|
|
}
|
|
|
|
.hero {
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
justify-content: center;
|
|
min-height: calc(100vh - 56px);
|
|
width: 100%;
|
|
background:
|
|
radial-gradient(ellipse at 30% 20%, rgba(20, 184, 166, 0.08) 0%, transparent 60%),
|
|
radial-gradient(ellipse at 70% 80%, rgba(99, 102, 241, 0.06) 0%, transparent 60%);
|
|
}
|
|
|
|
.container {
|
|
text-align: center;
|
|
max-width: 520px;
|
|
padding: 40px 20px;
|
|
width: 100%;
|
|
}
|
|
|
|
h1 {
|
|
font-size: 2.5rem;
|
|
margin-bottom: 0.75rem;
|
|
background: var(--rs-gradient-brand);
|
|
-webkit-background-clip: text;
|
|
-webkit-text-fill-color: transparent;
|
|
}
|
|
|
|
.tagline {
|
|
font-size: 1.1rem;
|
|
color: var(--rs-text-secondary);
|
|
margin-bottom: 2.5rem;
|
|
}
|
|
|
|
.create-form {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 1.25rem;
|
|
background: var(--rs-bg-surface);
|
|
padding: 2rem;
|
|
border-radius: 16px;
|
|
border: 1px solid var(--rs-border);
|
|
box-shadow: var(--rs-shadow-lg);
|
|
}
|
|
|
|
.form-group {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 0.5rem;
|
|
text-align: left;
|
|
}
|
|
|
|
label {
|
|
font-size: 0.875rem;
|
|
color: var(--rs-text-secondary);
|
|
font-weight: 500;
|
|
}
|
|
|
|
input, select {
|
|
padding: 12px 16px;
|
|
border-radius: 8px;
|
|
border: 1px solid var(--rs-input-border);
|
|
background: var(--rs-input-bg);
|
|
color: var(--rs-input-text);
|
|
font-size: 1rem;
|
|
transition: border-color 0.2s;
|
|
}
|
|
|
|
select option {
|
|
background: var(--rs-bg-surface);
|
|
color: var(--rs-text-primary);
|
|
}
|
|
|
|
input:focus, select:focus {
|
|
outline: none;
|
|
border-color: var(--rs-accent);
|
|
box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.15);
|
|
}
|
|
|
|
input::placeholder {
|
|
color: var(--rs-text-muted);
|
|
}
|
|
|
|
.slug-preview {
|
|
font-size: 0.875rem;
|
|
color: var(--rs-text-muted);
|
|
margin-top: 0.25rem;
|
|
}
|
|
|
|
.slug-preview span {
|
|
color: var(--rs-accent);
|
|
font-weight: 500;
|
|
}
|
|
|
|
.submit-btn {
|
|
padding: 14px 28px;
|
|
border-radius: 8px;
|
|
border: none;
|
|
background: var(--rs-gradient-cta);
|
|
color: white;
|
|
font-size: 1rem;
|
|
font-weight: 600;
|
|
cursor: pointer;
|
|
transition: transform 0.2s, box-shadow 0.2s;
|
|
}
|
|
|
|
.submit-btn:hover {
|
|
transform: translateY(-2px);
|
|
box-shadow: 0 8px 20px rgba(20, 184, 166, 0.3);
|
|
}
|
|
|
|
.submit-btn:active {
|
|
transform: translateY(0);
|
|
}
|
|
|
|
.submit-btn:disabled {
|
|
opacity: 0.6;
|
|
cursor: not-allowed;
|
|
transform: none;
|
|
box-shadow: none;
|
|
}
|
|
|
|
.error {
|
|
color: var(--rs-error);
|
|
font-size: 0.875rem;
|
|
margin-top: 0.5rem;
|
|
}
|
|
|
|
.help-text {
|
|
font-size: 0.8rem;
|
|
color: var(--rs-text-muted);
|
|
margin-top: 0.25rem;
|
|
}
|
|
|
|
.back-link {
|
|
display: inline-block;
|
|
margin-top: 1.5rem;
|
|
color: var(--rs-text-muted);
|
|
text-decoration: none;
|
|
font-size: 0.9rem;
|
|
transition: color 0.2s;
|
|
}
|
|
|
|
.back-link:hover {
|
|
color: var(--rs-text-secondary);
|
|
}
|
|
|
|
/* Visibility option cards */
|
|
.visibility-options {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 0.5rem;
|
|
}
|
|
.visibility-option {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 10px;
|
|
padding: 10px 14px;
|
|
border-radius: 8px;
|
|
border: 1px solid var(--rs-border);
|
|
background: var(--rs-bg-surface-sunken);
|
|
cursor: pointer;
|
|
transition: border-color 0.2s, background 0.2s;
|
|
}
|
|
.visibility-option:hover {
|
|
border-color: var(--rs-border-strong);
|
|
}
|
|
.visibility-option.active {
|
|
border-color: var(--rs-accent);
|
|
background: var(--rs-bg-active);
|
|
}
|
|
.visibility-option input[type="radio"] {
|
|
accent-color: var(--rs-accent);
|
|
width: 16px;
|
|
height: 16px;
|
|
padding: 0;
|
|
border: none;
|
|
}
|
|
.visibility-option .vis-label {
|
|
font-size: 0.875rem;
|
|
font-weight: 500;
|
|
color: var(--rs-text-primary);
|
|
}
|
|
.visibility-option .vis-desc {
|
|
font-size: 0.75rem;
|
|
color: var(--rs-text-muted);
|
|
}
|
|
</style>
|
|
<script defer src="https://rdata.online/collect.js" data-website-id="6ee7917b-0ed7-44cb-a4c8-91037638526b"></script>
|
|
</head>
|
|
<body>
|
|
<header class="rstack-header">
|
|
<div class="rstack-header__left">
|
|
<a href="/" style="display:flex;align-items:center;margin-right:4px"><img src="/logo.png" alt="rSpace" class="rstack-header__logo"></a>
|
|
<rstack-app-switcher current=""></rstack-app-switcher>
|
|
<rstack-space-switcher current="" name="Spaces"></rstack-space-switcher>
|
|
</div>
|
|
<div class="rstack-header__center">
|
|
<rstack-mi></rstack-mi>
|
|
</div>
|
|
<div class="rstack-header__right">
|
|
<rstack-identity></rstack-identity>
|
|
</div>
|
|
</header>
|
|
<div class="hero">
|
|
<div class="container">
|
|
<h1>Create a Space</h1>
|
|
<p class="tagline">Start a collaborative community space with all the r* tools built in.</p>
|
|
|
|
<form class="create-form" id="create-form">
|
|
<div class="form-group">
|
|
<label for="community-name">Space Name</label>
|
|
<input
|
|
type="text"
|
|
id="community-name"
|
|
placeholder="e.g. MycoFi Commons"
|
|
required
|
|
/>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="community-slug">URL Slug</label>
|
|
<input
|
|
type="text"
|
|
id="community-slug"
|
|
placeholder="e.g. mycofi"
|
|
pattern="[a-z0-9-]+"
|
|
required
|
|
/>
|
|
<p class="slug-preview">Your space will be at: <span id="slug-preview">___.rspace.online</span></p>
|
|
</div>
|
|
<div class="form-group">
|
|
<label>Visibility</label>
|
|
<div class="visibility-options" id="visibility-options">
|
|
<label class="visibility-option active">
|
|
<input type="radio" name="visibility" value="public" checked />
|
|
<div>
|
|
<div class="vis-label">Public</div>
|
|
<div class="vis-desc">Anyone can read, sign in to write</div>
|
|
</div>
|
|
</label>
|
|
<label class="visibility-option">
|
|
<input type="radio" name="visibility" value="permissioned" />
|
|
<div>
|
|
<div class="vis-label">Permissioned</div>
|
|
<div class="vis-desc">Sign in to read & write</div>
|
|
</div>
|
|
</label>
|
|
<label class="visibility-option">
|
|
<input type="radio" name="visibility" value="private" />
|
|
<div>
|
|
<div class="vis-label">Private</div>
|
|
<div class="vis-desc">Invite-only access</div>
|
|
</div>
|
|
</label>
|
|
</div>
|
|
<p class="help-text">You can change this later in space settings.</p>
|
|
</div>
|
|
<button type="submit" class="submit-btn">Create Space</button>
|
|
<p class="error" id="error-message" style="display: none;"></p>
|
|
</form>
|
|
|
|
<a href="/" class="back-link">← Back to rSpace</a>
|
|
</div>
|
|
</div>
|
|
|
|
<script type="module">
|
|
import { RStackIdentity } from "@shared/components/rstack-identity";
|
|
import { RStackAppSwitcher } from "@shared/components/rstack-app-switcher";
|
|
import { RStackSpaceSwitcher } from "@shared/components/rstack-space-switcher";
|
|
import { RStackMi } from "@shared/components/rstack-mi";
|
|
import { requireAuth, isAuthenticated, getAccessToken } from "@shared/components/rstack-identity";
|
|
|
|
RStackIdentity.define();
|
|
RStackAppSwitcher.define();
|
|
RStackSpaceSwitcher.define();
|
|
RStackMi.define();
|
|
|
|
fetch("/api/modules").then(r => r.json()).then(data => {
|
|
document.querySelector("rstack-app-switcher")?.setModules(data.modules || []);
|
|
}).catch(() => {});
|
|
|
|
// Visibility option cards — highlight active
|
|
const visOptions = document.getElementById("visibility-options");
|
|
visOptions.addEventListener("change", () => {
|
|
visOptions.querySelectorAll(".visibility-option").forEach(opt => {
|
|
opt.classList.toggle("active", opt.querySelector("input").checked);
|
|
});
|
|
});
|
|
|
|
const nameInput = document.getElementById("community-name");
|
|
const slugInput = document.getElementById("community-slug");
|
|
const slugPreview = document.getElementById("slug-preview");
|
|
const form = document.getElementById("create-form");
|
|
const errorMessage = document.getElementById("error-message");
|
|
|
|
nameInput.addEventListener("input", () => {
|
|
const slug = nameInput.value
|
|
.toLowerCase()
|
|
.replace(/[^a-z0-9]+/g, "-")
|
|
.replace(/^-|-$/g, "");
|
|
slugInput.value = slug;
|
|
slugPreview.textContent = slug ? `${slug}.rspace.online` : "___.rspace.online";
|
|
});
|
|
|
|
slugInput.addEventListener("input", () => {
|
|
const slug = slugInput.value.toLowerCase().replace(/[^a-z0-9-]/g, "");
|
|
slugInput.value = slug;
|
|
slugPreview.textContent = slug ? `${slug}.rspace.online` : "___.rspace.online";
|
|
});
|
|
|
|
async function submitCreateCommunity() {
|
|
errorMessage.style.display = "none";
|
|
|
|
const name = nameInput.value.trim();
|
|
const slug = slugInput.value.trim();
|
|
const visibility = document.querySelector('input[name="visibility"]:checked').value;
|
|
|
|
if (!name || !slug) {
|
|
errorMessage.textContent = "Please fill in all fields";
|
|
errorMessage.style.display = "block";
|
|
return;
|
|
}
|
|
|
|
const token = getAccessToken();
|
|
if (!token) {
|
|
errorMessage.textContent = "Authentication token missing. Please sign in again.";
|
|
errorMessage.style.display = "block";
|
|
return;
|
|
}
|
|
|
|
const submitBtn = form.querySelector(".submit-btn");
|
|
submitBtn.disabled = true;
|
|
submitBtn.textContent = "Creating...";
|
|
|
|
try {
|
|
const response = await fetch("/api/communities", {
|
|
method: "POST",
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
"Authorization": `Bearer ${token}`,
|
|
},
|
|
body: JSON.stringify({ name, slug, visibility }),
|
|
});
|
|
|
|
const data = await response.json();
|
|
|
|
if (!response.ok) {
|
|
throw new Error(data.error || "Failed to create community");
|
|
}
|
|
|
|
window.location.href = `/${slug}/canvas`;
|
|
} catch (err) {
|
|
errorMessage.textContent = err.message;
|
|
errorMessage.style.display = "block";
|
|
submitBtn.disabled = false;
|
|
submitBtn.textContent = "Create Space";
|
|
}
|
|
}
|
|
|
|
form.addEventListener("submit", (e) => {
|
|
e.preventDefault();
|
|
|
|
if (!isAuthenticated()) {
|
|
requireAuth(() => submitCreateCommunity());
|
|
return;
|
|
}
|
|
|
|
submitCreateCommunity();
|
|
});
|
|
|
|
// Listen for theme changes from other components
|
|
window.addEventListener("storage", (e) => {
|
|
if (e.key === "canvas-theme" && e.newValue) {
|
|
document.documentElement.setAttribute("data-theme", e.newValue);
|
|
}
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|