MCPcopy Index your code
hub / github.com/bitjson/qr-code

github.com/bitjson/qr-code @v1.0.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.0.0 ↗ · + Follow
50 symbols 77 edges 6 files 2 documented · 4%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

bitjson/qr-code

A framework-less <qr-code> element (a Web Component).

Usage

Import the qr-code component properly using your build system or framework, or use the standalone script in your HTML <head> element:

<script src="https://github.com/bitjson/qr-code/raw/v1.0.0/path/to/qr-code.js"></script>

Then use the component anywhere in your HTML <body> element:

<qr-code contents="https://bitjson.com"></qr-code>

Examples

Here's an example taking advantage of all configuration options:

<qr-code
  id="qr1"
  contents="https://bitjson.com"
  module-color="#1c7d43"
  position-ring-color="#13532d"
  position-center-color="#70c559"
  mask-x-to-y-ratio="1.2"
  style="width: 200px; height: 200px; background-color: #fff"
>
  <img src="https://github.com/bitjson/qr-code/raw/v1.0.0/assets/icon.svg" slot="icon" />
</qr-code>
<script>
  setTimeout(() => {
    document.getElementById('qr1').animateQRCode('MaterializeIn');
  }, 1000);
</script>

For more examples, review src/index.html.

Animations

Several preset animations are available, simply run them with the element's animateQRCode method:

document.getElementById('qr1').animateQRCode('RadialRipple');

The current, built-in presets are:

  • FadeInTopDown
  • FadeInCenterOut
  • MaterializeIn
  • RadialRipple
  • RadialRippleIn

Custom animations can be defined with a single, pure function; rather than an animation preset name, simply pass in the function:

// A layered, "explosion" fade-in
document
  .getElementById('qr1')
  .animateQRCode((targets, _x, _y, _count, entity) => ({
    targets,
    from: entity === 'module' ? Math.random() * 200 : 200,
    duration: 500,
    easing: 'cubic-bezier(1,1,0,.5)',
    web: {
      opacity: [0, 1],
      scale: [0.3, 1.13, 0.93, 1],
    },
  }));

The built-in presets are also defined using this API. Review src/components/qr-code/animations.ts to see how they work. Pull request for new presets are welcome!

The animation previewer makes fine-tuning animations much easier: try it by cloning this repo and running the start package script:

git clone https://github.com/bitjson/qr-code.git
cd qr-code
npm ci
npm start

Production build

Disable the just-animate player in src/components/qr-code/qr-code.tsx, then build:

npm run build

You can test the built component by pointing the script in src/index.html to dist/qr-code.js and then opening src/index.html via the local filesystem.

Run the tests

npm test

Extension points exported contracts — how you extend this code

Element (Interface)
(no doc)
src/components.d.ts
IntrinsicElements (Interface)
(no doc)
src/components.d.ts
HTMLElement (Interface)
(no doc)
src/components.d.ts
HTMLStencilElement (Interface)
(no doc)
src/components.d.ts
HTMLAttributes (Interface)
(no doc)
src/components.d.ts

Core symbols most depended-on inside this repo

distanceBetween
called by 3
src/components/qr-code/animation-utils.ts
innermostPoint
called by 3
src/components/qr-code/animation-utils.ts
yMax
called by 3
src/components/qr-code/animation-utils.ts
translatePoint
called by 2
src/components/qr-code/animation-utils.ts
focalPoint
called by 2
src/components/qr-code/animation-utils.ts
y
called by 2
src/components/qr-code/animation-utils.ts
applyToValues
called by 2
src/components/qr-code/animation-utils.ts
getAnimationPreset
called by 1
src/components/qr-code/animations.ts

Shape

Function 17
Method 16
Interface 11
Enum 4
Class 2

Languages

TypeScript100%

Modules by API surface

src/components/qr-code/qr-code.tsx16 symbols
src/components/qr-code/animation-utils.ts13 symbols
src/components.d.ts13 symbols
src/components/qr-code/animations.ts8 symbols

For agents

$ claude mcp add qr-code \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact