npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@montagejs/qr-poster

v1.2.4

Published

Poster qr code generation component

Downloads

2

Readme

QR code poster component

npm GitHub GitHub last commit XO code style

English | 简体中文

Based on React, a poster QR code component with Headless Component feature.

Install

# npm
$ npm i @montagejs/qr-poster --S
# pnpm
$ pnpm add @montagejs/qr-poster --S

API

| params | type | desc | version | |--------|------------------------------------------------------------------------------------------|------------------------------|---------| | children | (props: {generatePoster: () => Promise<string>}) => ReactNode | JSX.Element; | render props function | 1.0.0 | | render | () => ReactNode | JSX.Element; | will generate qrPoster‘s dom | 1.0.0 | | h2cOptions | Options | will generate qrPoster‘s dom | 1.1.1 |

Background

In common event promotion, it is often necessary to share promotional posters or set up sales signs at the front desk. We hope to further improve the efficiency of business development.

The traditional 'UI' components are difficult to meet the flexible and complex layout of QR code posters, requiring a solution that can adapt to changes.

Target

  • Encapsulate core poster generation and storage capabilities;
  • Excellent compatibility, meeting the needs of low-end devices with webview kernel;
  • Headless feature;

Component design

Online map:Git Mind

Usage

import type {FC} from 'react';
import {useEffect, useState} from 'react';
import {QRCodeCanvas} from 'qrcode.react';
import {QrPoster} from '@montagejs/qr-poster';
import './QRCode.demo.less';

function getQRCodePositionByKnownPosition(knownPosition, posterWidth, posterHeight) {
	const qrCodeWidth = 248;
	const qrCodeHeight = 242;
	const qrCodeX = (knownPosition.x / 704) * posterWidth;
	const qrCodeY = posterHeight - qrCodeHeight - ((996 - knownPosition.y) / 996) * posterHeight - 242;
	return {
		x: qrCodeX,
		y: qrCodeY,
		width: qrCodeWidth,
		height: qrCodeHeight,
	};
}

const qr = getQRCodePositionByKnownPosition({x: 227, y: 902}, 1406, 1992);

const QRCodeDemo: FC = () => {
	const [isReset, setStatus] = useState(false);

	return (
		<QrPoster render={() => (
			<div className='QRCodeWrapper'>
				<img src='https://cdn.jsdelivr.net/gh/bigbigDreamer/pic-bed@main/uPic/Poster%201.png' crossOrigin='anonymous' />
				<QRCodeCanvas
					className='qrcode'
					value='www.baidu.com'
					size={248 * 2}
					imageSettings={{
						width: qr.width,
						height: qr.height,
					}}
					style={{
						top: qr.y,
						left: qr.x,
					}}
				/>
			</div>
		)}>
			{
				({generatePoster}) => {
					const [url, setUrl] = useState('');

					useEffect(() => {
						generatePoster()
							.then(url => {
								setUrl(url);
							});
						setStatus(false);
					}, []);

					return (
						(
							<>
								<div className='demo-wrapper'>
                                    <img src={url} />
								</div>
							</>
						)
					);
				}
			}
		</QrPoster>
	);
};

Acknowledgement

QRPoster can not be shipped today without the inspiration and support of various projects in the community. We would like to show our respect to these predecessors:

  • html2canvas provided the ability to convert DOM into images;
  • await-to-js provided handle await error way;
  • rollup provide construction support;

LICENSE

MIT. Copyright By 不换.