feat: add FEN block support and related assets

Introduced a new FEN block feature, including a PHP snippet to render FEN diagrams, a new CSS file for chessboard styling, font integration, and blueprint updates. Adjusted asset paths and file references for consistency.
This commit is contained in:
2025-06-29 16:08:31 +02:00
parent 6ff29c724e
commit b29a21780f
10 changed files with 154 additions and 5 deletions
+13 -1
View File
@@ -3,4 +3,16 @@ title: Block Page
fields:
blocks:
type: blocks
pretty: true
pretty: true
fieldsets:
- heading
- text
- image
- type: fen
label: FEN-Diagramm
preview: fields
wysiwyg: true
fields:
fen:
type: text
label: FEN-Position
+61
View File
@@ -0,0 +1,61 @@
<?php
// Beispiel-FEN (kann ersetzt werden)
$fen = $block->fen();
// Unicode-Mapping
$pieceUnicode = [
'K' => 'k', 'Q' => 'q', 'R' => 'r', 'B' => 'b', 'N' => 'n', 'P' => 'p',
'k' => 'l', 'q' => 'w', 'r' => 't', 'b' => 'v', 'n' => 'm', 'p' => 'o',
];
$board = fenToBoard($fen);
?>
<style>
.chessboard {
border: 3px solid #333;
border-radius: 2px;
display: inline-block;
}
.chessboard-row {
display: flex;
}
.chessboard-square {
width: 50px;
height: 50px;
display: flex;
align-items: center;
justify-content: center;
font-family: 'Case';
font-size: 3rem;
}
.chessboard-light {
background: #ededed;
}
.chessboard-dark {
background: #7e91c5;
}
</style>
<div class="flex justify-center py-8">
<div class="chessboard">
<?php for ($i = 0; $i < 8; $i++): ?>
<div class="chessboard-row">
<?php for ($j = 0; $j < 8; $j++):
$isLight = ($i + $j) % 2 == 1;
$piece = $board[$i][$j] ?? '';
$symbol = $pieceUnicode[$piece] ?? '';
?>
<div class="chessboard-square chessboard-<?= $isLight ? 'light' : 'dark' ?>">
<?php echo $symbol; ?>
</div>
<?php endfor; ?>
</div>
<?php endfor; ?>
</div>
</div>
+4 -2
View File
@@ -8,7 +8,7 @@
<?= css([
'assets/css/styles.css',
'assets/css/png4web.css',
'assets/css/chess.css'
]) ?>
<link rel="shortcut icon" type="image/x-icon"
@@ -40,6 +40,8 @@
<footer class="bg-sf_grau-400 w-full" id="footer">
<?php snippet('footer') ?>
</footer>
<?= js('assets/js/navbar.js') ?>
<?= js([
'assets/js/navbar.js'
]) ?>
</body>
</html>
+32
View File
@@ -0,0 +1,32 @@
<?php
// FEN in Array umwandeln
function fenToBoard($fen) {
$rows = explode('/', explode(' ', $fen)[0]);
$board = [];
foreach ($rows as $row) {
$boardRow = [];
$chars = str_split($row);
foreach ($chars as $char) {
if (is_numeric($char)) {
for ($i = 0; $i < intval($char); $i++) {
$boardRow[] = '';
}
} else {
$boardRow[] = $char;
}
}
$board[] = $boardRow;
}
return $board;
} ?>
<?php
snippet('layout', slots: true) ?>
<?= $page->blocks()->toBlocks() ?>
<?php
endsnippet() ?>