22
33Collection of Hooks.
44
5-
65## Install
76
87> Note: React 16.8+ is required for Hooks.
@@ -22,10 +21,17 @@ yarn add hooks-toolbox
2221## API
2322
2423- [ Hooks] ( #hooks )
25- - [ ` useGoogleApiInit() ` ] ( #usegoogleapiinit )
24+ - [ Google-API] ( #google-api )
25+ - [ ` useGoogleApiInit() ` ] ( #usegoogleapiinit )
26+ - [ DYMO-API] ( #dymo-api )
27+ - [ ` useDymoCheckService() ` ] ( #usedymocheckservice )
28+ - [ ` useDymoFetchPrinters() ` ] ( #usedymofetchprinters )
29+ - [ ` useDymoOpenLabel() ` ] ( #usedymoopenlabel )
2630
2731## Hooks
2832
33+ ## Google-API
34+
2935### ` useGoogleApiInit() `
3036
3137This Hook is designed for load https://apis.google.com/js/api.js , initialize Google API and handle sign status.
@@ -43,11 +49,71 @@ Object containing:
4349- ` signed: boolean ` : ` false ` Sign status.
4450- ` userProfile: object ` : ` null ` User's basic profile information and token.
4551
52+ ## DYMO-API
53+
54+ ### ` useDymoCheckService() `
55+
56+ Return the status of DYMO Label Web Service
57+
58+ #### Arguments
59+
60+ ` port: number ` : The port of running DYMO Label Web Service.
61+
62+ #### Returns
63+
64+ Array containing:
65+
66+ - ` message: string ` : ` "" ` The errors thrown.
67+ - ` status: string ` : ` "init" ` : ` "init" | "loading" | "success" | "error" ` Status of DYMO Label Web Service.
68+
69+ ### ` useDymoFetchPrinters() `
70+
71+ Returns the available DYMO Labelwriter Printer
72+
73+ #### Arguments
74+
75+ ` port: number ` : The port of running DYMO Label Web Service.
76+ ` statusDymoService: string ` : The status of DYMO Label Web Service.
4677
78+ #### Returns
79+
80+ Array containing:
81+
82+ - ` printers: array ` : ` [] ` The list of available DYMO Labelwriter Printer.
83+ - ` status: string ` : ` "init" ` : ` "init" | "loading" | "success" | "error" ` Status of loading printers.
84+
85+ ### ` useDymoOpenLabel() `
86+
87+ Render Label
88+
89+ #### Arguments
90+
91+ ` labelXML: xml file ` : XML file.
92+ ` statusDymoService: string ` : The status of DYMO Label Web Service.
93+ ` port: number ` : The port of running DYMO Label Web Service.
4794
48- [ build-badge ] : https://img.shields.io/travis/user/repo/master.png?style=flat-square
49- [ build ] : https://travis-ci.org/user/repo
50- [ npm-badge ] : https://img.shields.io/npm/v/npm-package.png?style=flat-square
51- [ npm ] : https://www.npmjs.org/package/npm-package
52- [ coveralls-badge ] : https://img.shields.io/coveralls/user/repo/master.png?style=flat-square
53- [ coveralls ] : https://coveralls.io/github/user/repo
95+ #### Returns
96+
97+ Array containing:
98+
99+ - ` label ` :
100+ - ` status: string ` : ` "init" ` : ` "init" | "loading" | "success" | "error" ` Status of render label.
101+
102+ #### Example
103+
104+ ``` js
105+ import { useDymoOpenLabel , useDymoCheckService } from " hooks-toolbox" ;
106+
107+ const DymoLabelPreview = () => {
108+ const [msg , statusDymoService ] = useDymoCheckService ();
109+ const [label , status ] = useDymoOpenLabel (statusDymoService, xmlFile);
110+
111+ if (label) {
112+ return (
113+ < img src= {" data:image/png;base64," + label} alt= " dymo label preview" / >
114+ );
115+ } else {
116+ return null ;
117+ }
118+ };
119+ ```
0 commit comments