anycoder-e7e10300 / index.html
asiriagent's picture
Upload folder using huggingface_hub
455f785 verified
Raw History Blame Contribute Delete
24.5 kB
<!DOCTYPE html>
<html lang="fa" dir="rtl">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>بساز | UI Builder حرفه‌ای</title>
<!-- Fonts & Icons -->
<link href="https://fonts.googleapis.com/css2?family=Vazirmatn:wght@100..900&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
/*
---------------------------------------------------------
Core Variables & Reset
---------------------------------------------------------
*/
:root {
/* App Theme Colors */
--app-bg: #0f172a;
--panel-bg: #1e293b;
--panel-border: #334155;
--text-main: #f8fafc;
--text-muted: #94a3b8;
--accent: #38bdf8;
--accent-hover: #0ea5e9;
--danger: #ef4444;
/* Card Defaults */
--card-bg: rgba(255, 255, 255, 0.05);
--card-border: rgba(255, 255, 255, 0.1);
--card-blur: 12px;
--card-radius: 24px;
--card-padding: 32px;
--card-width: 340px;
--card-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
--card-text: #ffffff;
--card-img-radius: 50%;
/* Button Defaults */
--btn-bg: #38bdf8;
--btn-text: #0f172a;
--btn-radius: 50px;
--btn-padding: 12px 24px;
/* Font */
--font-main: 'Vazirmatn', sans-serif;
}
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
font-family: var(--font-main);
background-color: var(--app-bg);
color: var(--text-main);
height: 100vh;
overflow: hidden;
display: flex;
flex-direction: column;
}
/*
---------------------------------------------------------
Background & Effects
---------------------------------------------------------
*/
.bg-mesh {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: -1;
overflow: hidden;
background: radial-gradient(circle at 15% 50%, rgba(56, 189, 248, 0.15), transparent 25%),
radial-gradient(circle at 85% 30%, rgba(139, 92, 246, 0.15), transparent 25%);
}
.orb {
position: absolute;
border-radius: 50%;
filter: blur(80px);
opacity: 0.4;
animation: float 10s infinite ease-in-out alternate;
}
.orb-1 { width: 300px; height: 300px; background: #38bdf8; top: -50px; left: -50px; }
.orb-2 { width: 400px; height: 400px; background: #818cf8; bottom: -100px; right: -100px; animation-delay: -5s; }
@keyframes float {
0% { transform: translate(0, 0); }
100% { transform: translate(30px, 50px); }
}
/*
---------------------------------------------------------
Header
---------------------------------------------------------
*/
header {
height: 70px;
border-bottom: 1px solid var(--panel-border);
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 30px;
background: rgba(15, 23, 42, 0.7);
backdrop-filter: blur(12px);
z-index: 100;
}
.brand {
display: flex;
align-items: center;
gap: 12px;
font-size: 1.6rem;
font-weight: 900;
background: linear-gradient(135deg, #fff, #94a3b8);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
.brand i { -webkit-text-fill-color: var(--accent); }
.header-actions {
display: flex;
gap: 15px;
}
.anycoder-link {
text-decoration: none;
color: var(--text-muted);
font-size: 0.9rem;
display: flex;
align-items: center;
gap: 8px;
transition: 0.3s;
padding: 8px 16px;
border-radius: 12px;
background: rgba(255,255,255,0.05);
}
.anycoder-link:hover {
color: var(--accent);
background: rgba(255,255,255,0.1);
}
/*
---------------------------------------------------------
Main Layout
---------------------------------------------------------
*/
main {
display: flex;
flex: 1;
height: calc(100vh - 70px);
overflow: hidden;
}
/*
---------------------------------------------------------
Sidebar (Controls)
---------------------------------------------------------
*/
aside {
width: 380px;
background: var(--panel-bg);
border-left: 1px solid var(--panel-border);
display: flex;
flex-direction: column;
overflow: hidden;
box-shadow: -10px 0 30px rgba(0,0,0,0.2);
z-index: 10;
}
.sidebar-header {
padding: 20px;
border-bottom: 1px solid var(--panel-border);
font-weight: bold;
color: var(--accent);
display: flex;
justify-content: space-between;
align-items: center;
}
.scroll-area {
flex: 1;
overflow-y: auto;
padding: 20px;
display: flex;
flex-direction: column;
gap: 25px;
}
/* Custom Scrollbar */
.scroll-area::-webkit-scrollbar { width: 6px; }
.scroll-area::-webkit-scrollbar-track { background: transparent; }
.scroll-area::-webkit-scrollbar-thumb { background: var(--panel-border); border-radius: 10px; }
.scroll-area::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
.control-section h3 {
font-size: 0.85rem;
text-transform: uppercase;
letter-spacing: 1px;
color: var(--text-muted);
margin-bottom: 15px;
display: flex;
align-items: center;
gap: 8px;
}
.input-group {
margin-bottom: 18px;
}
.input-row {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 8px;
}
label {
font-size: 0.9rem;
color: var(--text-main);
}
.value-display {
font-size: 0.8rem;
color: var(--text-muted);
font-family: monospace;
background: rgba(0,0,0,0.2);
padding: 2px 6px;
border-radius: 4px;
}
/* Modern Inputs */
input[type="text"],
textarea,
input[type="url"] {
width: 100%;
background: rgba(15, 23, 42, 0.6);
border: 1px solid var(--panel-border);
color: white;
padding: 10px 12px;
border-radius: 8px;
font-family: inherit;
font-size: 0.95rem;
transition: 0.2s;
}
input[type="text"]:focus,
textarea:focus,
input[type="url"]:focus {
border-color: var(--accent);
box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}
textarea { resize: vertical; min-height: 80px; }
input[type="color"] {
-webkit-appearance: none;
border: none;
width: 32px;
height: 32px;
border-radius: 8px;
cursor: pointer;
background: none;
padding: 0;
}
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: 1px solid var(--panel-border); border-radius: 8px; }
input[type="range"] {
width: 100%;
height: 6px;
background: rgba(255,255,255,0.1);
border-radius: 5px;
outline: none;
-webkit-appearance: none;
}
input[type="range"]::-webkit-slider-thumb {
-webkit-appearance: none;
width: 18px;
height: 18px;
border-radius: 50%;
background: var(--accent);
cursor: pointer;
transition: 0.2s;
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.2); }
/*
---------------------------------------------------------
Preview Area
---------------------------------------------------------
*/
.preview-stage {
flex: 1;
display: flex;
align-items: center;
justify-content: center;
position: relative;
perspective: 1000px;
overflow: hidden;
/* Optional: Checkerboard for transparency check */
background-image:
linear-gradient(45deg, rgba(255,255,255,0.03) 25%, transparent 25%),
linear-gradient(-45deg, rgba(255,255,255,0.03) 25%, transparent 25%),
linear-gradient(45deg, transparent 75%, rgba(255,255,255,0.03) 75%),
linear-gradient(-45deg, transparent 75%, rgba(255,255,255,0.03) 75%);
background-size: 20px 20px;
}
/* Floating Elements for Depth */
.floating-shape {
position: absolute;
border-radius: 50%;
background: rgba(255,255,255,0.1);
z-index: 0;
}
.shape-1 { width: 200px; height: 200px; top: 20%; left: 20%; background: rgba(56, 189, 248, 0.2); filter: blur(40px); animation: float 8s infinite ease-in-out; }
.shape-2 { width: 150px; height: 150px; bottom: 30%; right: 20%; background: rgba(139, 92, 246, 0.2); filter: blur(40px); animation: float 12s infinite ease-in-out reverse; }
/* The Card */
#glass-card {
background: var(--card-bg);
backdrop-filter: blur(var(--card-blur));
-webkit-backdrop-filter: blur(var(--card-blur));
border: 1px solid var(--card-border);
border-radius: var(--card-radius);
padding: var(--card-padding);
width: var(--card-width);
max-width: 90%;
color: var(--card-text);
box-shadow: var(--card-shadow);
display: flex;
flex-direction: column;
align-items: center;
text-align: center;
gap: 16px;
position: relative;
z-index: 1;
transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}
#glass-card img {
width: 100px;
height: 100px;
border-radius: var(--card-img-radius);
object-fit: cover;
border: 2px solid rgba(255,255,255,0.2);
transition: 0.3s;
}
#glass-card h3 { font-size: 1.5rem; margin: 0; font-weight: 700; }
#glass-card p { font-size: 0.95rem; line-height: 1.6; opacity: 0.9; margin: 0; }
#glass-card button {
margin-top: 10px;
background: var(--btn-bg);
color: var(--btn-text);
border: none;
padding: var(--btn-padding);
border-radius: var(--btn-radius);
font-weight: bold;
font-family: inherit;
cursor: pointer;
transition: 0.2s;
box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}
#glass-card button:hover {
transform: translateY(-2px);
filter: brightness(1.1);
box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}
/*
---------------------------------------------------------
Code Panel (Bottom of Sidebar)
---------------------------------------------------------
*/
.code-panel {
background: #0f172a;
border-top: 1px solid var(--panel-border);
padding: 15px;
display: flex;
flex-direction: column;
gap: 10px;
}
.code-header {
display: flex;
justify-content: space-between;
align-items: center;
}
.code-output {
width: 100%;
height: 120px;
background: rgba(0,0,0,0.3);
border: 1px solid var(--panel-border);
border-radius: 8px;
color: #a5b4fc;
font-family: monospace;
font-size: 0.8rem;
padding: 10px;
resize: none;
}
.btn-copy {
width: 100%;
padding: 12px;
background: var(--accent);
color: #0f172a;
border: none;
border-radius: 8px;
font-weight: bold;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
gap: 8px;
transition: 0.2s;
}
.btn-copy:hover { background: var(--accent-hover); }
.toast {
position: fixed;
bottom: 20px;
left: 50%;
transform: translateX(-50%) translateY(100px);
background: var(--accent);
color: #0f172a;
padding: 10px 20px;
border-radius: 30px;
font-weight: bold;
box-shadow: 0 10px 30px rgba(0,0,0,0.5);
transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
z-index: 1000;
display: flex;
align-items: center;
gap: 8px;
}
.toast.show { transform: translateX(-50%) translateY(0); }
/*
---------------------------------------------------------
Responsive Design
---------------------------------------------------------
*/
@media (max-width: 900px) {
body { overflow: auto; height: auto; }
main { flex-direction: column; height: auto; }
aside {
width: 100%;
height: auto;
border-left: none;
border-bottom: 1px solid var(--panel-border);
}
.preview-stage {
min-height: 500px;
padding: 40px 20px;
}
.scroll-area {
max-height: 400px; /* Limit height on mobile sidebar */
}
}
</style>
</head>
<body>
<!-- Background Animation -->
<div class="bg-mesh">
<div class="orb orb-1"></div>
<div class="orb orb-2"></div>
</div>
<header>
<div class="brand">
<i class="fa-solid fa-layer-group"></i>
بساز
</div>
<div class="header-actions">
<a href="https://huggingface.co/spaces/akhaliq/anycoder" target="_blank" class="anycoder-link">
<span>Built with Anycoder</span>
<i class="fa-solid fa-code"></i>
</a>
</div>
</header>
<main>
<!-- Sidebar Controls -->
<aside>
<div class="sidebar-header">
<span>تنظیمات ظاهری</span>
<i class="fa-solid fa-sliders"></i>
</div>
<div class="scroll-area">
<!-- Section 1: Content -->
<div class="control-section">
<h3><i class="fa-solid fa-pen-to-square"></i> محتوا</h3>
<div class="input-group">
<label>تصویر پروفایل (URL)</label>
<input type="url" id="inp-img" value="https://images.unsplash.com/photo-1535713875002-d1d0cf377fde?auto=format&fit=crop&w=500&q=80" placeholder="لینک عکس...">
</div>
<div class="input-group">
<label>عنوان</label>
<input type="text" id="inp-title" value="عنوان دلخواه شما">
</div>
<div class="input-group">
<label>توضیحات</label>
<textarea id="inp-desc">این یک متن نمونه برای کارت گلس‌مورفیسم است. می‌توانید این متن را به راحتی ویرایش کنید.</textarea>
</div>
<div class="input-group">
<label>متن دکمه</label>
<input type="text" id="inp-btn-text" value="شروع کنید">
</div>
</div>
<!-- Section 2: Glass Effect -->
<div class="control-section">
<h3><i class="fa-solid fa-wand-magic-sparkles"></i> افکت شیشه‌ای</h3>
<div class="input-group">
<div class="input-row">
<label>رنگ پس‌زمینه</label>
<input type="color" id="inp-color-bg" value="#ffffff">
</div>
<input type="range" id="inp-opacity" min="0" max="1" step="0.05" value="0.1">
</div>
<div class="input-group">
<div class="input-row">
<label>رنگ حاشیه</label>
<input type="color" id="inp-color-border" value="#ffffff">
</div>
<input type="range" id="inp-border-opacity" min="0" max="1" step="0.05" value="0.2">
</div>
<div class="input-group">
<div class="input-row">
<label>تاری پس‌زمینه (Blur)</label>
<span class="value-display" id="val-blur">12px</span>
</div>
<input type="range" id="inp-blur" min="0" max="50" value="12">
</div>
</div>
<!-- Section 3: Shape & Layout -->
<div class="control-section">
<h3><i class="fa-solid fa-border-all"></i> ابعاد و شکل</h3>
<div class="input-group">
<div class="input-row">
<label>شعاع گوشه‌ها</label>
<span class="value-display" id="val-radius">24px</span>
</div>
<input type="range" id="inp-radius" min="0" max="60" value="24">
</div>
<div class="input-group">
<div class="input-row">
<label>عرض کارت</label>
<span class="value-display" id="val-width">340px</span>
</div>
<input type="range" id="inp-width" min="200" max="600" value="340">
</div>
<div class="input-group">
<label>رنگ متن</label>
<input type="color" id="inp-text-color" value="#ffffff">
</div>
</div>
<!-- Section 4: Button -->
<div class="control-section">
<h3><i class="fa-solid fa-hand-pointer"></i> استایل دکمه</h3>
<div class="input-group">
<label>رنگ دکمه</label>
<input type="color" id="inp-btn-bg" value="#38bdf8">
</div>
<div class="input-group">
<div class="input-row">
<label>شعاع دکمه</label>
<span class="value-display" id="val-btn-radius">50px</span>
</div>
<input type="range" id="inp-btn-radius" min="0" max="50" value="50">
</div>
</div>
</div>
<!-- Code Output -->
<div class="code-panel">
<div class="code-header">
<label>کد خروجی HTML & CSS</label>
<i class="fa-solid fa-code" style="color: var(--text-muted)"></i>
</div>
<textarea id="code-output" class="code-output" readonly></textarea>
<button class="btn-copy" onclick="copyCode()">
<i class="fa-regular fa-copy"></i> کپی کد
</button>
</div>
</aside>
<!-- Live Preview -->
<section class="preview-stage">
<!-- Decorative Background Shapes -->
<div class="floating-shape shape-1"></div>
<div class="floating-shape shape-2"></div>
<!-- The Card -->
<div id="glass-card">
<img src="https://images.unsplash.com/photo-1535713875002-d1d0cf377fde?auto=format&fit=crop&w=500&q=80" id="card-img" alt="Profile">
<h3 id="card-title">عنوان دلخواه شما</h3>
<p id="card-desc">این یک متن نمونه برای کارت گلس‌مورفیسم است. می‌توانید این متن را به راحتی ویرایش کنید.</p>
<button id="card-btn">شروع کنید</button>
</div>
</section>
</main>
<!-- Toast Notification -->
<div id="toast" class="toast">
<i class="fa-solid fa-check-circle"></i>
کد با موفقیت کپی شد!
</div>
<script>
// --- Configuration & Selectors ---
const inputs = {
title: document.getElementById('inp-title'),
desc: document.getElementById('inp-desc'),
img: document.getElementById('inp-img'),
btnText: document.getElementById('inp-btn-text'),
// Colors
bgColor: document.getElementById('inp-color-bg'),
bgOpacity: document.getElementById('inp-opacity'),
borderColor: document.getElementById('inp-color-border'),
borderOpacity: document.getElementById('inp-border-opacity'),
textColor: document.getElementById('inp-text-color'),
btnBg: document.getElementById('inp-btn-bg'),
// Sliders
blur: document.getElementById('inp-blur'),
radius: document.getElementById('inp-radius'),
width: document.getElementById('inp-width'),
btnRadius: document.getElementById('inp-btn-radius'),
};
const card = {
root: document.getElementById('glass-card'),
img: document.getElementById('card-img'),
title: document.getElementById('card-title'),
desc: document.getElementById('card-desc'),
btn: document.getElementById('card-btn')
};
const displays = {
blur: document.getElementById('val-blur'),
radius: document.getElementById('val-radius'),
width: document.getElementById('val-width'),
btnRadius: document.getElementById('val-btn-radius'),
};
const codeOutput = document.getElementById('code-output');
const toast = document.getElementById('toast');
// --- Helper Functions ---
// Convert Hex to RGBA
function hexToRgba(hex, opacity) {
let r = 0, g = 0, b = 0;
// 3 digits
if (hex.length === 4) {
r = "0x" + hex[1] + hex[1];
g = "0x" + hex[2] + hex[2];
b = "0x" + hex[3] + hex[3];
} else if (hex.length === 7) {
// 6 digits
r = "0x" + hex[1] + hex[2];
g = "0x" + hex[3] + hex[4];
b = "0x" + hex[5] + hex[6];
}
return `rgba(${+r}, ${+g}, ${+b}, ${opacity})`;
}
// --- Core Logic ---
function updateUI() {
// 1. Content
card.title.textContent = inputs.title.value;
card.desc.textContent = inputs.desc.value;
card.btn.textContent = inputs.btnText.value;
card.img.src = inputs.img.value;
// 2. Calculate Colors
const bgStyle = hexToRgba(inputs.bgColor.value, inputs.bgOpacity.value);
const borderStyle = hexToRgba(inputs.borderColor.value, inputs.borderOpacity.value);
// 3. Apply Styles to Card
card.root.style.setProperty('--card-bg', bgStyle);
card.root.style.setProperty('--card-border', borderStyle);
card.root.style.setProperty('--card-blur', `${inputs.blur.value}px`);
card.root.style.setProperty('--card-radius', `${inputs.radius.value}px`);
card.root.style.setProperty('--card-width', `${inputs.width.value}px`);
card.root.style.setProperty('--card-text', inputs.textColor.value);
card.root.style.setProperty('--btn-bg', inputs.btnBg.value);
card.root.style.setProperty('--btn-radius', `${inputs.btnRadius.value}px`);
// 4. Update Text Displays
displays.blur.textContent = `${inputs.blur.value}px`;
displays.radius.textContent = `${inputs.radius.value}px`;
displays.width.textContent = `${inputs.width.value}px`;
displays.btnRadius.textContent = `${inputs.btnRadius.value}px`;
// 5. Generate Code
generateCode(bgStyle, borderStyle);
}
function generateCode(bgStyle, borderStyle) {
const code = `
<!-- Glassmorphism Card -->
<style>
.glass-card {
/* Dimensions */
width: ${inputs.width.value}px;
max-width: 100%;
padding: 32px;
border-radius: ${inputs.radius.value}px;
/* Glass Effect */
background: ${bgStyle};
backdrop-filter: blur(${inputs.blur.value}px);
-webkit-backdrop-filter: blur(${inputs.blur.value}px);
border: 1px solid ${borderStyle};
box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
/* Text */
color: ${inputs.textColor.value};
font-family: 'Tahoma', sans-serif; /* Or Vazirmatn */
text-align: center;
/* Layout */
display: flex;
flex-direction: column;
align-items: center;
gap: 16px;
}
.glass-card img {
width: 100px;
height: 100px;
border-radius: 50%;
object-fit: cover;
border: 2px solid rgba(255,255,255,0.2);
}
.glass-card button {
margin-top: 10px;
padding: 12px 24px;
background: ${inputs.btnBg.value};
color: #fff; /* Assuming white text for button, use contrast checker for prod */
border: none;
border-radius: ${inputs.btnRadius.value}px;
font-weight: bold;
cursor: pointer;
transition: transform 0.2s;
}
.glass-card button:hover {
transform: scale(1.05);
}
</style>
<div class="glass-card">
<img src="${inputs.img.value}" alt="Profile">
<h3>${inputs.title.value}</h3>
<p>${inputs.desc.value}</p>
<button>${inputs.btnText.value}</button>
</div>
`;
codeOutput.value = code.trim();
}
function copyCode() {
codeOutput.select();
document.execCommand('copy');
// Show Toast
toast.classList.add('show');
setTimeout(() => {
toast.classList.remove('show');
}, 2500);
}
// --- Event Listeners ---
// Attach listener to all inputs
Object.values(inputs).forEach(input => {
input.addEventListener('input', updateUI);
});
// Initial Load
updateUI();
</script>
</body>
</html>