Tansy UI: a themeable React component kit

Tansy UI is a React component kit by OpenKhalix, named after the tansy
flower ("golden buttons"). It has two surfaces:

- A landing page built entirely from the kit's own components, with
  five featured parts, a palette-switching playground form, and links
  into Storybook
- A Storybook workshop with Tansy branding, a Welcome page, palette
  toolbar and accessibility checks

Includes 15 components with colocated tokens and stories, seven brand
palettes, a palette-aware logo, a Docker/nginx image, a scripted
cPanel deploy, and a generator that keeps the landing page catalogue
in sync with Storybook.
This commit is contained in:
thekhalidsha committed 2026-09-28 17:09:57 +05:30
commit 9d406d6d2a
81 files changed
+14240

No files matched your search

+215
View File
@@ -0,0 +1,215 @@
<?php
/**
* cPanel static deployer: extract a base64 ZIP, then prune anything the
* upload did not bring with it.
*
* Post fields:
* data - base64 of a ZIP whose entries are relative paths
* keep - optional JSON array of extra top-level names to preserve
*
* The archive is authoritative for everything except the names in
* $keepNames. After extraction anything else is stale output from a
* previous build and is removed, so the docroot always matches exactly
* one build and old content-hashed assets do not accumulate.
*
* Self-deletes as its first action so it cannot be replayed.
*/
$self = __FILE__;
@unlink($self);
header('Content-Type: text/plain');
// Named PRESERVE, not PROTECTED - `protected` is a reserved PHP keyword
// and a const with that name is a parse error.
const PRESERVE = ['.', '..', '.htaccess', '.user.ini', 'php.ini', 'cgi-bin', '.well-known'];
function fail(string $msg): never {
echo "ERROR: {$msg}\n";
exit(1);
}
if (!isset($_POST['data'])) {
fail('no data payload');
}
$raw = base64_decode($_POST['data'], true);
if ($raw === false || $raw === '') {
fail('base64 decode failed');
}
$extraKeep = [];
if (isset($_POST['keep'])) {
$decoded = json_decode($_POST['keep'], true);
if (is_array($decoded)) {
$extraKeep = $decoded;
}
}
$keepNames = array_merge(PRESERVE, $extraKeep);
$tmp = tempnam(sys_get_temp_dir(), 'dep');
if ($tmp === false) {
fail('tempnam failed');
}
file_put_contents($tmp, $raw);
$zip = new ZipArchive();
if ($zip->open($tmp) !== TRUE) {
@unlink($tmp);
fail('zip open failed');
}
$root = __DIR__;
$writtenFiles = []; // every relative file path the archive produced
$writtenDirs = ['']; // every relative directory the archive produced
$extracted = 0;
for ($i = 0; $i < $zip->numFiles; $i++) {
$name = $zip->getNameIndex($i);
if ($name === false || $name === '' || str_ends_with($name, '/')) {
continue;
}
// Reject traversal and absolute paths outright.
if (str_contains($name, '..') || $name[0] === '/' || $name[0] === '\\') {
fail("refusing suspicious archive path: {$name}");
}
// Record every parent directory as part of the new build.
$parts = explode('/', $name);
array_pop($parts);
$acc = '';
foreach ($parts as $part) {
$acc = $acc === '' ? $part : $acc . '/' . $part;
$writtenDirs[$acc] = true;
}
$dest = $root . '/' . $name;
$writtenFiles[$name] = true;
$dir = dirname($dest);
if (!is_dir($dir) && !@mkdir($dir, 0755, true) && !is_dir($dir)) {
fail("mkdir failed: {$dir}");
}
$stream = $zip->getStream($name);
if ($stream === false) {
fail("getStream failed: {$name}");
}
$out = fopen($dest, 'wb');
if ($out === false) {
fclose($stream);
fail("fopen failed: {$dest}");
}
stream_copy_to_stream($stream, $out);
fclose($out);
fclose($stream);
$extracted++;
}
$zip->close();
@unlink($tmp);
if ($extracted === 0) {
fail('archive contained no files');
}
// --- prune stale output -------------------------------------------------
$removed = 0;
$prunedDirs = 0;
function rmTree(string $dir): void {
global $removed, $prunedDirs;
$items = @scandir($dir);
if ($items === false) {
return;
}
foreach ($items as $item) {
if ($item === '.' || $item === '..') {
continue;
}
$path = $dir . '/' . $item;
if (is_dir($path)) {
rmTree($path);
if (@rmdir($path)) {
$prunedDirs++;
}
} elseif (@unlink($path)) {
$removed++;
}
}
}
/**
* Delete everything inside $absDir that the new build did not write, then
* remove the directory itself if this build did not produce it.
*/
function pruneDir(string $absDir, string $relDir): void {
global $removed, $prunedDirs, $writtenFiles, $writtenDirs;
$items = @scandir($absDir);
if ($items === false) {
return;
}
foreach ($items as $item) {
if ($item === '.' || $item === '..') {
continue;
}
$rel = $relDir === '' ? $item : $relDir . '/' . $item;
$path = $absDir . '/' . $item;
if (is_dir($path)) {
pruneDir($path, $rel);
// Only remove the directory if this build did not put anything
// inside it - that is what makes assets/ and docs/ survive.
if (!isset($writtenDirs[$rel]) && @rmdir($path)) {
$prunedDirs++;
}
continue;
}
if (!isset($writtenFiles[$rel]) && @unlink($path)) {
$removed++;
}
}
}
$top = @scandir($root);
if ($top === false) {
fail('scandir failed on docroot');
}
foreach ($top as $entry) {
if (in_array($entry, $keepNames, true)) {
continue;
}
$path = $root . '/' . $entry;
if (is_dir($path)) {
pruneDir($path, $entry);
if (!isset($writtenDirs[$entry]) && @rmdir($path)) {
$prunedDirs++;
}
continue;
}
if (!isset($writtenFiles[$entry]) && @unlink($path)) {
$removed++;
}
}
$bytes = 0;
foreach (array_keys($writtenFiles) as $name) {
$bytes += @filesize($root . '/' . $name) ?: 0;
}
// Post-deploy sanity check: the docroot must still contain what was written.
if (!file_exists($root . '/index.html')) {
fail('post-deploy check failed: index.html is missing');
}
echo json_encode([
'ok' => true,
'extracted' => $extracted,
'pruned_files' => $removed,
'pruned_dirs' => $prunedDirs,
'bytes' => $bytes,
'docroot' => $root,
], JSON_PRETTY_PRINT) . "\n";