Repository navigation
feat: add QR code customisation (colours, shapes, corner squares, logo) - #24
Merged
Merged
Conversation
- generateQRSymbol returns the matrix with the version, level, mode and quiet zone used; generateQRCode delegates to it - renderToStyledSVG draws custom colours, linear/radial gradients, square/rounded/dots/diamond modules, styled corner squares, rounded background corners and a logo; alignment patterns are always solid squares so scanners can find the grid - analyzeStyle reports contrast, inverted colours, transparent background and small module problems, and the logo coverage; a logo needs level Q or H and is capped by hidden area (12% at Q, 15% at H) - Colours and logo URLs are strictly validated (StyleError), nothing user-supplied reaches the SVG unchecked - renderToPng accepts foreground/background colours (palette PNG, with transparency); renderSvgToPng turns a styled SVG into a PNG in browsers - Tests cover shapes, gradients, validation, hostile input, the logo limits and the PNG chunks
- Demo: Style / Logo / Options tabs with presets, colour swatches, gradient, shape pickers, corner colours and a logo upload; live scan-safety warnings; compact preview pinned above the settings on phones and sticky beside them on desktop; download size next to the download buttons - Fix the page shell clipping so position: sticky works - Presets keep the logo settings, and logo changes keep the preset - README: document generateQRSymbol, renderToStyledSVG, analyzeStyle, logos, PNG options and scan-safety guidance; desktop and phone screenshots
- App icon in the demo's own blue (#0e7bf7 to #0d63c4): favicon.svg, favicon.ico (16, 32, 48 px), a 96 px PNG (Google wants multiples of 48), apple-touch-icon, 192 and 512 px icons and a web manifest - New og.png about the customisable QR code: three real styles, all encoding https://qr.deityhub.com/, with the app icon as the logo in the main code - Cache headers for the new files and the manifest content type
- Title and description now mention the customisation, plus robots meta (large previews and snippets), og:locale and image alt text - Link the new favicon set and manifest instead of an inline data URI - JSON-LD: WebSite, Person (the same @id as judeojini.com so both sites describe one entity), WebApplication with a feature list, the library as SoftwareSourceCode, HowTo and an 8 question FAQPage - Visible intro, features, how-to steps and FAQ that match the structured data exactly - llms.txt for AI tools and a dated sitemap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds customisation to the package and the demo site: colours, gradients, module shapes, styled corner squares and a logo in the middle, with built-in scan-safety checks. Everything stays dependency-free, and
generateQRCode/renderToSVG/renderToPngare unchanged for existing callers.Library
generateQRSymbol(config)returns{ matrix, version, ecl, mode, quietZone, modules }(generateQRCodeis nowgenerateQRSymbol(config).matrix)renderToStyledSVG(symbol, style): solid colours, linear/radial gradients, transparent background, rounded background corners, module shapes (square, rounded, dots, diamond) with a size setting, corner frame/dot shapes and colours, optional logo (square or circle, size, margin, backing colour)analyzeStyle(symbol, style)returns{ warnings, errors, logoCoverage, contrastRatio }(low contrast, inverted colours, transparent background, small modules)strict: falseturns the errors into warnings. A logo can never cover a corner square, format or version informationrenderToPng(matrix, size, { foreground, background })writes a 2-colour palette PNG (with transparency);renderSvgToPng(svg, size)makes a PNG from a styled SVG in browsers (in Node, convert the SVG with sharp or resvg, documented in the README)rgb(),hsl(), basic names) and logo hrefs (base64data:imageorhttps://) are strictly validated and throwStyleError; nothing user-supplied is copied into the SVG unchecked. Tests include hostile stringsDemo site
overflow: hiddenon the shell silently brokeposition: sticky(nowoverflow: clip); presets no longer reset the logo settings and logo changes no longer deselect the presetVerification
npm run lint,npm run buildandnpm run test:packagepassNotes
feat:) will make release-please propose a minor releaseBrand, social image and SEO (added later)
#0e7bf7to#0d63c4) and a full favicon set:favicon.svg,favicon.ico(16/32/48 px), a 96 px PNG,apple-touch-icon.png, 192/512 px icons andsite.webmanifest; the old inlinedata:favicon is gone (Google cannot use it in search results)og.pngabout the customisable QR code: three real styles, all encodinghttps://qr.deityhub.com/, with the app icon as the logo in the main code (each code was scanned with jsQR and zxing)robotsmeta allows large previews and snippets;og:localeand image alt text addedWebSite,Person(same@idas judeojini.com, so both sites describe one entity),WebApplicationwith a feature list, the library asSoftwareSourceCode,HowToand an 8-questionFAQPage. The structured data text is generated from the same source as the visible intro, features, steps and FAQ and was checked to match word for wordllms.txtfor AI tools, datedsitemap.xml, cache headers for the new filesAfter deploying: submit
https://qr.deityhub.com/sitemap.xmlin Google Search Console and refresh the social image caches (Facebook Sharing Debugger, LinkedIn Post Inspector).