@ -11,13 +11,27 @@
type Tab = 'live' | 'examples' | 'api' | 'morfo' | 'recipe' | 'a11y';
type Tab = 'live' | 'examples' | 'api' | 'morfo' | 'recipe' | 'a11y';
let tab = $state< Tab > ('live');
let tab = $state< Tab > ('live');
let value = $state('https://uix.dev/qr-code');
// The encoder takes ANY UTF-8 string — not just URLs. The reader decides how
// to interpret it (vCard contact, WiFi join, geo, plain text, …); the QR is
// content-agnostic. Multi-line + accents/CJK go through byte (UTF-8) mode.
const presets: { label : string ; value : string } [] = [
{ label : 'URL' , value : 'https://uix.dev/qr-code' } ,
{
label: 'vCard',
value:
'BEGIN:VCARD\nVERSION:3.0\nFN:Juan Vicente\nORG:UIX\nTITLE:Maker\nTEL;TYPE=CELL:+34600123456\nEMAIL:hola@uix.dev\nURL:https://uix.dev\nEND:VCARD'
},
{ label : 'WiFi' , value : 'WIFI:T:WPA;S:UIX-Guest;P:s3cret-pass;;' } ,
{ label : 'Text · unicode' , value : 'Diseñando lo que ocurre — açaí · ñoño · 日本語 · 🎯' }
];
let value = $state(presets[0].value);
let size = $state< QrCodeSize > ('lg');
let size = $state< QrCodeSize > ('lg');
let cellShape = $state< QrCodeCellShape > ('square');
let cellShape = $state< QrCodeCellShape > ('square');
let errorCorrection = $state< ErrorCorrection > ('M');
let errorCorrection = $state< ErrorCorrection > ('M');
let margin = $state(4);
let margin = $state(4);
let color = $state< string | undefined > (undefined);
let color = $state< string | undefined > (undefined);
let withLogo = $state(false);
let withLogo = $state(tru e);
const sizes: QrCodeSize[] = ['xs', 'sm', 'md', 'lg', 'xl'];
const sizes: QrCodeSize[] = ['xs', 'sm', 'md', 'lg', 'xl'];
const shapes: QrCodeCellShape[] = ['square', 'rounded', 'dots'];
const shapes: QrCodeCellShape[] = ['square', 'rounded', 'dots'];
@ -60,8 +74,16 @@
< / svelte:head >
< / svelte:head >
{ # snippet brandLogo ()}
{ # snippet brandLogo ()}
< svg viewBox = "0 0 24 24" fill = { color ?? '#18181b' } aria-hidden="true" >
<!-- Test logo: a brand monogram. Its own colour (not the QR fg) so it reads as a logo. -->
< path d = "M12 2L2 7l10 5 10-5-10-5zM2 17l10 5 10-5M2 12l10 5 10-5" / >
< svg viewBox = "0 0 32 32" aria-hidden = "true" >
< rect width = "32" height = "32" rx = "8" fill = "#7c3aed" / >
< path
d="M10 9v8a6 6 0 0 0 12 0V9"
fill="none"
stroke="#fff"
stroke-width="3.5"
stroke-linecap="round"
/>
< / svg >
< / svg >
{ /snippet }
{ /snippet }
@ -117,8 +139,16 @@
< p data-uix-section-desc > Pure < span data-uix-layer-badge = "eidos" > eidos< / span > display — no soma. < code > value< / code > → matrix → SVG.< / p >
< p data-uix-section-desc > Pure < span data-uix-layer-badge = "eidos" > eidos< / span > display — no soma. < code > value< / code > → matrix → SVG.< / p >
< div data-uix-controls >
< div data-uix-controls >
< label data-uix-control >
< label data-uix-control >
< span data-uix-control-label > value< / span >
< span data-uix-control-label > content preset< / span >
< input type = "text" bind:value / >
< span data-uix-chips role = "radiogroup" >
{ #each presets as p }
< button data-uix-chip data-active = { value === p . value } onclick= {() => ( value = p . value )} > { p . label } </ button >
{ /each }
< / span >
< / label >
< label data-uix-control style = "flex-basis: 100%;" >
< span data-uix-control-label > value (any UTF-8 string)< / span >
< textarea bind:value rows = "3" style = "resize: vertical; font-family: inherit;" > < / textarea >
< / label >
< / label >
< label data-uix-control >
< label data-uix-control >
< span data-uix-control-label > cellShape< / span >
< span data-uix-control-label > cellShape< / span >
@ -153,9 +183,9 @@
< / span >
< / span >
< / label >
< / label >
< label data-uix-control >
< label data-uix-control >
< span data-uix-control-label > margin ( quiet zone)< / span >
< span data-uix-control-label > quiet zone · modules (spec min 4 )< / span >
< span data-uix-chips role = "radiogroup" >
< span data-uix-chips role = "radiogroup" >
{ #each [ 2, 4 , 6] as m }
{ #each [ 4, 8 , 1 6] as m }
< button data-uix-chip data-active = { margin === m } onclick= {() => ( margin = m )} > { m } </ button >
< button data-uix-chip data-active = { margin === m } onclick= {() => ( margin = m )} > { m } </ button >
{ /each }
{ /each }
< / span >
< / span >
@ -244,7 +274,7 @@
< tr > < td class = "name" > --qr-code-fg / --qr-code-bg< / td > < td > module colour / quiet-zone (fixed-tone)< / td > < / tr >
< tr > < td class = "name" > --qr-code-fg / --qr-code-bg< / td > < td > module colour / quiet-zone (fixed-tone)< / td > < / tr >
< tr >< td class = "name" > --qr-code-size-{ '{' } xs…xl{ '}' } </ td >< td > size presets</ td ></ tr >
< tr >< td class = "name" > --qr-code-size-{ '{' } xs…xl{ '}' } </ td >< td > size presets</ td ></ tr >
< tr > < td class = "name" > --qr-code-radius< / td > < td > frame radius< / td > < / tr >
< tr > < td class = "name" > --qr-code-radius< / td > < td > frame radius< / td > < / tr >
< tr > < td class = "name" > --qr-code-overlay-bg / -padding / - radius< / td > < td > logo backing< / td > < / tr >
< tr > < td class = "name" > --qr-code-overlay-bg / -radius< / td > < td > logo backing (padding is proportional, inline) < / td > < / tr >
< / tbody >
< / tbody >
< / table >
< / table >
< / div >
< / div >