feat: Change file structure
- Move return object to named export for 11ty config - screens is now view - 11ty data files moved to view/_data - templates is now view/_includes - Both are the default directories - data is now used as intended, for user data - Update index to reflect filenames and structure
This commit is contained in:
parent
610e22b3c9
commit
b67a8a893a
78 changed files with 21 additions and 19 deletions
60
source/view/demo/examples/ui/cli.liquid
Normal file
60
source/view/demo/examples/ui/cli.liquid
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
---
|
||||
title: CLI
|
||||
tags:
|
||||
- ui
|
||||
---
|
||||
{% assign bodyClass = 'body_cli' -%}
|
||||
{% layout 'hippie/app.liquid' %}
|
||||
|
||||
{% block body %}
|
||||
<div id="cli">
|
||||
<div id="history">
|
||||
<pre>Previous prompt</pre>
|
||||
</div>
|
||||
<div id="line">
|
||||
<textarea name="prefix" id="prefix" rows="1" cols="1" readonly>></textarea>
|
||||
<textarea name="prompt" id="prompt" rows="1" autofocus></textarea>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{%- block script %}
|
||||
{{ block.super -}}
|
||||
<script>
|
||||
function resizeTextArea(textarea) {
|
||||
const {style, value} = textarea;
|
||||
|
||||
style.height = style.minHeight = 'auto';
|
||||
style.minHeight = `${Math.min(textarea.scrollHeight + 4, parseInt(textarea.style.maxHeight))}px`;
|
||||
style.height = `${textarea.scrollHeight}px`;
|
||||
}
|
||||
|
||||
const textarea = document.getElementById('prompt');
|
||||
|
||||
document
|
||||
.body
|
||||
.addEventListener('click', () => {
|
||||
textarea.focus();
|
||||
});
|
||||
|
||||
textarea.addEventListener('input', () => {
|
||||
resizeTextArea(textarea);
|
||||
});
|
||||
|
||||
window.addEventListener("keydown", (event) => {
|
||||
if (event.key === 'Enter' && !event.shiftKey) {
|
||||
event.preventDefault();
|
||||
|
||||
const p = document.createElement("pre");
|
||||
|
||||
p.textContent = event.target.value;
|
||||
document
|
||||
.getElementById("history")
|
||||
.appendChild(p);
|
||||
// window.scrollTo(0, document.body.scrollHeight);
|
||||
|
||||
event.target.value = '';
|
||||
}
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
52
source/view/demo/examples/ui/drag.liquid
Executable file
52
source/view/demo/examples/ui/drag.liquid
Executable file
|
|
@ -0,0 +1,52 @@
|
|||
---
|
||||
title: Drag
|
||||
tags:
|
||||
- ui
|
||||
---
|
||||
{% layout 'hippie/app.liquid' %}
|
||||
|
||||
{% block body %}
|
||||
<header class="io pos_fix pin_top pin_right pin_left">
|
||||
<button data-action="add">Add</button>
|
||||
</header>
|
||||
<div id="space"></div>
|
||||
<div>
|
||||
<div id="test">
|
||||
<div class="body_frame">
|
||||
{% render 'hippie/partials/frame-header.liquid' %}
|
||||
<main></main>
|
||||
{% render 'hippie/partials/frame-mode.liquid' %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block assets %}
|
||||
{{ block.super -}}
|
||||
<script src="/js/drag.js"></script>
|
||||
{% endblock %}
|
||||
|
||||
{%- block script %}
|
||||
<script>
|
||||
// Get the space element
|
||||
const space = document.getElementById('space');
|
||||
const add = document.querySelector('[data-action=add]');
|
||||
const test = document.getElementById('test');
|
||||
|
||||
// Add event listener to the add space button
|
||||
add.addEventListener('click', () => {
|
||||
const newDiv = new NewDiv(100, 100, 100, 100, getRandomColor());
|
||||
newDiv.createDiv();
|
||||
newDiv.appendToFrame(space);
|
||||
});
|
||||
|
||||
// Create a new NewDiv instance
|
||||
const newDiv = new NewDiv(100, 100, 200, 200, '#000');
|
||||
newDiv.createDiv();
|
||||
newDiv.appendToFrame(space);
|
||||
|
||||
const explorer = new NewDiv(256, 128, 800, 600, '#fff', test);
|
||||
explorer.createDiv();
|
||||
explorer.appendToFrame(space);
|
||||
</script>
|
||||
{% endblock %}
|
||||
145
source/view/demo/examples/ui/explorer.liquid
Normal file
145
source/view/demo/examples/ui/explorer.liquid
Normal file
|
|
@ -0,0 +1,145 @@
|
|||
---
|
||||
title: Explorer
|
||||
tags:
|
||||
- ui
|
||||
---
|
||||
{% assign bodyClass = 'body_frame' -%}
|
||||
{% layout 'hippie/app.liquid' %}
|
||||
|
||||
{% block body %}
|
||||
{% render 'hippie/partials/frame-header.liquid' %}
|
||||
<main class="io">
|
||||
<aside class="io">
|
||||
<nav>
|
||||
<span>location-pane</span>
|
||||
<ul class="vertical">
|
||||
<li>
|
||||
<a class="a_button" href="">
|
||||
<span>Start/Home</span>
|
||||
<i class="bi bi-pin-fill"></i>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="a_button" href="">
|
||||
<span>System</span>
|
||||
<i class="bi bi-pin-fill"></i>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<hr>
|
||||
<nav>
|
||||
<ul class="vertical">
|
||||
<li>
|
||||
<a class="a_button" href="">
|
||||
<span>💽 disc link</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="a_button" href="">
|
||||
<span>📁 folder link</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="a_button" href="">
|
||||
<span>🔗 location link</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
</aside>
|
||||
<section>
|
||||
<header class="io">
|
||||
<nav>
|
||||
<button title="back">
|
||||
<i class="bi bi-caret-left"></i>
|
||||
</button>
|
||||
<button title="up">
|
||||
<i class="bi bi-caret-up"></i>
|
||||
</button>
|
||||
<button title="forward">
|
||||
<i class="bi bi-caret-right"></i>
|
||||
</button>
|
||||
<button title="reload">
|
||||
<i class="bi bi-arrow-clockwise"></i>
|
||||
</button>
|
||||
<input placeholder="//" type="text">
|
||||
</nav>
|
||||
<nav>
|
||||
<span>location-bar</span>
|
||||
<hr class="vertical">
|
||||
<button title="search">
|
||||
<i class="bi bi-search"></i>
|
||||
</button>
|
||||
<input placeholder="*" type="text">
|
||||
</nav>
|
||||
</header>
|
||||
<header class="io">
|
||||
<nav>
|
||||
<button title="add">
|
||||
<i class="bi bi-plus-circle"></i>
|
||||
</button>
|
||||
<div class="spacer a"></div>
|
||||
<button title="cut">
|
||||
<i class="bi bi-scissors"></i>
|
||||
</button>
|
||||
<button title="copy">
|
||||
<i class="bi bi-copy"></i>
|
||||
</button>
|
||||
<button title="paste">
|
||||
<i class="bi bi-clipboard-check-fill"></i>
|
||||
</button>
|
||||
<div class="spacer b"></div>
|
||||
<button title="delete">
|
||||
<i class="bi bi-trash"></i>
|
||||
</button>
|
||||
</nav>
|
||||
<hr class="vertical">
|
||||
<nav>
|
||||
<ul>
|
||||
<li>
|
||||
<button title="collapse">
|
||||
<i class="bi bi-arrows-collapse"></i>
|
||||
</button>
|
||||
</li>
|
||||
<li>
|
||||
<button title="expand">
|
||||
<i class="bi bi-arrows-expand-vertical"></i>
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
<span>options-bar</span>
|
||||
</nav>
|
||||
<nav></nav>
|
||||
</header>
|
||||
<div id="content">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>name</th>
|
||||
<th>date</th>
|
||||
<th>type</th>
|
||||
<th>size</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>folder</td>
|
||||
<td>YYYY-MM-DD</td>
|
||||
<td>folder</td>
|
||||
<td>4KB</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>file</td>
|
||||
<td>YYYY-MM-DD</td>
|
||||
<td>folder</td>
|
||||
<td>1B</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{% render 'hippie/partials/frame-status.liquid' %}
|
||||
</section>
|
||||
</main>
|
||||
{% render 'hippie/partials/frame-mode.liquid' %}
|
||||
{% endblock %}
|
||||
56
source/view/demo/examples/ui/form.liquid
Normal file
56
source/view/demo/examples/ui/form.liquid
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
---
|
||||
title: Form
|
||||
tags:
|
||||
- ui
|
||||
---
|
||||
{% assign bodyClass = 'body_frame' -%}
|
||||
{% layout 'hippie/app.liquid' %}
|
||||
|
||||
{% block body %}
|
||||
{% render 'hippie/partials/frame-header.liquid' %}
|
||||
<header class="io">
|
||||
<h1>Formulare</h1>
|
||||
<button data-action="add">Hinzufügen</button>
|
||||
<button data-action="change">Ändern</button>
|
||||
<hr>
|
||||
</header>
|
||||
<form id="form" action="">
|
||||
<div id="grid">
|
||||
<div>a</div>
|
||||
<div>b</div>
|
||||
<div>c</div>
|
||||
</div>
|
||||
</form>
|
||||
{% endblock %}
|
||||
|
||||
{%- block script %}
|
||||
{{ block.super -}}
|
||||
<script>
|
||||
const add = document.querySelector('[data-action=add]');
|
||||
const change = document.querySelector('[data-action=change]');
|
||||
const grid = document.getElementById('grid');
|
||||
|
||||
add.addEventListener('click', (e) => {
|
||||
const item = document.createElement('div');
|
||||
|
||||
item.style.backgroundColor = '#f0f';
|
||||
item.textContent = 'c'
|
||||
|
||||
grid.appendChild(item);
|
||||
});
|
||||
|
||||
change.addEventListener('click', (e) => {
|
||||
changeLayout(grid);
|
||||
});
|
||||
|
||||
function changeLayout(grid) {
|
||||
const currentTemplate = grid.style.gridTemplateColumns;
|
||||
|
||||
if (currentTemplate === 'repeat(4, 1fr)') {
|
||||
grid.style.gridTemplateColumns = 'repeat(2, 1fr)';
|
||||
} else {
|
||||
grid.style.gridTemplateColumns = 'repeat(4, 1fr)';
|
||||
}
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
||||
78
source/view/demo/examples/ui/gallery.liquid
Executable file
78
source/view/demo/examples/ui/gallery.liquid
Executable file
|
|
@ -0,0 +1,78 @@
|
|||
---
|
||||
title: Gallery
|
||||
tags:
|
||||
- ui
|
||||
---
|
||||
{% assign bodyClass = 'body_frame' -%}
|
||||
{% layout 'hippie/app.liquid' %}
|
||||
|
||||
{% block body %}
|
||||
{% render 'hippie/partials/frame-header.liquid' %}
|
||||
<main class="io">
|
||||
<section>
|
||||
<header class="io">
|
||||
<nav>
|
||||
<div class="group_nav">
|
||||
<input id="setSize" value="5" min="1" max="10" step="1" type="range"/>
|
||||
<label class="right" for="setSize">Größe</label>
|
||||
</div>
|
||||
<button title="details">
|
||||
<i class="bi bi-layout-sidebar-reverse"></i> Details
|
||||
</button>
|
||||
</nav>
|
||||
<nav></nav>
|
||||
</header>
|
||||
<div class="gallery">
|
||||
<div>A</div>
|
||||
<div>B</div>
|
||||
<div>C</div>
|
||||
</div>
|
||||
{% render 'hippie/partials/frame-status.liquid' %}
|
||||
</section>
|
||||
</main>
|
||||
{% render 'hippie/partials/frame-mode.liquid' %}
|
||||
{% endblock %}
|
||||
|
||||
{%- block script %}
|
||||
{{ block.super -}}
|
||||
<script>
|
||||
const sizeSlider = document.getElementById('setSize');
|
||||
const galleryItems = document.querySelectorAll('.gallery > div');
|
||||
|
||||
// Set the default size
|
||||
const defaultSize = 128; // In pixels
|
||||
const minSize = 16; // Minimum width in pixels
|
||||
const steps = 10;
|
||||
// Define specific sizes for each step (from 1 to 10)
|
||||
const sizes = [16, 32, 64, 96, 128, 256, 512, 1024, 2048]; // Sizes in pixels
|
||||
|
||||
|
||||
// Calculate width based on slider value
|
||||
function calculateWidth(value) {
|
||||
// Map 1-10 to a pixel width
|
||||
return Math.floor(minSize + (value - 1) * (defaultSize - minSize) / (steps - 1));
|
||||
}
|
||||
|
||||
// Set initial size
|
||||
galleryItems.forEach(item => {
|
||||
item.style.width = `${defaultSize}px`;
|
||||
item.style.width = `${sizes[5]}px`; // Initial width based on the default step (8 corresponds to index 7)
|
||||
});
|
||||
|
||||
sizeSlider.addEventListener('input', function () {
|
||||
console.debug('Change size');
|
||||
// const newSize = calculateWidth(Number(sizeSlider.value));
|
||||
// galleryItems.forEach(item => {
|
||||
// item.style.width = `${newSize}px`;
|
||||
// });
|
||||
const selectedStep = Number(sizeSlider.value) - 1; // Adjust for zero-indexing
|
||||
const newSize = sizes[selectedStep]; // Get size from the array using slider value
|
||||
galleryItems.forEach(item => {
|
||||
item.style.width = `${newSize}px`;
|
||||
});
|
||||
});
|
||||
|
||||
// Initialize slider to default
|
||||
sizeSlider.value = 6; // Sets default to 128px width
|
||||
</script>
|
||||
{% endblock %}
|
||||
24
source/view/demo/examples/ui/index.liquid
Normal file
24
source/view/demo/examples/ui/index.liquid
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
---
|
||||
title: UI
|
||||
tags:
|
||||
- demoExample
|
||||
- index
|
||||
---
|
||||
{% layout 'hippie/simple.liquid' %}
|
||||
|
||||
{% block title %}{{ title }}{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<div class="sec_main_center">
|
||||
<nav role="doc-toc">
|
||||
<h1>{{ title }}</h1>
|
||||
<ul class="link">
|
||||
{%- for ui in collections.ui -%}
|
||||
<li>
|
||||
<a href="{{ ui.page.url }}">{{ ui.data.title }}</a>
|
||||
</li>
|
||||
{%- endfor -%}
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
||||
{% endblock %}
|
||||
462
source/view/demo/examples/ui/table.liquid
Executable file
462
source/view/demo/examples/ui/table.liquid
Executable file
|
|
@ -0,0 +1,462 @@
|
|||
---
|
||||
title: Table
|
||||
tags:
|
||||
- ui
|
||||
---
|
||||
{% assign bodyClass = 'body_frame' -%}
|
||||
{% layout 'hippie/app.liquid' %}
|
||||
|
||||
{% block body %}
|
||||
{% render 'hippie/partials/frame-header.liquid' %}
|
||||
<main class="io">
|
||||
<section>
|
||||
<header class="io">
|
||||
<nav>
|
||||
<div class="group_nav">
|
||||
<button id="addEntry" title="Add entry">
|
||||
<i class="bi bi-plus-circle"></i>
|
||||
</button>
|
||||
<div class="wrap_input"><input id="setScroll" type="checkbox"></div>
|
||||
<label for="setScroll">Scroll to new entry</label>
|
||||
</div>
|
||||
</nav>
|
||||
<nav>
|
||||
<button id="tglIndex" title="Toggle index column">
|
||||
<i class="bi bi-hash"></i>
|
||||
</button>
|
||||
<div class="group_nav">
|
||||
<select id="sltNum" name="position-number" aria-label="numbering">
|
||||
<option value="" selected>None</option>
|
||||
<option value="numeric">123</option>
|
||||
<option value="latin">ABC</option>
|
||||
<option value="roman">IVX</option>
|
||||
</select>
|
||||
<button id="setPosNum" title="Set numbering" type="button"><i class="bi bi-list-ol"></i></button>
|
||||
</div>
|
||||
{% comment %}TODO: Auswahl für ziehbares Element hinzufügen{% endcomment %}
|
||||
</nav>
|
||||
</header>
|
||||
<table id="content" class="draggable content horizontal">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col" title="Index">#</th>
|
||||
<th scope="col"></th>
|
||||
<th scope="col" title="Position">#</th>
|
||||
<th scope="col">Number</th>
|
||||
<th scope="col">Name</th>
|
||||
<th class="max" scope="col">Description</th>
|
||||
<th scope="col">Amount</th>
|
||||
<th scope="col">Unit</th>
|
||||
<th scope="col">Price</th>
|
||||
<th scope="col">Sum</th>
|
||||
<th scope="col"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="positions"></tbody>
|
||||
</table>
|
||||
{% render 'hippie/partials/frame-status.liquid' %}
|
||||
</section>
|
||||
</main>
|
||||
<template id="rowDefault">
|
||||
<tr draggable="true">
|
||||
<th scope="row"></th>
|
||||
<td class="io">
|
||||
<nav>
|
||||
<input class="input_io" name="active" aria-label="active" type="checkbox">
|
||||
<span class="a_button" data-action="drag"><i class="bi bi-grip-horizontal" title="Drag"></i></span>
|
||||
</nav>
|
||||
</td>
|
||||
<td class="pos-num"></td>
|
||||
<td><input class="input_io" name="number" aria-label="number" type="text"></td>
|
||||
<td><input class="input_io" name="name" aria-label="name" type="text"></td>
|
||||
{% comment %}<td class="ellipsis"></td>{% endcomment %}
|
||||
<td>
|
||||
<textarea class="fit" name="description" cols="64" rows="2" aria-label="description"></textarea>
|
||||
</td>
|
||||
<td><input class="input_io" name="amount" aria-label="amount" type="number"></td>
|
||||
<td>
|
||||
<select class="io_select" name="unit" aria-label="unit">
|
||||
<option value="">None</option>
|
||||
<option value="piece">Piece(s)</option>
|
||||
<option value="hour">Hour(s)</option>
|
||||
</select>
|
||||
</td>
|
||||
<td><input class="input_io" name="price" aria-label="price" type="text"></td>
|
||||
<td class="unit"></td>
|
||||
<td class="io">
|
||||
<nav>
|
||||
<button title="Event"><i class="bi bi-calendar-event"></i></button>
|
||||
<button title="Note"><i class="bi bi-journal"></i></button>
|
||||
<button title="Delete"><i class="bi bi-trash"></i></button>
|
||||
</nav>
|
||||
</td>
|
||||
</tr>
|
||||
</template>
|
||||
<template id="rowArticle">
|
||||
<tr draggable="true">
|
||||
<th scope="row"></th>
|
||||
<td class="io">
|
||||
<nav>
|
||||
<input class="input_io" name="active" aria-label="active" type="checkbox">
|
||||
<span class="a_button" data-action="drag"><i class="bi bi-grip-horizontal" title="Drag"></i></span>
|
||||
</nav>
|
||||
</td>
|
||||
<td class="pos-num"></td>
|
||||
<td class="rigid"></td>
|
||||
<td></td>
|
||||
<td>
|
||||
<textarea class="fit" name="description" cols="64" rows="2" aria-label="description"></textarea>
|
||||
</td>
|
||||
<td><input name="amount" aria-label="number" type="number"></td>
|
||||
<td>
|
||||
<select name="unit" aria-label="unit">
|
||||
<option value="">None</option>
|
||||
<option value="piece">Piece(s)</option>
|
||||
<option value="hour">Hour(s)</option>
|
||||
</select>
|
||||
</td>
|
||||
<td class="unit"></td>
|
||||
<td class="unit"></td>
|
||||
<td class="io">
|
||||
<nav>
|
||||
<button title="Event"><i class="bi bi-calendar-event"></i></button>
|
||||
<button title="Note"><i class="bi bi-journal"></i></button>
|
||||
<button title="Delete"><i class="bi bi-trash"></i></button>
|
||||
</nav>
|
||||
</td>
|
||||
</tr>
|
||||
</template>
|
||||
<template id="rowText">
|
||||
<tr draggable="true">
|
||||
<th scope="row"></th>
|
||||
<td class="io">
|
||||
<nav>
|
||||
<input class="input_io" name="active" aria-label="active" type="checkbox">
|
||||
<span class="a_button" data-action="drag"><i class="bi bi-grip-horizontal" title="Drag"></i></span>
|
||||
</nav>
|
||||
</td>
|
||||
<td class="pos-num"></td>
|
||||
<td colspan="7">
|
||||
<textarea class="fit" name="description" cols="64" rows="2" aria-label="description"></textarea>
|
||||
</td>
|
||||
<td class="io">
|
||||
<nav>
|
||||
<button title="Delete"><i class="bi bi-trash"></i></button>
|
||||
</nav>
|
||||
</td>
|
||||
</tr>
|
||||
</template>
|
||||
<template id="rowGroup">
|
||||
<tr draggable="true" class="header">
|
||||
<th scope="row"></th>
|
||||
<td class="io">
|
||||
<nav>
|
||||
<input class="input_io" name="active" aria-label="active" type="checkbox">
|
||||
<span class="a_button" data-action="drag"><i class="bi bi-grip-horizontal" title="Drag"></i></span>
|
||||
<button name="group" title="Expand"><i class="bi bi-arrows-expand"></i></button>
|
||||
</nav>
|
||||
</td>
|
||||
<td class="pos-num"></td>
|
||||
<td colspan="7">Group</td>
|
||||
<td class="io">
|
||||
<nav>
|
||||
<button title="Delete"><i class="bi bi-trash"></i></button>
|
||||
</nav>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"></th>
|
||||
<td></td>
|
||||
<td class="pos-num"></td>
|
||||
<td colspan="7">Content</td>
|
||||
<td class="io">
|
||||
<nav>
|
||||
<button title="Event"><i class="bi bi-calendar-event"></i></button>
|
||||
<button title="Note"><i class="bi bi-journal"></i></button>
|
||||
<button title="Delete"><i class="bi bi-trash"></i></button>
|
||||
</nav>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="footer">
|
||||
<th scope="row"></th>
|
||||
<td></td>
|
||||
<td class="pos-num"></td>
|
||||
<td colspan="8">End</td>
|
||||
</tr>
|
||||
</template>
|
||||
|
||||
{% render 'hippie/partials/frame-mode.liquid' %}
|
||||
{% endblock %}
|
||||
|
||||
{%- block script %}
|
||||
{{ block.super -}}
|
||||
<script>
|
||||
const placeholderNames = [
|
||||
'Mac',
|
||||
'Sonic',
|
||||
'Furiosa',
|
||||
'Leia',
|
||||
'Frisbee',
|
||||
'Ripley',
|
||||
'Motoko',
|
||||
'Lupin',
|
||||
'Yoda',
|
||||
'Spike',
|
||||
'Obelix',
|
||||
'Samus',
|
||||
'Plisken'
|
||||
];
|
||||
const placeholderAttributes = [
|
||||
'blue',
|
||||
'tall',
|
||||
'clever',
|
||||
'true'
|
||||
];
|
||||
const placeholderContents = [
|
||||
'Description - At vero eos et accusam et justo duo dolores et ea rebum.',
|
||||
'',
|
||||
"Content with linebreaks - \nPhasellus finibus mollis diam non posuere. Vestibulum porttitor volutpat consectetur. Duis neque sapien, tincidunt ac odio vel, laoreet ultricies ligula. Suspendisse erat eros, volutpat vel fringilla at, placerat ac nisi. \nNulla arcu elit, facilisis egestas risus ac, aliquet varius sapien. Sed et nisi fringilla nibh ultrices sagittis ac in nisl. \nPellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nullam porta lectus ac pharetra feugiat. In ligula nunc, porttitor non arcu vel, feugiat tempor mi. Aenean pellentesque ipsum ac ligula pulvinar, vel auctor diam vehicula. Sed at arcu lacus.",
|
||||
'Very long content - Suspendisse lectus orci, convallis vitae sapien et, iaculis cursus magna. Pellentesque ultrices sodales eros eget vehicula. Aliquam tincidunt nulla non finibus ullamcorper. Ut accumsan nisi non aliquam fermentum. Vestibulum sit amet purus eu dolor vulputate pretium in eget libero. Donec vitae quam in leo eleifend semper. Cras mollis orci augue, vitae aliquam quam consequat quis. Donec sed nisi sed nulla ultricies ultricies quis ac erat. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Mauris euismod mollis neque sit amet varius. In malesuada nibh faucibus orci tincidunt, in elementum sapien pretium. Cras vel urna felis. Proin cursus tempor egestas. Nulla facilisis justo enim. Mauris fermentum, tortor a malesuada facilisis, leo tortor aliquam elit, sed sodales ipsum tortor et tellus.',
|
||||
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum facilisis condimentum quam, bibendum tristique odio.'
|
||||
];
|
||||
|
||||
const currencyEuro = new Intl.NumberFormat('de-DE', {style: 'currency', currency: 'EUR'});
|
||||
|
||||
const content = document.querySelector('main.io section > table');
|
||||
const tbodyPosition = document.getElementById('positions');
|
||||
|
||||
tbodyPosition.addEventListener('click', (event) => {
|
||||
const rows = tbodyPosition.querySelectorAll('tr');
|
||||
const rowTarget = event.target.closest('tr');
|
||||
const groupTarget = event.target.closest('[name="group"]');
|
||||
|
||||
if (event.button !== 0) return;
|
||||
|
||||
if (rowTarget) {
|
||||
for (const row of rows) {
|
||||
row.classList.remove('active');
|
||||
}
|
||||
|
||||
rowTarget.classList.add('active');
|
||||
}
|
||||
|
||||
if (groupTarget) {
|
||||
console.log('group');
|
||||
let currentRow = groupTarget.closest('tr').nextElementSibling;
|
||||
|
||||
while (currentRow && !currentRow.classList.contains('footer')) {
|
||||
currentRow.classList.toggle('di_none');
|
||||
currentRow = currentRow.nextElementSibling;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
for (let i = 0; i < 256; i++) {
|
||||
const t = Math.random();
|
||||
let type = undefined;
|
||||
|
||||
if (t < .2) {
|
||||
type = 'default';
|
||||
} else if (t >= .2 && t < .4) {
|
||||
type = 'text';
|
||||
} else if (t >= .4 && t < .5) {
|
||||
type = 'group';
|
||||
} else {
|
||||
type = 'article';
|
||||
}
|
||||
|
||||
tbodyPosition.appendChild(cloneRow(i, type));
|
||||
}
|
||||
|
||||
const selectNum = document.getElementById('sltNum');
|
||||
const buttonPosNum = document.getElementById('setPosNum');
|
||||
|
||||
buttonPosNum.addEventListener('click', () => {
|
||||
const numType = selectNum.value;
|
||||
const cells = tbodyPosition.querySelectorAll('td.pos-num');
|
||||
let num = '';
|
||||
|
||||
for (let i = 0; i < cells.length; i++) {
|
||||
switch (numType) {
|
||||
case 'numeric':
|
||||
num = (i + 1).toString();
|
||||
break;
|
||||
case 'roman':
|
||||
num = convertToRomanNumeral((i + 1)).toString();
|
||||
break;
|
||||
case '':
|
||||
default:
|
||||
}
|
||||
|
||||
cells[i].textContent = num;
|
||||
}
|
||||
});
|
||||
|
||||
const buttonIndex = document.getElementById('tglIndex');
|
||||
|
||||
buttonIndex.addEventListener('click', () => {
|
||||
const cells = content.querySelectorAll('th:first-child');
|
||||
const isHidden = cells[0].classList.contains('di_none');
|
||||
|
||||
for (const cell of cells) {
|
||||
if (isHidden) {
|
||||
cell.classList.remove('di_none');
|
||||
} else {
|
||||
cell.classList.add('di_none');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const buttonAdd = document.getElementById('addEntry');
|
||||
const checkScroll = document.getElementById('setScroll');
|
||||
|
||||
buttonAdd.addEventListener('click', () => {
|
||||
const clone = cloneRow();
|
||||
const viewportHeight = window.innerHeight;
|
||||
const elementActive = tbodyPosition.querySelector('tr.active');
|
||||
let elementNew;
|
||||
let elementBound = undefined;
|
||||
|
||||
if (elementActive) {
|
||||
elementActive.after(clone);
|
||||
elementNew = elementActive.nextElementSibling;
|
||||
} else {
|
||||
tbodyPosition.appendChild(clone);
|
||||
elementNew = tbodyPosition.lastElementChild;
|
||||
}
|
||||
|
||||
if (checkScroll.checked) {
|
||||
elementBound = elementNew.getBoundingClientRect();
|
||||
|
||||
if (elementBound.bottom > viewportHeight || elementBound.top < 0) {
|
||||
elementNew.scrollIntoView({behavior: 'smooth', block: 'nearest'});
|
||||
}
|
||||
}
|
||||
|
||||
reindexRows(tbodyPosition);
|
||||
});
|
||||
|
||||
let draggedRow = null;
|
||||
|
||||
tbodyPosition.addEventListener('dragstart', (event) => {
|
||||
const rowTarget = event.target.closest('tr[draggable="true"]');
|
||||
|
||||
if (rowTarget) {
|
||||
draggedRow = rowTarget;
|
||||
rowTarget.classList.add('dragging');
|
||||
event.dataTransfer.effectAllowed = 'move';
|
||||
|
||||
console.debug('Drag', rowTarget);
|
||||
}
|
||||
});
|
||||
|
||||
tbodyPosition.addEventListener('dragend', () => {
|
||||
if (draggedRow) {
|
||||
draggedRow.classList.remove('dragging');
|
||||
draggedRow = null;
|
||||
}
|
||||
});
|
||||
|
||||
tbodyPosition.addEventListener('dragover', (event) => {
|
||||
event.preventDefault();
|
||||
event.dataTransfer.dropEffect = 'move';
|
||||
|
||||
const rowTarget = event.target.closest('tr');
|
||||
|
||||
if (rowTarget && rowTarget !== draggedRow) {
|
||||
const rows = [...tbodyPosition.querySelectorAll('tr')];
|
||||
const draggedIndex = rows.indexOf(draggedRow);
|
||||
const targetIndex = rows.indexOf(rowTarget);
|
||||
|
||||
if (draggedIndex < targetIndex) {
|
||||
rowTarget.parentNode.insertBefore(draggedRow, rowTarget.nextSibling);
|
||||
} else {
|
||||
rowTarget.parentNode.insertBefore(draggedRow, rowTarget);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
tbodyPosition.addEventListener('drop', (event) => {
|
||||
event.preventDefault();
|
||||
reindexRows(event.currentTarget);
|
||||
|
||||
console.debug('Drop');
|
||||
});
|
||||
|
||||
function cloneRow(index, type = 'article') {
|
||||
const id = 'row' + capitalizeFirstLetter(type);
|
||||
|
||||
const rowFragment = document.getElementById(id).content;
|
||||
const tr = rowFragment.querySelector('tr');
|
||||
const th = rowFragment.querySelector('th');
|
||||
const td = rowFragment.querySelectorAll('td');
|
||||
|
||||
const j = index % placeholderNames.length;
|
||||
const k = randomIntFrom(0, placeholderContents.length - 1);
|
||||
const l = Math.random() > .2;
|
||||
const amount = randomIntFrom(1, 100);
|
||||
const price = randomFloatFrom(1, 10000, 2);
|
||||
const sum = amount * price;
|
||||
|
||||
tr.setAttribute('data-id', index);
|
||||
th.textContent = index + 1;
|
||||
td[0].querySelector('[name="active"]').checked = l;
|
||||
// td[2].innerHTML = replaceLineBreaks(placeholderContents[k]);
|
||||
|
||||
switch (type) {
|
||||
case 'default':
|
||||
td[2].firstElementChild.style.width = '9ch';
|
||||
td[3].firstElementChild.style.width = '6ch';
|
||||
td[4].firstElementChild.textContent = placeholderContents[k];
|
||||
td[5].firstElementChild.value = amount;
|
||||
td[5].firstElementChild.style.width = '4em';
|
||||
td[7].firstElementChild.style.width = '8ch';
|
||||
td[8].textContent = currencyEuro.format(sum);
|
||||
break;
|
||||
case 'article':
|
||||
td[2].textContent = getRandomFormattedString();
|
||||
td[3].textContent = placeholderNames[j];
|
||||
td[4].firstElementChild.textContent = placeholderContents[k];
|
||||
td[5].firstElementChild.value = amount;
|
||||
td[5].firstElementChild.style.width = '4em';
|
||||
td[7].textContent = currencyEuro.format(price);
|
||||
td[8].textContent = currencyEuro.format(sum);
|
||||
break;
|
||||
case 'text':
|
||||
td[2].firstElementChild.textContent = placeholderContents[k];
|
||||
break;
|
||||
default:
|
||||
console.debug('No matching type found.');
|
||||
}
|
||||
|
||||
return document.importNode(rowFragment, true);
|
||||
}
|
||||
|
||||
function reindexRows(parent, selector = 'tr') {
|
||||
const rows = parent.querySelectorAll(selector);
|
||||
let th = undefined;
|
||||
|
||||
for (let i = 0; i < rows.length; i++) {
|
||||
th = rows[i].querySelector('th');
|
||||
th.textContent = i + 1;
|
||||
}
|
||||
}
|
||||
|
||||
function toggleGroup(headerRow) {
|
||||
// Get the toggle icon
|
||||
const icon = headerRow.querySelector('.toggle-icon');
|
||||
|
||||
// Get all rows after this header
|
||||
let currentRow = headerRow.nextElementSibling;
|
||||
|
||||
// Toggle visibility of group rows until next header
|
||||
while (currentRow && !currentRow.classList.contains('group-header')) {
|
||||
currentRow.classList.toggle('hidden');
|
||||
currentRow = currentRow.nextElementSibling;
|
||||
}
|
||||
|
||||
// Toggle the icon rotation
|
||||
icon.classList.toggle('collapsed');
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
||||
13
source/view/demo/examples/ui/tui.liquid
Normal file
13
source/view/demo/examples/ui/tui.liquid
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
---
|
||||
title: TUI
|
||||
tags:
|
||||
- ui
|
||||
---
|
||||
{% assign bodyClass = 'body_frame' -%}
|
||||
{% layout 'hippie/app.liquid' %}
|
||||
|
||||
{% block body %}
|
||||
{% render 'hippie/partials/frame-header.liquid' %}
|
||||
<main class="io"></main>
|
||||
{% render 'hippie/partials/frame-mode.liquid' %}
|
||||
{% endblock %}
|
||||
82
source/view/demo/examples/ui/windows.liquid
Normal file
82
source/view/demo/examples/ui/windows.liquid
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
---
|
||||
title: Windows
|
||||
tags:
|
||||
- ui
|
||||
---
|
||||
{% assign bodyClass = 'body_frame' -%}
|
||||
{% layout 'hippie/app.liquid' %}
|
||||
|
||||
{% block body %}
|
||||
<div id="task-bar">
|
||||
<nav>
|
||||
<button data-action="start"><i class="bi bi-microsoft"></i></button>
|
||||
</nav>
|
||||
<nav>
|
||||
<button><i class="bi bi-search"></i></button>
|
||||
<button><i class="bi bi-layers-half"></i></button>
|
||||
</nav>
|
||||
<nav class="big">
|
||||
<button><i class="bi bi-folder"></i></button>
|
||||
<button><i class="bi bi-terminal"></i></button>
|
||||
<button id="setPause"><i class="bi bi-pause"></i></button>
|
||||
<button id="setPlay"><i class="bi bi-play"></i></button>
|
||||
</nav>
|
||||
<div>
|
||||
<nav class="small">
|
||||
<button><i class="bi bi-chevron-up"></i></button>
|
||||
<button><i class="bi bi-steam"></i></button>
|
||||
<button><i class="bi bi-router"></i></button>
|
||||
<button><i class="bi bi-mic"></i></button>
|
||||
<button><i class="bi bi-volume-down"></i></button>
|
||||
</nav>
|
||||
<div class="clock">
|
||||
<span id="time">##:##</span>
|
||||
<br>
|
||||
</div>
|
||||
<nav>
|
||||
<button data-action="notification"><i class="bi bi-bell-fill"></i></button>
|
||||
</nav>
|
||||
</div>
|
||||
</div>
|
||||
<div id="screen-space"></div>
|
||||
<div id="placeholder">
|
||||
<div class="box"></div>
|
||||
<div class="box_brd"></div>
|
||||
<div>
|
||||
<span>task bar</span>
|
||||
<div class="box_brd"></div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block assets %}
|
||||
{{ block.super -}}
|
||||
<script src="/js/windows.js"></script>
|
||||
{% endblock %}
|
||||
|
||||
{%- block script %}
|
||||
{{ block.super -}}
|
||||
<script>
|
||||
console.log(HIPPIE.brand);
|
||||
// Get the space element
|
||||
const space = document.getElementById('screen-space');
|
||||
const start = document.querySelector('[data-action=start]');
|
||||
const draggableElement = document.getElementById('task-bar');
|
||||
const placeholderElement = document.getElementById('placeholder');
|
||||
// TODO: TimeDisplay in HippieTaskbar aufnehmen
|
||||
const timeElement = document.getElementById('time');
|
||||
|
||||
const taskBar = new HippieTaskBar(draggableElement, placeholderElement);
|
||||
const timeFormat = {hour: '2-digit', minute: '2-digit'};
|
||||
const timeDisplay = new TimeDisplay(timeElement, timeFormat);
|
||||
|
||||
document.getElementById('setPause').addEventListener('click', () => {
|
||||
timeDisplay.pause();
|
||||
console.info('Pause time');
|
||||
});
|
||||
document.getElementById('setPlay').addEventListener('click', () => {
|
||||
timeDisplay.resume();
|
||||
console.info('Resume time');
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
Loading…
Add table
Add a link
Reference in a new issue