Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,4 @@ pnpm-lock.yaml
.cofoundy/state/history.jsonl
.cofoundy/state/**/worker-id*
.cofoundy/state/**/*.lock
node_modules
2 changes: 2 additions & 0 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ const config: StorybookConfig = {
'@storybook/addon-essentials',
'@storybook/addon-interactions',
],
// Lockups de Cofoundy Identity → https://ui.cofoundy.dev/brand/identity/<slug>.svg (Casdoor los usa como logo).
staticDirs: [{ from: '../src/assets/brand/identity', to: '/brand/identity' }],
framework: {
name: '@storybook/react-vite',
options: {},
Expand Down
4 changes: 4 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ npm test # Run tests
npm run test:watch # Watch mode
npm run test:coverage # Coverage report

# Lockup de cada app de Cofoundy Identity (id.cofoundy.dev): una línea en
# src/assets/brand/identity/apps.json → SVG en ui.cofoundy.dev/brand/identity/<slug>.svg
npm run gen:lockups # verify:lockups en CI

# Build IIFE (standalone widget)
npm run build:iife

Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,16 @@
"test:watch": "vitest",
"test:coverage": "vitest run --coverage",
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build",
"build-storybook": "npm run verify:lockups && storybook build",
"build:iife": "vite build --config vite.config.iife.ts",
"build:iife:watch": "vite build --config vite.config.iife.ts --watch",
"build:ds": "vite build -c vite.config.ds.ts && vite build -c vite.config.ds.ts --mode react && vite build -c vite.config.ds.ts --mode react-dom",
"capture-shader-poster": "node scripts/capture-shader-poster.mjs",
"gen:agents": "tsx scripts/gen-atelier-agents-md.ts",
"verify:agents": "tsx scripts/gen-atelier-agents-md.ts --check",
"gen:springs": "tsx scripts/gen-spring-tokens.ts",
"verify:springs": "tsx scripts/gen-spring-tokens.ts --check"
"verify:springs": "tsx scripts/gen-spring-tokens.ts --check",
"gen:lockups": "tsx scripts/gen-identity-lockups.ts",
"verify:lockups": "tsx scripts/gen-identity-lockups.ts --check"
}
}
93 changes: 93 additions & 0 deletions scripts/fonts/OFL-space-grotesk.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
Copyright 2020 The Space Grotesk Project Authors (https://github.com/floriankarsten/space-grotesk)

This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL


-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------

PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.

The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.

DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.

"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).

"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).

"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.

"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.

PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:

1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.

2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.

3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.

4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.

5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.

TERMINATION
This license becomes null and void if any of the above conditions are
not met.

DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
Binary file added scripts/fonts/space-grotesk-latin-600-normal.woff
Binary file not shown.
149 changes: 149 additions & 0 deletions scripts/gen-identity-lockups.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
/**
* Lockup de cada aplicación de Cofoundy Identity (id.cofoundy.dev): isologo + «Cofoundy Identity»
* + el nombre de la app. Una sola plantilla; el nombre es la variable (src/assets/brand/identity/apps.json).
* Escribe un SVG por app, solo con trazos (sin fuentes), en src/assets/brand/identity/<slug>.svg.
* El deploy los publica en https://ui.cofoundy.dev/brand/identity/<slug>.svg y Casdoor los usa como `logo`.
*
* npm run gen:lockups # regenera
* npm run verify:lockups # CI: falla si un SVG no coincide con la lista o un nombre no cabe
*
* Cambiar el diseño = editar LAYOUT/INK aquí y regenerar: todas las apps cambian a la vez, sin tocar Casdoor.
*/
import { readFileSync, readdirSync, writeFileSync, unlinkSync } from "node:fs";
import { resolve } from "node:path";
import opentype, { type Font } from "opentype.js";

const ROOT = resolve(import.meta.dirname, "..");
const OUT = resolve(ROOT, "src/assets/brand/identity");
const LIST = resolve(OUT, "apps.json");
const ISOLOGO = resolve(ROOT, "src/assets/brand/Isologo.svg");
const TOKENS = resolve(ROOT, "src/styles/index.css");

/** Medidas en unidades del viewBox (alto total 240, como el lockup PNG anterior). */
export const LAYOUT = {
height: 240,
isologo: 240, // lado del isologo (es cuadrado)
gap: 40, // isologo → texto
line1: { size: 64, baseline: 74 }, // «Cofoundy Identity», la marca común
line2: { size: 96, baseline: 198 }, // nombre de la app: lo que distingue una tarjeta de otra
oneLine: { size: 88, baseline: 152 }, // sin nombre: «Cofoundy Identity» solo, centrado en el isologo
tracking: -0.02, // em, igual que el Wordmark (logo-header.tsx)
padRight: 8,
maxRatio: 6, // ancho/alto: más ancho se vuelve ilegible a 250 px (login) y se corta en la tarjeta de /apps
};

/** Tintas: el azul de «Identity» es el token --cf-primary; las otras salen de las caras del isologo. */
function ink() {
const iso = readFileSync(ISOLOGO, "utf8");
const css = readFileSync(TOKENS, "utf8");
const primary = css.match(/--cf-primary:\s*(#[0-9A-Fa-f]{6})/)?.[1];
const need = (hex: string) => {
if (!iso.includes(`fill="${hex}"`)) throw new Error(`${hex} ya no es una cara de Isologo.svg: actualiza INK`);
return hex;
};
if (!primary) throw new Error("no encontré --cf-primary en src/styles/index.css");
return { cofoundy: need("#103D5C"), identity: primary, app: need("#103D5C") };
}

const font600 = opentype.parse(toArrayBuffer(readFileSync(resolve(ROOT, "scripts/fonts/space-grotesk-latin-600-normal.woff"))));

function toArrayBuffer(b: Buffer): ArrayBuffer {
return b.buffer.slice(b.byteOffset, b.byteOffset + b.byteLength) as ArrayBuffer;
}

function text(font: Font, s: string, x: number, y: number, size: number, fill: string, cls = "") {
const opts = { letterSpacing: LAYOUT.tracking };
const d = font.getPath(s, x, y, size, opts).toPathData(2);
const width = font.getAdvanceWidth(s, size, opts);
const klass = cls ? ` class="${cls}"` : "";
return { svg: `<path${klass} fill="${fill}" d="${d}"/>`, width };
}

/** El login de Casdoor pone fondo oscuro con prefers-color-scheme: dark; la tinta navy se aclara ahí. */
const DARK = `<style>@media (prefers-color-scheme: dark){.ink{fill:#F5F7FA}}</style>`;

function esc(s: string): string {
return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
}

function isologoInner(): string {
const iso = readFileSync(ISOLOGO, "utf8");
const inner = iso.replace(/^[\s\S]*?<svg[^>]*>/, "").replace(/<\/svg>\s*$/, "").trim();
const scale = LAYOUT.isologo / 701;
return `<g transform="scale(${scale.toFixed(6)})">${inner}</g>`;
}

export function renderLockup(name: string): string {
const c = ink();
const x = LAYOUT.isologo + LAYOUT.gap;
const l1 = name ? LAYOUT.line1 : LAYOUT.oneLine;
const a = text(font600, "Cofoundy", x, l1.baseline, l1.size, c.cofoundy, "ink");
const space = font600.getAdvanceWidth(" ", l1.size);
const b = text(font600, "Identity", x + a.width + space, l1.baseline, l1.size, c.identity);
const parts = [a.svg, b.svg];
let textWidth = a.width + space + b.width;
if (name) {
const n = text(font600, name, x, LAYOUT.line2.baseline, LAYOUT.line2.size, c.app, "ink");
parts.push(n.svg);
textWidth = Math.max(textWidth, n.width);
}
const width = Math.ceil(x + textWidth + LAYOUT.padRight);
const label = esc(name ? `Cofoundy Identity · ${name}` : "Cofoundy Identity");
return [
`<!-- generado por scripts/gen-identity-lockups.ts desde apps.json: no editar a mano -->`,
`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${width} ${LAYOUT.height}" width="${width}" height="${LAYOUT.height}" role="img" aria-label="${label}">`,
`<title>${label}</title>`,
DARK,
isologoInner(),
...parts,
`</svg>`,
"",
].join("\n");
}

export function readApps(): Record<string, string> {
const apps = JSON.parse(readFileSync(LIST, "utf8")).apps as Record<string, string>;
for (const slug of Object.keys(apps)) {
if (!/^[a-z0-9-]+$/.test(slug)) throw new Error(`slug inválido: «${slug}» (solo a-z, 0-9 y guiones: va en la URL)`);
}
return apps;
}

function main() {
const check = process.argv.includes("--check");
const apps = readApps();
const problems: string[] = [];
const expected = new Set<string>();
for (const [slug, name] of Object.entries(apps)) {
const svg = renderLockup(name);
const w = Number(svg.match(/viewBox="0 0 (\d+) /)?.[1]);
if (w / LAYOUT.height > LAYOUT.maxRatio) {
problems.push(`«${name}» no cabe (${(w / LAYOUT.height).toFixed(1)}:1 > ${LAYOUT.maxRatio}:1): acórtalo`);
continue;
}
const file = resolve(OUT, `${slug}.svg`);
expected.add(`${slug}.svg`);
if (check) {
let current = "";
try {
current = readFileSync(file, "utf8");
} catch {
/* falta */
}
if (current !== svg) problems.push(`${slug}.svg no coincide con apps.json: corre npm run gen:lockups`);
} else {
writeFileSync(file, svg);
}
}
for (const f of readdirSync(OUT).filter((f) => f.endsWith(".svg") && !expected.has(f))) {
if (check) problems.push(`${f} sobra (no está en apps.json)`);
else unlinkSync(resolve(OUT, f));
}
if (problems.length) {
console.error(problems.join("\n"));
process.exit(1);
}
console.log(`${check ? "ok" : "escritos"}: ${expected.size} lockups en src/assets/brand/identity/`);
}

if (import.meta.url === `file://${process.argv[1]}`) main();
80 changes: 0 additions & 80 deletions scripts/text-to-svg.cjs

This file was deleted.

Loading
Loading