Skip to content

Commit 0cdcaa7

Browse files
committed
feat: add @rxts/qrcode package, improve documentation
1 parent 20618bb commit 0cdcaa7

File tree

19 files changed

+571
-31
lines changed

19 files changed

+571
-31
lines changed

README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,19 @@
4040

4141
This repository is a monorepo managed by [Lerna][] what means we actually publish several packages to npm from same codebase, including:
4242

43-
| Package | Description | Version | Peer Dependencies | Dependencies |
44-
| ------------------------------------ | ----------------------------------------------------- | ----------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------- |
45-
| [`vue-qrious`](/packages/vue-qrious) | 🤳 A Vue component for QR code generation with qrious | [![npm](https://img.shields.io/npm/v/vue-qrious.svg)](https://www.npmjs.com/package/vue-qrious) | [![David Peer](https://img.shields.io/david/peer/rx-ts/vue.svg?path=packages/vue-qrious)](https://david-dm.org/rx-ts/vue?path=packages/vue-qrious&type=peer) | [![David](https://img.shields.io/david/rx-ts/vue.svg?path=packages/vue-qrious)](https://david-dm.org/rx-ts/vue?path=packages/vue-qrious) |
43+
| Package | Description | Version | Peer Dependencies | Dependencies |
44+
| ------------------------------------ | --------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------- |
45+
| [`vue-qrcode`](/packages/vue-qrcode) | 🤳 A Vue component for QR code generation with [qrcode][] | [![npm](https://img.shields.io/npm/v/@rxts/vue-qrcode.svg)](https://www.npmjs.com/package/@rxts/vue-qrcode) | [![David Peer](https://img.shields.io/david/peer/rx-ts/vue.svg?path=packages/vue-qrcode)](https://david-dm.org/rx-ts/vue?path=packages/vue-qrcode&type=peer) | [![David](https://img.shields.io/david/rx-ts/vue.svg?path=packages/vue-qrcode)](https://david-dm.org/rx-ts/vue?path=packages/vue-qrcode) |
46+
| [`vue-qrious`](/packages/vue-qrious) | 🤳 A Vue component for QR code generation with [qrious][] | [![npm](https://img.shields.io/npm/v/vue-qrious.svg)](https://www.npmjs.com/package/vue-qrious) | [![David Peer](https://img.shields.io/david/peer/rx-ts/vue.svg?path=packages/vue-qrious)](https://david-dm.org/rx-ts/vue?path=packages/vue-qrious&type=peer) | [![David](https://img.shields.io/david/rx-ts/vue.svg?path=packages/vue-qrious)](https://david-dm.org/rx-ts/vue?path=packages/vue-qrious) |
4647

4748
## Install
4849

4950
```sh
5051
# yarn
51-
yarn add vue-qrious
52+
yarn add @rxts/vue-qrcode vue-qrious
5253

5354
# npm
54-
npm i vue-qrious
55+
npm i @rxts/vue-qrcode vue-qrious
5556
```
5657

5758
## Changelog
@@ -68,3 +69,5 @@ Detailed changes for each release are documented in [CHANGELOG.md](./CHANGELOG.m
6869
[jounqin]: https://GitHub.com/JounQin
6970
[lerna]: https://github.com/lerna/lerna
7071
[mit]: http://opensource.org/licenses/MIT
72+
[qrcode]: https://github.com/soldair/node-qrcode
73+
[qrious]: https://github.com/neocotic/qrious

demo/shim.d.ts

Lines changed: 0 additions & 4 deletions
This file was deleted.

now.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,15 @@
1111
"src": "package.json",
1212
"use": "@now/static-build"
1313
}
14+
],
15+
"routes": [
16+
{
17+
"src": "/vue-qrious/*",
18+
"dest": "vue-qrious/docs/index.html"
19+
},
20+
{
21+
"src": "/*",
22+
"dest": "vue-qrcode/docs/index.html"
23+
}
1424
]
1525
}

package.json

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
"packages/*"
1111
],
1212
"scripts": {
13-
"dev": "parcel demo/index.html",
13+
"dev": "parcel packages/*/docs/index.html",
1414
"lint:es": "EFF_NO_LINK_RULES=true eslint . --ext js,md,mdx,ts,tsx -f friendly",
1515
"lint:style": "stylelint **/*.scss",
1616
"lint": "run-p lint:*",
1717
"build:es": "tsc -b --force",
1818
"build:bundle": "rollup -c node_modules/@1stg/rollup-config/module.js",
1919
"build:bundle:min": "cross-env NODE_ENV=production yarn build:bundle",
20-
"build:demo": "parcel build demo/index.html --out-dir dist",
20+
"build:docs": "parcel build packages/*/docs/index.html",
2121
"build": "rimraf dist packages/*/lib && run-p build:**",
2222
"serve": "serve dist",
2323
"type-coverage": "type-coverage --cache --ignore-catch --detail --ignore-files *.d.ts --strict"
@@ -35,9 +35,11 @@
3535
"@babel/core": "^7.5.5",
3636
"@commitlint/cli": "^8.1.0",
3737
"@commitlint/config-conventional": "^8.1.0",
38+
"@rxts/vue-qrcode": "link:packages/vue-qrcode/src",
3839
"@types/classnames": "^2.2.9",
3940
"@types/lodash": "^4.14.138",
4041
"@types/node": "^12.7.4",
42+
"@types/qrcode": "^1.3.4",
4143
"autoprefixer": "^9.6.1",
4244
"classnames": "^2.2.6",
4345
"core-js": "^3.2.1",
@@ -54,6 +56,7 @@
5456
"parcel": "^1.12.3",
5557
"postcss": "^7.0.17",
5658
"prettier": "^1.18.2",
59+
"qrcode": "^1.4.1",
5760
"qrious": "^4.0.2",
5861
"remark-preset-lint-consistent": "^2.0.3",
5962
"remark-preset-lint-markdown-style-guide": "^2.1.3",
@@ -64,6 +67,7 @@
6467
"rollup-plugin-terser": "^5.1.1",
6568
"rollup-plugin-typescript": "^1.0.1",
6669
"rxjs": "^6.5.3",
70+
"sanitize.css": "^11.0.0",
6771
"sass": "^1.23.0-module.beta.1",
6872
"serve": "^11.1.0",
6973
"stylelint": "^10.1.0",
@@ -74,6 +78,9 @@
7478
"vue": "^2.6.10",
7579
"vue-qrious": "link:packages/vue-qrious/src"
7680
},
81+
"alias": {
82+
"vue": "./node_modules/vue/dist/vue.esm.js"
83+
},
7784
"babel": {
7885
"presets": [
7986
"@1stg"
@@ -91,7 +98,7 @@
9198
"lib",
9299
"packages/*/CHANGELOG.md"
93100
],
94-
"prettier": "@1stg/prettier-config",
101+
"prettier": "@1stg/prettier-config/vue",
95102
"renovate": {
96103
"extends": "@1stg"
97104
},

packages/vue-qrcode/README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# VueQRCode
2+
3+
> 🤳 A Vue component for QR code generation with [qrcode](https://github.com/soldair/node-qrcode)
4+
5+
## Usage
6+
7+
```vue
8+
<template>
9+
<qrious value="https://www.1stg.me" />
10+
</template>
11+
<script>
12+
import Qrcode from 'vue-qrcode'
13+
14+
export default {
15+
components: {
16+
Qrcode,
17+
},
18+
}
19+
</script>
20+
```
21+
22+
## Available Props
23+
24+
| prop | type | default value |
25+
| ---------------------- | ------------------------------------------------------------------ | ------------------------------------------- |
26+
| `version` | `number` (1-40) | N/A |
27+
| `errorCorrectionLevel` | `String` ('low', 'medium', 'quartile', 'high', 'L', 'M', 'Q', 'H') | `'M'` |
28+
| `maskPattern` | `number` (0-7) | N/A |
29+
| `toSJISFunc` | `Function` | N/A |
30+
| `margin` | `number` | `4` |
31+
| `scale` | `number` | `4` |
32+
| `width` | `number` | N/A |
33+
| `color` | `{ dark: string; light:string }` | `{ dark: '#000000ff', light: '#ffffffff' }` |
34+
| `type` | `string` ('image/png', 'image/jpeg', 'image/webp',) | `'image/png'` |
35+
| `quality` | `number`(0-1) | `0.92` |
36+
| `value` | `string | Array<{ data: string; mode?: string }>` | N/A |

packages/vue-qrcode/docs/index.html

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta
6+
name="viewport"
7+
content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"
8+
/>
9+
<title>VueQrcode</title>
10+
<link rel="stylesheet" href="./style.scss" />
11+
</head>
12+
<body>
13+
<div id="app" v-cloak>
14+
<h1>VueQrcode</h1>
15+
<ul class="lists">
16+
<li>
17+
<label>version</label>
18+
<select v-model="version">
19+
<option v-for="v of 40" :value="v">{{ v }}</option>
20+
</select>
21+
</li>
22+
<li>
23+
<label>errorCorrectionLevel</label>
24+
<select v-model="errorCorrectionLevel">
25+
<option v-for="level of LEVELS" :value="level">{{ level }}</option>
26+
</select>
27+
</li>
28+
<li>
29+
<label>maskPattern</label>
30+
<select v-model="maskPattern">
31+
<option v-for="pattern of MASK_PATTERNS" :value="pattern">
32+
{{ pattern }}
33+
</option>
34+
</select>
35+
</li>
36+
<li>
37+
<label>margin</label>
38+
<input type="number" v-model.number="margin" />
39+
</li>
40+
<li></li>
41+
<li>
42+
<label>scale</label>
43+
<input type="number" v-model.number="scale" />
44+
</li>
45+
<li>
46+
<label>width</label>
47+
<input type="number" v-model.number="width" />
48+
</li>
49+
<li>
50+
<label>color.dark</label>
51+
<input type="color" v-model="color.dark" />
52+
</li>
53+
<li>
54+
<label>color.light</label>
55+
<input type="color" v-model="color.light" />
56+
</li>
57+
<li>
58+
<label>type</label>
59+
<select v-model="type">
60+
<option v-for="t of TYPES" :value="t">{{ t }}</option>
61+
</select>
62+
</li>
63+
<li>
64+
<label>quality</label>
65+
<input type="number" step="0.01" v-model.number="quality" />
66+
</li>
67+
<li>
68+
<label>
69+
manualMode
70+
<input type="checkbox" v-model="manualMode" />
71+
</label>
72+
</li>
73+
<li>
74+
<label>
75+
value
76+
<button v-if="manualMode" @click="addValue" is="button">+</button>
77+
</label>
78+
<ul v-if="manualMode">
79+
<li v-for="(v, index) of value">
80+
<label v-if="value.length">
81+
maskPattern
82+
<button @click="removeValue(index)" is="button">-</button>
83+
</label>
84+
<div>
85+
<label>mode</label>
86+
<select v-model="v.mode">
87+
<option v-for="mode of MODES" :value="mode">
88+
{{ mode }}
89+
</option>
90+
</select>
91+
</div>
92+
<div>
93+
<label>data</label>
94+
<textarea rows="6" cols="80" v-model="v.data"></textarea>
95+
</div>
96+
</li>
97+
</ul>
98+
<textarea v-else rows="6" cols="80" v-model="value"></textarea>
99+
</li>
100+
</ul>
101+
<qrcode v-bind="$data" />
102+
</div>
103+
<script src="./index.ts"></script>
104+
</body>
105+
</html>

packages/vue-qrcode/docs/index.ts

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import Qrcode, {
2+
LEVELS,
3+
MASK_PATTERNS,
4+
MODES,
5+
QRCodeSegment,
6+
QRCodeValue,
7+
TYPES,
8+
} from '@rxts/vue-qrcode'
9+
import Vue from 'vue'
10+
11+
const DEFAULT_TEXT = 'http://www.1stg.me'
12+
13+
// eslint-disable-next-line no-new
14+
new Vue({
15+
// tslint:disable-line: no-unused-expression
16+
el: '#app',
17+
data() {
18+
return {
19+
LEVELS,
20+
MASK_PATTERNS,
21+
MODES,
22+
TYPES,
23+
version: undefined,
24+
errorCorrectionLevel: 'M',
25+
maskPattern: undefined,
26+
margin: 4,
27+
scale: 4,
28+
width: undefined,
29+
color: {
30+
dark: '#000000',
31+
light: '#ffffff',
32+
},
33+
type: 'image/png',
34+
quality: 0.92,
35+
value: DEFAULT_TEXT as QRCodeValue,
36+
manualMode: false,
37+
}
38+
},
39+
watch: {
40+
manualMode() {
41+
this.value = this.manualMode
42+
? [
43+
{
44+
data: DEFAULT_TEXT,
45+
},
46+
]
47+
: DEFAULT_TEXT
48+
},
49+
},
50+
methods: {
51+
addValue() {
52+
;(this.value as QRCodeSegment[]).push({
53+
data: DEFAULT_TEXT,
54+
})
55+
},
56+
removeValue(index: number) {
57+
;(this.value as QRCodeSegment[]).splice(index, 1)
58+
},
59+
},
60+
components: {
61+
Qrcode,
62+
},
63+
})

packages/vue-qrcode/docs/style.scss

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
@import 'sanitize.css';
2+
@import 'sanitize.css/forms.css';
3+
4+
[v-cloak] {
5+
display: none;
6+
}
7+
8+
#app {
9+
margin: 0 auto;
10+
text-align: center;
11+
}
12+
13+
.lists {
14+
padding: 0;
15+
text-align: left;
16+
list-style: none;
17+
width: 300px;
18+
margin: 0 auto 30px;
19+
20+
li {
21+
margin-bottom: 8px;
22+
}
23+
24+
label {
25+
display: block;
26+
margin-bottom: 5px;
27+
28+
&:after {
29+
content: ':';
30+
}
31+
}
32+
33+
input {
34+
&[type='color'] {
35+
padding: 0;
36+
}
37+
}
38+
39+
textarea {
40+
width: 100%;
41+
}
42+
}

packages/vue-qrcode/package.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "@rxts/vue-qrcode",
3+
"version": "0.0.0",
4+
"description": "🤳 A Vue component for QR code generation with `qrcode`",
5+
"repository": "git@github.com:rx-ts/vue.git",
6+
"author": "JounQin <admin@1stg.me>",
7+
"license": "MIT",
8+
"main": "lib/cjs.js",
9+
"module": "lib/index.js",
10+
"browser": "lib/umd.js",
11+
"unpkg": "lib/umd.min.js",
12+
"es2015": "lib/es2015.js",
13+
"esm5": "lib/index.js",
14+
"fesm5": "lib/esm.js",
15+
"types": "lib/index.d.ts",
16+
"files": [
17+
"lib",
18+
"src"
19+
],
20+
"peerDependencies": {
21+
"qrcode": "^1.0.0",
22+
"vue": "^2.0.0"
23+
},
24+
"sideEffects": false
25+
}

0 commit comments

Comments
 (0)