Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2da42fa201
|
@@ -1,4 +1,5 @@
|
|||||||
node_modules
|
node_modules
|
||||||
dist
|
dist
|
||||||
|
.astro
|
||||||
*.log
|
*.log
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
import { defineConfig } from 'astro/config';
|
||||||
|
|
||||||
|
// Astro builds with Vite under the hood. The page ships as static HTML;
|
||||||
|
// the interactive logic lives in a bundled client <script> in index.astro.
|
||||||
|
export default defineConfig({});
|
||||||
-13
@@ -1,13 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="de">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
||||||
<title>Logo-Generator</title>
|
|
||||||
<link href="https://fonts.googleapis.com/css2?family=Anton&family=Bowlby+One&family=Bebas+Neue&family=Bungee&family=Passion+One:wght@900&family=Ultra&display=swap" rel="stylesheet">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div id="app"></div>
|
|
||||||
<script type="module" src="/src/main.js"></script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
Generated
+4427
-340
File diff suppressed because it is too large
Load Diff
+8
-9
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "demo-ecmascript-svelte",
|
"name": "demo-ecmascript-astro",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"description": "LIBRETECH logo generator — Svelte + Vite",
|
"description": "LIBRETECH logo generator — Astro (Vite)",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "ssh://tengo@git.librete.ch:41240/public/demo-ecmascript.git"
|
"url": "ssh://tengo@git.librete.ch:41240/public/demo-ecmascript.git"
|
||||||
@@ -9,13 +9,12 @@
|
|||||||
"license": "WTFPL",
|
"license": "WTFPL",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "astro dev",
|
||||||
"build": "vite build",
|
"build": "astro build",
|
||||||
"preview": "vite preview"
|
"preview": "astro preview",
|
||||||
|
"astro": "astro"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"dependencies": {
|
||||||
"@sveltejs/vite-plugin-svelte": "^5.0.3",
|
"astro": "^5.1.1"
|
||||||
"svelte": "^5.16.0",
|
|
||||||
"vite": "^6.0.0"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
-133
@@ -1,133 +0,0 @@
|
|||||||
<script>
|
|
||||||
import { defaults, fonts, logoStyle, cssOutput } from './logo.js';
|
|
||||||
|
|
||||||
const FONT_LABELS = { Impact: 'Impact (System)' };
|
|
||||||
|
|
||||||
let s = $state({ ...defaults });
|
|
||||||
let copied = $state(false);
|
|
||||||
|
|
||||||
const css = $derived(cssOutput(s));
|
|
||||||
const logoCss = $derived(styleString(logoStyle(s)));
|
|
||||||
|
|
||||||
$effect(() => {
|
|
||||||
document.body.style.background = s.bg;
|
|
||||||
});
|
|
||||||
|
|
||||||
// logoStyle() returns a camelCase object; the style attribute needs a string.
|
|
||||||
function styleString(obj) {
|
|
||||||
return Object.entries(obj)
|
|
||||||
.map(([k, v]) => `${k.replace(/[A-Z]/g, (m) => '-' + m.toLowerCase())}:${v}`)
|
|
||||||
.join(';');
|
|
||||||
}
|
|
||||||
|
|
||||||
async function copy() {
|
|
||||||
try {
|
|
||||||
await navigator.clipboard.writeText(css);
|
|
||||||
copied = true;
|
|
||||||
setTimeout(() => (copied = false), 1500);
|
|
||||||
} catch {
|
|
||||||
alert('Kopieren fehlgeschlagen — bitte manuell aus dem Code-Feld kopieren.');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function onSubmit(e) {
|
|
||||||
e.preventDefault();
|
|
||||||
}
|
|
||||||
|
|
||||||
// bind:value owns the values, so restore defaults explicitly on reset.
|
|
||||||
function onReset(e) {
|
|
||||||
e.preventDefault();
|
|
||||||
s = { ...defaults };
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<div class="logo" style={logoCss}>{s.text || ' '}</div>
|
|
||||||
|
|
||||||
<details class="disclosure" id="panel" open>
|
|
||||||
<summary class="toggle-panel">Panel ein/aus</summary>
|
|
||||||
|
|
||||||
<div class="panel">
|
|
||||||
<h1>Logo-Generator</h1>
|
|
||||||
|
|
||||||
<form id="logoForm" onsubmit={onSubmit} onreset={onReset}>
|
|
||||||
<h2>Inhalt</h2>
|
|
||||||
<p class="hint" id="hint-text">Mehrere Zeilen mit Enter trennen.</p>
|
|
||||||
<textarea id="text" rows="2" aria-label="Logo-Text" aria-describedby="hint-text" bind:value={s.text}></textarea>
|
|
||||||
|
|
||||||
<h2>Schrift</h2>
|
|
||||||
<select id="font" aria-label="Schriftart" bind:value={s.font}>
|
|
||||||
{#each fonts as f}
|
|
||||||
<option value={f}>{FONT_LABELS[f] || f}</option>
|
|
||||||
{/each}
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<div class="row-2col">
|
|
||||||
<div>
|
|
||||||
<label for="fs">Größe: <span class="val">{s.fs}</span>vw</label>
|
|
||||||
<input type="range" id="fs" min="6" max="30" step="0.5" bind:value={s.fs} />
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<label for="lh">Zeilenabstand: <span class="val">{s.lh.toFixed(2)}</span></label>
|
|
||||||
<input type="range" id="lh" min="0.5" max="2" step="0.05" bind:value={s.lh} />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<label for="ls">Buchstabenabstand: <span class="val">{s.ls.toFixed(3)}</span>em</label>
|
|
||||||
<input type="range" id="ls" min="-0.15" max="0.3" step="0.005" bind:value={s.ls} />
|
|
||||||
|
|
||||||
<h2>Farben</h2>
|
|
||||||
<div class="color-row">
|
|
||||||
<input type="color" id="c-bg" bind:value={s.bg} aria-labelledby="lbl-bg" />
|
|
||||||
<span class="swatch-label" id="lbl-bg">Hintergrund</span>
|
|
||||||
<span class="hex">{s.bg}</span>
|
|
||||||
</div>
|
|
||||||
<div class="color-row">
|
|
||||||
<input type="color" id="c-face" bind:value={s.face} aria-labelledby="lbl-face" />
|
|
||||||
<span class="swatch-label" id="lbl-face">Face</span>
|
|
||||||
<span class="hex">{s.face}</span>
|
|
||||||
</div>
|
|
||||||
<div class="color-row">
|
|
||||||
<input type="color" id="c-depth" bind:value={s.depth} aria-labelledby="lbl-depth" />
|
|
||||||
<span class="swatch-label" id="lbl-depth">Tiefe</span>
|
|
||||||
<span class="hex">{s.depth}</span>
|
|
||||||
</div>
|
|
||||||
<div class="color-row">
|
|
||||||
<input type="color" id="c-shadow" bind:value={s.shadow} aria-labelledby="lbl-shadow" />
|
|
||||||
<span class="swatch-label" id="lbl-shadow">Schatten & Kontur</span>
|
|
||||||
<span class="hex">{s.shadow}</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<h2>Lichtrichtung</h2>
|
|
||||||
<p class="hint">Steuert alle Versätze gleichzeitig — Schatten geht in Lichtrichtung, Tiefe entgegen.</p>
|
|
||||||
<label for="angle">Winkel: <span class="val">{s.angle}</span>° (0=oben, 90=rechts, 180=unten)</label>
|
|
||||||
<input type="range" id="angle" min="0" max="359" bind:value={s.angle} />
|
|
||||||
|
|
||||||
<h2>Schichten</h2>
|
|
||||||
<p class="hint">Hinten nach vorn: Schatten · Tiefe · Kontur · Face</p>
|
|
||||||
<label for="shadow-len">Schatten-Länge: <span class="val">{s.shadowLen}</span>px</label>
|
|
||||||
<input type="range" id="shadow-len" min="0" max="80" bind:value={s.shadowLen} />
|
|
||||||
<label for="depth-len">Tiefe (in Gegenrichtung): <span class="val">{s.depthLen}</span>px</label>
|
|
||||||
<input type="range" id="depth-len" min="0" max="30" bind:value={s.depthLen} />
|
|
||||||
<label for="contour-len">Kontur (vor der Tiefe): <span class="val">{s.contourLen}</span>px</label>
|
|
||||||
<input type="range" id="contour-len" min="0" max="20" bind:value={s.contourLen} />
|
|
||||||
|
|
||||||
<h2>Komposition</h2>
|
|
||||||
<div class="row-2col">
|
|
||||||
<div>
|
|
||||||
<label for="rot">Drehung: <span class="val">{s.rot}</span>°</label>
|
|
||||||
<input type="range" id="rot" min="-25" max="25" bind:value={s.rot} />
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<label for="skew">Schräge: <span class="val">{s.skew}</span>°</label>
|
|
||||||
<input type="range" id="skew" min="-20" max="20" bind:value={s.skew} />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<h2>Generiertes CSS</h2>
|
|
||||||
<code id="cssout">{css}</code>
|
|
||||||
<button type="button" class="copy-btn" class:copied onclick={copy}>
|
|
||||||
{copied ? 'Kopiert!' : 'CSS kopieren'}
|
|
||||||
</button>
|
|
||||||
<button type="reset" class="reset-btn">Zurücksetzen</button>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</details>
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
import { mount } from 'svelte';
|
|
||||||
import App from './App.svelte';
|
|
||||||
import './style.css';
|
|
||||||
|
|
||||||
const app = mount(App, { target: document.getElementById('app') });
|
|
||||||
|
|
||||||
export default app;
|
|
||||||
@@ -0,0 +1,200 @@
|
|||||||
|
---
|
||||||
|
import { defaults, fonts } from '../logo.js';
|
||||||
|
import '../styles/style.css';
|
||||||
|
|
||||||
|
const FONT_LABELS = { Impact: 'Impact (System)' };
|
||||||
|
---
|
||||||
|
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="de">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
|
<title>Logo-Generator</title>
|
||||||
|
<link href="https://fonts.googleapis.com/css2?family=Anton&family=Bowlby+One&family=Bebas+Neue&family=Bungee&family=Passion+One:wght@900&family=Ultra&display=swap" rel="stylesheet" />
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="logo" id="logo">{defaults.text}</div>
|
||||||
|
|
||||||
|
<details class="disclosure" id="panel" open>
|
||||||
|
<summary class="toggle-panel">Panel ein/aus</summary>
|
||||||
|
|
||||||
|
<div class="panel">
|
||||||
|
<h1>Logo-Generator</h1>
|
||||||
|
|
||||||
|
<form id="logoForm">
|
||||||
|
<h2>Inhalt</h2>
|
||||||
|
<p class="hint" id="hint-text">Mehrere Zeilen mit Enter trennen.</p>
|
||||||
|
<textarea id="text" rows="2" aria-label="Logo-Text" aria-describedby="hint-text">{defaults.text}</textarea>
|
||||||
|
|
||||||
|
<h2>Schrift</h2>
|
||||||
|
<select id="font" aria-label="Schriftart">
|
||||||
|
{fonts.map((f) => <option value={f}>{FONT_LABELS[f] ?? f}</option>)}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<div class="row-2col">
|
||||||
|
<div>
|
||||||
|
<label for="fs">Größe: <span class="val" id="v-fs">{defaults.fs}</span>vw</label>
|
||||||
|
<input type="range" id="fs" min="6" max="30" step="0.5" value={defaults.fs} />
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label for="lh">Zeilenabstand: <span class="val" id="v-lh">{defaults.lh.toFixed(2)}</span></label>
|
||||||
|
<input type="range" id="lh" min="0.5" max="2" step="0.05" value={defaults.lh} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<label for="ls">Buchstabenabstand: <span class="val" id="v-ls">{defaults.ls.toFixed(3)}</span>em</label>
|
||||||
|
<input type="range" id="ls" min="-0.15" max="0.3" step="0.005" value={defaults.ls} />
|
||||||
|
|
||||||
|
<h2>Farben</h2>
|
||||||
|
<div class="color-row">
|
||||||
|
<input type="color" id="c-bg" value={defaults.bg} aria-labelledby="lbl-bg" />
|
||||||
|
<span class="swatch-label" id="lbl-bg">Hintergrund</span>
|
||||||
|
<span class="hex" id="hex-bg">{defaults.bg}</span>
|
||||||
|
</div>
|
||||||
|
<div class="color-row">
|
||||||
|
<input type="color" id="c-face" value={defaults.face} aria-labelledby="lbl-face" />
|
||||||
|
<span class="swatch-label" id="lbl-face">Face</span>
|
||||||
|
<span class="hex" id="hex-face">{defaults.face}</span>
|
||||||
|
</div>
|
||||||
|
<div class="color-row">
|
||||||
|
<input type="color" id="c-depth" value={defaults.depth} aria-labelledby="lbl-depth" />
|
||||||
|
<span class="swatch-label" id="lbl-depth">Tiefe</span>
|
||||||
|
<span class="hex" id="hex-depth">{defaults.depth}</span>
|
||||||
|
</div>
|
||||||
|
<div class="color-row">
|
||||||
|
<input type="color" id="c-shadow" value={defaults.shadow} aria-labelledby="lbl-shadow" />
|
||||||
|
<span class="swatch-label" id="lbl-shadow">Schatten & Kontur</span>
|
||||||
|
<span class="hex" id="hex-shadow">{defaults.shadow}</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h2>Lichtrichtung</h2>
|
||||||
|
<p class="hint">Steuert alle Versätze gleichzeitig — Schatten geht in Lichtrichtung, Tiefe entgegen.</p>
|
||||||
|
<label for="angle">Winkel: <span class="val" id="v-angle">{defaults.angle}</span>° (0=oben, 90=rechts, 180=unten)</label>
|
||||||
|
<input type="range" id="angle" min="0" max="359" value={defaults.angle} />
|
||||||
|
|
||||||
|
<h2>Schichten</h2>
|
||||||
|
<p class="hint">Hinten nach vorn: Schatten · Tiefe · Kontur · Face</p>
|
||||||
|
<label for="shadow-len">Schatten-Länge: <span class="val" id="v-shadow">{defaults.shadowLen}</span>px</label>
|
||||||
|
<input type="range" id="shadow-len" min="0" max="80" value={defaults.shadowLen} />
|
||||||
|
<label for="depth-len">Tiefe (in Gegenrichtung): <span class="val" id="v-depth">{defaults.depthLen}</span>px</label>
|
||||||
|
<input type="range" id="depth-len" min="0" max="30" value={defaults.depthLen} />
|
||||||
|
<label for="contour-len">Kontur (vor der Tiefe): <span class="val" id="v-contour">{defaults.contourLen}</span>px</label>
|
||||||
|
<input type="range" id="contour-len" min="0" max="20" value={defaults.contourLen} />
|
||||||
|
|
||||||
|
<h2>Komposition</h2>
|
||||||
|
<div class="row-2col">
|
||||||
|
<div>
|
||||||
|
<label for="rot">Drehung: <span class="val" id="v-rot">{defaults.rot}</span>°</label>
|
||||||
|
<input type="range" id="rot" min="-25" max="25" value={defaults.rot} />
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label for="skew">Schräge: <span class="val" id="v-skew">{defaults.skew}</span>°</label>
|
||||||
|
<input type="range" id="skew" min="-20" max="20" value={defaults.skew} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h2>Generiertes CSS</h2>
|
||||||
|
<code id="cssout"></code>
|
||||||
|
<button type="button" class="copy-btn" id="copyBtn">CSS kopieren</button>
|
||||||
|
<button type="reset" class="reset-btn" id="resetBtn">Zurücksetzen</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { inlineTextShadow, cssOutput } from '../logo.js';
|
||||||
|
|
||||||
|
const $ = (id) => document.getElementById(id);
|
||||||
|
const logo = $('logo');
|
||||||
|
const cssout = $('cssout');
|
||||||
|
|
||||||
|
const NUM = {
|
||||||
|
fs: 'fs',
|
||||||
|
lh: 'lh',
|
||||||
|
ls: 'ls',
|
||||||
|
angle: 'angle',
|
||||||
|
shadowLen: 'shadow-len',
|
||||||
|
depthLen: 'depth-len',
|
||||||
|
contourLen: 'contour-len',
|
||||||
|
rot: 'rot',
|
||||||
|
skew: 'skew',
|
||||||
|
};
|
||||||
|
|
||||||
|
function readState() {
|
||||||
|
return {
|
||||||
|
text: $('text').value || ' ',
|
||||||
|
font: $('font').value,
|
||||||
|
fs: +$('fs').value,
|
||||||
|
lh: +$('lh').value,
|
||||||
|
ls: +$('ls').value,
|
||||||
|
bg: $('c-bg').value,
|
||||||
|
face: $('c-face').value,
|
||||||
|
depth: $('c-depth').value,
|
||||||
|
shadow: $('c-shadow').value,
|
||||||
|
angle: +$('angle').value,
|
||||||
|
shadowLen: +$('shadow-len').value,
|
||||||
|
depthLen: +$('depth-len').value,
|
||||||
|
contourLen: +$('contour-len').value,
|
||||||
|
rot: +$('rot').value,
|
||||||
|
skew: +$('skew').value,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function render() {
|
||||||
|
const s = readState();
|
||||||
|
|
||||||
|
$('v-fs').textContent = s.fs;
|
||||||
|
$('v-lh').textContent = s.lh.toFixed(2);
|
||||||
|
$('v-ls').textContent = s.ls.toFixed(3);
|
||||||
|
$('v-angle').textContent = s.angle;
|
||||||
|
$('v-shadow').textContent = s.shadowLen;
|
||||||
|
$('v-depth').textContent = s.depthLen;
|
||||||
|
$('v-contour').textContent = s.contourLen;
|
||||||
|
$('v-rot').textContent = s.rot;
|
||||||
|
$('v-skew').textContent = s.skew;
|
||||||
|
$('hex-bg').textContent = s.bg;
|
||||||
|
$('hex-face').textContent = s.face;
|
||||||
|
$('hex-depth').textContent = s.depth;
|
||||||
|
$('hex-shadow').textContent = s.shadow;
|
||||||
|
|
||||||
|
logo.textContent = s.text;
|
||||||
|
logo.style.textShadow = inlineTextShadow(s);
|
||||||
|
logo.style.transform = `rotate(${s.rot}deg) skewX(${s.skew}deg)`;
|
||||||
|
logo.style.fontFamily = `'${s.font}', 'Bebas Neue', Impact, sans-serif`;
|
||||||
|
logo.style.color = s.face;
|
||||||
|
logo.style.fontSize = s.fs + 'vw';
|
||||||
|
logo.style.lineHeight = s.lh;
|
||||||
|
logo.style.letterSpacing = s.ls + 'em';
|
||||||
|
document.body.style.background = s.bg;
|
||||||
|
|
||||||
|
cssout.textContent = cssOutput(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
document
|
||||||
|
.querySelectorAll('#logoForm input, #logoForm select, #logoForm textarea')
|
||||||
|
.forEach((el) => el.addEventListener('input', render));
|
||||||
|
|
||||||
|
$('copyBtn').addEventListener('click', async () => {
|
||||||
|
try {
|
||||||
|
await navigator.clipboard.writeText(cssout.textContent);
|
||||||
|
const btn = $('copyBtn');
|
||||||
|
btn.textContent = 'Kopiert!';
|
||||||
|
btn.classList.add('copied');
|
||||||
|
setTimeout(() => {
|
||||||
|
btn.textContent = 'CSS kopieren';
|
||||||
|
btn.classList.remove('copied');
|
||||||
|
}, 1500);
|
||||||
|
} catch {
|
||||||
|
alert('Kopieren fehlgeschlagen — bitte manuell aus dem Code-Feld kopieren.');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Native reset restores each field to its value= attribute; re-render next tick.
|
||||||
|
const form = $('logoForm');
|
||||||
|
form.addEventListener('reset', () => setTimeout(render, 0));
|
||||||
|
form.addEventListener('submit', (e) => e.preventDefault());
|
||||||
|
|
||||||
|
render();
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -9,7 +9,6 @@ body {
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
transition: background 0.15s;
|
transition: background 0.15s;
|
||||||
}
|
}
|
||||||
#app { display: contents; }
|
|
||||||
.logo {
|
.logo {
|
||||||
font-size: 18vw;
|
font-size: 18vw;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
|
|
||||||
|
|
||||||
export default {
|
|
||||||
preprocess: vitePreprocess(),
|
|
||||||
};
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
import { defineConfig } from 'vite';
|
|
||||||
import { svelte } from '@sveltejs/vite-plugin-svelte';
|
|
||||||
|
|
||||||
export default defineConfig({
|
|
||||||
plugins: [svelte()],
|
|
||||||
});
|
|
||||||
Reference in New Issue
Block a user