@pictogrammers/components 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (379) hide show
  1. package/@types/css.d.ts +4 -0
  2. package/@types/html.d.ts +4 -0
  3. package/README.md +49 -0
  4. package/dist/main.js +3819 -0
  5. package/dist/pgAnnoy.js +116 -0
  6. package/dist/pgAvatar.js +136 -0
  7. package/dist/pgButton.js +116 -0
  8. package/dist/pgButtonGroup.js +116 -0
  9. package/dist/pgButtonLink.js +116 -0
  10. package/dist/pgButtonToggle.js +146 -0
  11. package/dist/pgCard.js +116 -0
  12. package/dist/pgCardUser.js +196 -0
  13. package/dist/pgColor.js +136 -0
  14. package/dist/pgDatabase.js +236 -0
  15. package/dist/pgDropdown.js +686 -0
  16. package/dist/pgGrid.js +126 -0
  17. package/dist/pgHeader.js +116 -0
  18. package/dist/pgIcon.js +116 -0
  19. package/dist/pgInputCheck.js +116 -0
  20. package/dist/pgInputCheckList.js +126 -0
  21. package/dist/pgInputFileLocal.js +116 -0
  22. package/dist/pgInputHexRgb.js +126 -0
  23. package/dist/pgInputRange.js +116 -0
  24. package/dist/pgInputSelect.js +116 -0
  25. package/dist/pgInputText.js +116 -0
  26. package/dist/pgInputTextIcon.js +176 -0
  27. package/dist/pgInputUserSelect.js +116 -0
  28. package/dist/pgListTag.js +136 -0
  29. package/dist/pgMarkdown.js +346 -0
  30. package/dist/pgMenuIcon.js +206 -0
  31. package/dist/pgModalAlert.js +126 -0
  32. package/dist/pgModification.js +396 -0
  33. package/dist/pgNav.js +116 -0
  34. package/dist/pgOverlay.js +96 -0
  35. package/dist/pgPicker.js +116 -0
  36. package/dist/pgPreview.js +116 -0
  37. package/dist/pgScroll.js +266 -0
  38. package/dist/pgSearch.js +146 -0
  39. package/dist/pgTab.js +116 -0
  40. package/dist/pgTabs.js +136 -0
  41. package/dist/pgToast.js +136 -0
  42. package/dist/pgToasts.js +136 -0
  43. package/dist/pgTooltip.js +126 -0
  44. package/index.html +302 -0
  45. package/package.json +25 -0
  46. package/pg/annoy/README.md +18 -0
  47. package/pg/annoy/__examples__/basic/basic.html +8 -0
  48. package/pg/annoy/__examples__/basic/basic.ts +11 -0
  49. package/pg/annoy/annoy.css +238 -0
  50. package/pg/annoy/annoy.html +59 -0
  51. package/pg/annoy/annoy.ts +48 -0
  52. package/pg/annoy/index.ts +3 -0
  53. package/pg/avatar/README.md +23 -0
  54. package/pg/avatar/__examples__/basic/basic.html +6 -0
  55. package/pg/avatar/__examples__/basic/basic.ts +41 -0
  56. package/pg/avatar/__examples__/basic/constants.ts +1 -0
  57. package/pg/avatar/avatar.css +45 -0
  58. package/pg/avatar/avatar.html +8 -0
  59. package/pg/avatar/avatar.spec.ts +51 -0
  60. package/pg/avatar/avatar.ts +37 -0
  61. package/pg/avatar/index.ts +3 -0
  62. package/pg/button/README.md +51 -0
  63. package/pg/button/__examples__/basic/basic.html +11 -0
  64. package/pg/button/__examples__/basic/basic.ts +11 -0
  65. package/pg/button/__examples__/states/states.html +8 -0
  66. package/pg/button/__examples__/states/states.ts +20 -0
  67. package/pg/button/button.css +91 -0
  68. package/pg/button/button.html +3 -0
  69. package/pg/button/button.ts +45 -0
  70. package/pg/button/index.ts +3 -0
  71. package/pg/buttonGroup/README.md +28 -0
  72. package/pg/buttonGroup/__examples__/basic/basic.html +12 -0
  73. package/pg/buttonGroup/__examples__/basic/basic.ts +11 -0
  74. package/pg/buttonGroup/buttonGroup.css +4 -0
  75. package/pg/buttonGroup/buttonGroup.html +1 -0
  76. package/pg/buttonGroup/buttonGroup.spec.ts +30 -0
  77. package/pg/buttonGroup/buttonGroup.ts +50 -0
  78. package/pg/buttonGroup/index.ts +3 -0
  79. package/pg/buttonLink/README.md +51 -0
  80. package/pg/buttonLink/__examples__/basic/basic.html +17 -0
  81. package/pg/buttonLink/__examples__/basic/basic.ts +11 -0
  82. package/pg/buttonLink/buttonLink.css +91 -0
  83. package/pg/buttonLink/buttonLink.html +3 -0
  84. package/pg/buttonLink/buttonLink.ts +46 -0
  85. package/pg/buttonLink/index.ts +3 -0
  86. package/pg/buttonToggle/README.md +54 -0
  87. package/pg/buttonToggle/__examples__/basic/basic.html +10 -0
  88. package/pg/buttonToggle/__examples__/basic/basic.ts +23 -0
  89. package/pg/buttonToggle/buttonToggle.css +8 -0
  90. package/pg/buttonToggle/buttonToggle.html +4 -0
  91. package/pg/buttonToggle/buttonToggle.ts +44 -0
  92. package/pg/buttonToggle/index.ts +3 -0
  93. package/pg/card/README.md +21 -0
  94. package/pg/card/__examples__/basic/basic.html +5 -0
  95. package/pg/card/__examples__/basic/basic.ts +11 -0
  96. package/pg/card/card.css +11 -0
  97. package/pg/card/card.html +3 -0
  98. package/pg/card/card.spec.ts +30 -0
  99. package/pg/card/card.ts +13 -0
  100. package/pg/card/index.ts +3 -0
  101. package/pg/cardUser/README.md +22 -0
  102. package/pg/cardUser/__examples__/basic/basic.html +3 -0
  103. package/pg/cardUser/__examples__/basic/basic.ts +30 -0
  104. package/pg/cardUser/__examples__/basic/constants.ts +1 -0
  105. package/pg/cardUser/cardUser.css +67 -0
  106. package/pg/cardUser/cardUser.html +23 -0
  107. package/pg/cardUser/cardUser.spec.ts +46 -0
  108. package/pg/cardUser/cardUser.ts +53 -0
  109. package/pg/cardUser/index.ts +3 -0
  110. package/pg/color/README.md +13 -0
  111. package/pg/color/__examples__/basic/basic.html +4 -0
  112. package/pg/color/__examples__/basic/basic.ts +20 -0
  113. package/pg/color/color.css +21 -0
  114. package/pg/color/color.html +1 -0
  115. package/pg/color/color.ts +97 -0
  116. package/pg/color/constants.ts +357 -0
  117. package/pg/color/index.ts +3 -0
  118. package/pg/color/utils.ts +27 -0
  119. package/pg/database/README.md +28 -0
  120. package/pg/database/__examples__/basic/basic.html +9 -0
  121. package/pg/database/__examples__/basic/basic.ts +37 -0
  122. package/pg/database/database.css +0 -0
  123. package/pg/database/database.html +0 -0
  124. package/pg/database/database.ts +42 -0
  125. package/pg/database/index.ts +3 -0
  126. package/pg/dropdown/README.md +13 -0
  127. package/pg/dropdown/__examples__/basic/basic.html +14 -0
  128. package/pg/dropdown/__examples__/basic/basic.ts +11 -0
  129. package/pg/dropdown/dropdown.css +46 -0
  130. package/pg/dropdown/dropdown.html +5 -0
  131. package/pg/dropdown/dropdown.ts +60 -0
  132. package/pg/dropdown/index.ts +3 -0
  133. package/pg/grid/README.md +97 -0
  134. package/pg/grid/__examples__/basic/basic.html +29 -0
  135. package/pg/grid/__examples__/basic/basic.ts +139 -0
  136. package/pg/grid/grid.css +68 -0
  137. package/pg/grid/grid.html +6 -0
  138. package/pg/grid/grid.spec.ts +66 -0
  139. package/pg/grid/grid.ts +417 -0
  140. package/pg/grid/index.ts +3 -0
  141. package/pg/header/README.md +23 -0
  142. package/pg/header/__examples__/basic/basic.html +8 -0
  143. package/pg/header/__examples__/basic/basic.ts +11 -0
  144. package/pg/header/header.css +42 -0
  145. package/pg/header/header.html +15 -0
  146. package/pg/header/header.ts +28 -0
  147. package/pg/header/index.ts +3 -0
  148. package/pg/icon/README.md +26 -0
  149. package/pg/icon/__examples__/basic/basic.html +16 -0
  150. package/pg/icon/__examples__/basic/basic.ts +34 -0
  151. package/pg/icon/__examples__/basic/constants.ts +2 -0
  152. package/pg/icon/icon.css +9 -0
  153. package/pg/icon/icon.html +3 -0
  154. package/pg/icon/icon.spec.ts +46 -0
  155. package/pg/icon/icon.ts +23 -0
  156. package/pg/icon/index.ts +3 -0
  157. package/pg/inputCheck/README.md +32 -0
  158. package/pg/inputCheck/__examples__/basic/basic.html +8 -0
  159. package/pg/inputCheck/__examples__/basic/basic.ts +23 -0
  160. package/pg/inputCheck/index.ts +3 -0
  161. package/pg/inputCheck/inputCheck.css +45 -0
  162. package/pg/inputCheck/inputCheck.html +6 -0
  163. package/pg/inputCheck/inputCheck.ts +42 -0
  164. package/pg/inputCheckList/README.md +35 -0
  165. package/pg/inputCheckList/__examples__/basic/basic.html +4 -0
  166. package/pg/inputCheckList/__examples__/basic/basic.ts +31 -0
  167. package/pg/inputCheckList/index.ts +3 -0
  168. package/pg/inputCheckList/inputCheckList.css +70 -0
  169. package/pg/inputCheckList/inputCheckList.html +1 -0
  170. package/pg/inputCheckList/inputCheckList.ts +103 -0
  171. package/pg/inputCheckList/templates/option.html +8 -0
  172. package/pg/inputFileLocal/README.md +30 -0
  173. package/pg/inputFileLocal/__examples__/basic/basic.html +4 -0
  174. package/pg/inputFileLocal/__examples__/basic/basic.ts +23 -0
  175. package/pg/inputFileLocal/index.ts +3 -0
  176. package/pg/inputFileLocal/inputFileLocal.css +80 -0
  177. package/pg/inputFileLocal/inputFileLocal.html +5 -0
  178. package/pg/inputFileLocal/inputFileLocal.ts +82 -0
  179. package/pg/inputHexRgb/README.md +15 -0
  180. package/pg/inputHexRgb/__examples__/basic/basic.html +4 -0
  181. package/pg/inputHexRgb/__examples__/basic/basic.ts +23 -0
  182. package/pg/inputHexRgb/index.ts +3 -0
  183. package/pg/inputHexRgb/inputHexRgb.css +96 -0
  184. package/pg/inputHexRgb/inputHexRgb.html +9 -0
  185. package/pg/inputHexRgb/inputHexRgb.ts +79 -0
  186. package/pg/inputHexRgb/utils.ts +27 -0
  187. package/pg/inputRange/README.md +18 -0
  188. package/pg/inputRange/__examples__/basic/basic.html +9 -0
  189. package/pg/inputRange/__examples__/basic/basic.ts +30 -0
  190. package/pg/inputRange/index.ts +3 -0
  191. package/pg/inputRange/inputRange.css +0 -0
  192. package/pg/inputRange/inputRange.html +1 -0
  193. package/pg/inputRange/inputRange.ts +53 -0
  194. package/pg/inputSelect/README.md +25 -0
  195. package/pg/inputSelect/__examples__/basic/basic.html +6 -0
  196. package/pg/inputSelect/__examples__/basic/basic.ts +30 -0
  197. package/pg/inputSelect/index.ts +3 -0
  198. package/pg/inputSelect/inputSelect.css +36 -0
  199. package/pg/inputSelect/inputSelect.html +4 -0
  200. package/pg/inputSelect/inputSelect.ts +57 -0
  201. package/pg/inputText/README.md +27 -0
  202. package/pg/inputText/__examples__/basic/basic.html +9 -0
  203. package/pg/inputText/__examples__/basic/basic.ts +30 -0
  204. package/pg/inputText/index.ts +3 -0
  205. package/pg/inputText/inputText.css +20 -0
  206. package/pg/inputText/inputText.html +1 -0
  207. package/pg/inputText/inputText.spec.ts +59 -0
  208. package/pg/inputText/inputText.ts +59 -0
  209. package/pg/inputTextIcon/README.md +26 -0
  210. package/pg/inputTextIcon/index.ts +3 -0
  211. package/pg/inputTextIcon/inputTextIcon.css +24 -0
  212. package/pg/inputTextIcon/inputTextIcon.html +4 -0
  213. package/pg/inputTextIcon/inputTextIcon.spec.ts +44 -0
  214. package/pg/inputTextIcon/inputTextIcon.ts +26 -0
  215. package/pg/inputUserSelect/README.md +31 -0
  216. package/pg/inputUserSelect/__examples__/basic/basic.html +4 -0
  217. package/pg/inputUserSelect/__examples__/basic/basic.ts +25 -0
  218. package/pg/inputUserSelect/__examples__/basic/constants.ts +33 -0
  219. package/pg/inputUserSelect/index.ts +3 -0
  220. package/pg/inputUserSelect/inputUserSelect.css +174 -0
  221. package/pg/inputUserSelect/inputUserSelect.html +18 -0
  222. package/pg/inputUserSelect/inputUserSelect.ts +266 -0
  223. package/pg/listTag/README.md +26 -0
  224. package/pg/listTag/__examples__/basic/basic.html +16 -0
  225. package/pg/listTag/__examples__/basic/basic.ts +53 -0
  226. package/pg/listTag/__examples__/basic/constants.ts +22 -0
  227. package/pg/listTag/index.ts +3 -0
  228. package/pg/listTag/listTag.css +9 -0
  229. package/pg/listTag/listTag.html +1 -0
  230. package/pg/listTag/listTag.ts +48 -0
  231. package/pg/listTag/partials/tag.html +3 -0
  232. package/pg/markdown/README.md +13 -0
  233. package/pg/markdown/__examples__/basic/basic.html +3 -0
  234. package/pg/markdown/__examples__/basic/basic.ts +51 -0
  235. package/pg/markdown/__examples__/basic/constants.ts +129 -0
  236. package/pg/markdown/index.ts +5 -0
  237. package/pg/markdown/markdown.css +760 -0
  238. package/pg/markdown/markdown.html +1 -0
  239. package/pg/markdown/markdown.md +123 -0
  240. package/pg/markdown/markdown.spec.ts +87 -0
  241. package/pg/markdown/markdown.ts +381 -0
  242. package/pg/markdown/markdownReplace.ts +7 -0
  243. package/pg/menuIcon/README.md +13 -0
  244. package/pg/menuIcon/__examples__/basic/basic.html +3 -0
  245. package/pg/menuIcon/__examples__/basic/basic.ts +15 -0
  246. package/pg/menuIcon/index.ts +3 -0
  247. package/pg/menuIcon/menuIcon.css +168 -0
  248. package/pg/menuIcon/menuIcon.html +64 -0
  249. package/pg/menuIcon/menuIcon.ts +271 -0
  250. package/pg/modalAlert/README.md +17 -0
  251. package/pg/modalAlert/__examples__/basic/basic.html +4 -0
  252. package/pg/modalAlert/__examples__/basic/basic.ts +27 -0
  253. package/pg/modalAlert/index.ts +3 -0
  254. package/pg/modalAlert/modalAlert.css +43 -0
  255. package/pg/modalAlert/modalAlert.html +22 -0
  256. package/pg/modalAlert/modalAlert.ts +45 -0
  257. package/pg/modification/README.md +34 -0
  258. package/pg/modification/__examples__/basic/basic.html +8 -0
  259. package/pg/modification/__examples__/basic/basic.ts +63 -0
  260. package/pg/modification/__examples__/basic/constants.ts +416 -0
  261. package/pg/modification/index.ts +3 -0
  262. package/pg/modification/modification.css +311 -0
  263. package/pg/modification/modification.html +1 -0
  264. package/pg/modification/modification.spec.ts +33 -0
  265. package/pg/modification/modification.ts +201 -0
  266. package/pg/modification/type/date.html +1 -0
  267. package/pg/modification/type/iconAliasCreated.html +13 -0
  268. package/pg/modification/type/iconAliasDeleted.html +13 -0
  269. package/pg/modification/type/iconAuthorModified.html +13 -0
  270. package/pg/modification/type/iconCreated.html +13 -0
  271. package/pg/modification/type/iconDeleted.html +13 -0
  272. package/pg/modification/type/iconDeprecated.html +13 -0
  273. package/pg/modification/type/iconDescriptionModified.html +10 -0
  274. package/pg/modification/type/iconModified.html +14 -0
  275. package/pg/modification/type/iconRenamed.html +13 -0
  276. package/pg/modification/type/iconTagCreated.html +13 -0
  277. package/pg/modification/type/iconTagDeleted.html +13 -0
  278. package/pg/modification/type/news.html +5 -0
  279. package/pg/nav/README.md +16 -0
  280. package/pg/nav/__examples__/basic/basic.html +5 -0
  281. package/pg/nav/__examples__/basic/basic.ts +11 -0
  282. package/pg/nav/index.ts +3 -0
  283. package/pg/nav/nav.css +14 -0
  284. package/pg/nav/nav.html +16 -0
  285. package/pg/nav/nav.ts +21 -0
  286. package/pg/overlay/README.md +37 -0
  287. package/pg/overlay/__examples__/basic/basic.css +3 -0
  288. package/pg/overlay/__examples__/basic/basic.html +3 -0
  289. package/pg/overlay/__examples__/basic/basic.ts +13 -0
  290. package/pg/overlay/index.ts +3 -0
  291. package/pg/overlay/overlay.ts +26 -0
  292. package/pg/picker/README.md +13 -0
  293. package/pg/picker/index.ts +3 -0
  294. package/pg/picker/picker.css +56 -0
  295. package/pg/picker/picker.html +8 -0
  296. package/pg/picker/picker.ts +66 -0
  297. package/pg/preview/README.md +19 -0
  298. package/pg/preview/__examples__/basic/basic.html +11 -0
  299. package/pg/preview/__examples__/basic/basic.ts +22 -0
  300. package/pg/preview/index.ts +3 -0
  301. package/pg/preview/preview.css +34 -0
  302. package/pg/preview/preview.html +5 -0
  303. package/pg/preview/preview.ts +38 -0
  304. package/pg/scroll/README.md +42 -0
  305. package/pg/scroll/__examples__/basic/basic.css +4 -0
  306. package/pg/scroll/__examples__/basic/basic.html +11 -0
  307. package/pg/scroll/__examples__/basic/basic.ts +88 -0
  308. package/pg/scroll/index.ts +3 -0
  309. package/pg/scroll/scroll.css +7 -0
  310. package/pg/scroll/scroll.html +3 -0
  311. package/pg/scroll/scroll.ts +158 -0
  312. package/pg/search/README.md +59 -0
  313. package/pg/search/__examples__/basic/basic.html +3 -0
  314. package/pg/search/__examples__/basic/basic.ts +29 -0
  315. package/pg/search/__examples__/basic/constants.ts +3 -0
  316. package/pg/search/index.ts +3 -0
  317. package/pg/search/search.css +188 -0
  318. package/pg/search/search.html +18 -0
  319. package/pg/search/search.ts +252 -0
  320. package/pg/search/utils.ts +12 -0
  321. package/pg/shared/README.md +28 -0
  322. package/pg/shared/copy.ts +25 -0
  323. package/pg/shared/database.ts +35 -0
  324. package/pg/shared/databaseService.ts +230 -0
  325. package/pg/shared/debounce.ts +12 -0
  326. package/pg/shared/enums/modificationType.ts +19 -0
  327. package/pg/shared/filter.ts +14 -0
  328. package/pg/shared/http.ts +83 -0
  329. package/pg/shared/iconFilter.spec.ts +61 -0
  330. package/pg/shared/iconFilter.ts +71 -0
  331. package/pg/shared/list.ts +34 -0
  332. package/pg/shared/models/alias.ts +40 -0
  333. package/pg/shared/models/font.ts +31 -0
  334. package/pg/shared/models/fontIcon.ts +25 -0
  335. package/pg/shared/models/fontVersion.ts +22 -0
  336. package/pg/shared/models/icon.ts +97 -0
  337. package/pg/shared/models/modification.ts +45 -0
  338. package/pg/shared/models/style.ts +12 -0
  339. package/pg/shared/models/tag.ts +37 -0
  340. package/pg/shared/models/user.ts +35 -0
  341. package/pg/shared/models/version.ts +20 -0
  342. package/pg/shared/removeDiacritics.ts +94 -0
  343. package/pg/shared/toast.ts +47 -0
  344. package/pg/shared/uuid.ts +6 -0
  345. package/pg/tab/README.md +18 -0
  346. package/pg/tab/index.ts +3 -0
  347. package/pg/tab/tab.css +13 -0
  348. package/pg/tab/tab.html +3 -0
  349. package/pg/tab/tab.ts +51 -0
  350. package/pg/tabs/README.md +31 -0
  351. package/pg/tabs/__examples__/basic/basic.html +13 -0
  352. package/pg/tabs/__examples__/basic/basic.ts +11 -0
  353. package/pg/tabs/index.ts +3 -0
  354. package/pg/tabs/partials/tab.html +3 -0
  355. package/pg/tabs/tabs.css +69 -0
  356. package/pg/tabs/tabs.html +4 -0
  357. package/pg/tabs/tabs.ts +102 -0
  358. package/pg/toast/README.md +13 -0
  359. package/pg/toast/index.ts +3 -0
  360. package/pg/toast/toast.css +112 -0
  361. package/pg/toast/toast.html +13 -0
  362. package/pg/toast/toast.ts +39 -0
  363. package/pg/toasts/README.md +37 -0
  364. package/pg/toasts/__examples__/basic/basic.html +11 -0
  365. package/pg/toasts/__examples__/basic/basic.ts +86 -0
  366. package/pg/toasts/index.ts +3 -0
  367. package/pg/toasts/toasts.css +8 -0
  368. package/pg/toasts/toasts.html +1 -0
  369. package/pg/toasts/toasts.ts +51 -0
  370. package/pg/tooltip/README.md +51 -0
  371. package/pg/tooltip/__examples__/basic/basic.css +38 -0
  372. package/pg/tooltip/__examples__/basic/basic.html +21 -0
  373. package/pg/tooltip/__examples__/basic/basic.ts +55 -0
  374. package/pg/tooltip/addTooltip.ts +31 -0
  375. package/pg/tooltip/index.ts +20 -0
  376. package/pg/tooltip/position.ts +15 -0
  377. package/pg/tooltip/tooltip.css +36 -0
  378. package/pg/tooltip/tooltip.html +4 -0
  379. package/pg/tooltip/tooltip.ts +170 -0
@@ -0,0 +1,13 @@
1
+ # `<pg-color>`
2
+
3
+ Visual color picker using the standard Material Design pallet.
4
+
5
+ ```typescript
6
+ import '@pictogrammers/components/pg/color';
7
+ ```
8
+
9
+ ## Usage
10
+
11
+ | Events | Description |
12
+ | ------ | ----------- |
13
+ | `onchange` | `event = { detail: { r, g, b, hex } }` |
@@ -0,0 +1,4 @@
1
+ <div class="example">
2
+ <pg-color part="color1" value="#000"></pg-color>
3
+ <code>Selected: <span part="colorSelected"></span></code>
4
+ </div>
@@ -0,0 +1,20 @@
1
+ import { Component, Part, Prop } from '@pictogrammers/element';
2
+ import PgColor from '../../color';
3
+
4
+ import template from './basic.html';
5
+
6
+ @Component({
7
+ selector: 'x-pg-color-basic',
8
+ template
9
+ })
10
+ export default class XPgColorBasic extends HTMLElement {
11
+ @Part() $color1: PgColor;
12
+ @Part() $colorSelected: HTMLSpanElement;
13
+
14
+ connectedCallback() {
15
+ this.$color1.addEventListener('select', (e: CustomEvent) => {
16
+ const { rgb, hex } = e.detail;
17
+ this.$colorSelected.innerText = `${hex} or rgb(${rgb.r}, ${rgb.g}, ${rgb.b})`;
18
+ });
19
+ }
20
+ }
@@ -0,0 +1,21 @@
1
+ button {
2
+ border: 0;
3
+ padding: 0;
4
+ outline: 0;
5
+ }
6
+
7
+ button.active {
8
+ border: 2px solid #fff;
9
+ box-shadow: 0 0 0.25rem rgba(0, 0, 0, 0.5);
10
+ order: 1;
11
+ }
12
+
13
+ button.white.active {
14
+ box-shadow: 0 0 0.25rem rgba(0, 0, 0, 0.5) inset;
15
+ }
16
+
17
+ [part~=grid] {
18
+ display: grid;
19
+ grid-template-columns: repeat(19, 1rem);
20
+ grid-template-rows: repeat(14, 1rem);
21
+ }
@@ -0,0 +1 @@
1
+ <div part="grid"></div>
@@ -0,0 +1,97 @@
1
+ import { Component, Part, Prop } from '@pictogrammers/element';
2
+ import { SWATCHES } from './constants';
3
+ import { hexToRgb, normalizeHex } from './utils';
4
+
5
+ import template from './color.html';
6
+ import style from './color.css';
7
+
8
+ @Component({
9
+ selector: 'pg-color',
10
+ style,
11
+ template
12
+ })
13
+ export default class PgColor extends HTMLElement {
14
+ @Prop() value: string = '#000000';
15
+
16
+ @Part() $grid: HTMLDivElement;
17
+
18
+ buttons: [HTMLButtonElement, string, any][] = [];
19
+ isMouseDown: boolean = false;
20
+ index: number = -1;
21
+
22
+ connectedCallback() {
23
+ SWATCHES.forEach((group, groupIndex) => {
24
+ group.colors.forEach((color, colorIndex) => {
25
+ const button = document.createElement('button');
26
+ button.style.background = `#${color.hex}`;
27
+ if (color.name === 'black') {
28
+ button.style.gridArea = `13 / 17 / 15 / 20`;
29
+ } else if (color.name === 'white') {
30
+ button.style.gridArea = `11 / 17 / 13 / 20`;
31
+ button.classList.add('white');
32
+ } else {
33
+ button.style.gridRow = `${colorIndex + 1}`;
34
+ button.style.gridColumn = `${groupIndex + 1}`;
35
+ }
36
+ const index = this.buttons.push([
37
+ button,
38
+ `#${color.hex}`,
39
+ group
40
+ ]);
41
+ button.addEventListener('click', () => {
42
+ this.handleSelect(index - 1);
43
+ });
44
+ button.addEventListener('mouseenter', () => {
45
+ if (this.isMouseDown) {
46
+ this.handleSelect(index - 1);
47
+ }
48
+ });
49
+ this.$grid.appendChild(button);
50
+ });
51
+ });
52
+ const setToFalse = () => {
53
+ this.isMouseDown = false;
54
+ document.removeEventListener('mouseup', setToFalse);
55
+ };
56
+ this.$grid.addEventListener('mousedown', (e) => {
57
+ this.isMouseDown = true;
58
+ const index = this.buttons.findIndex(([b]) => b === e.target);
59
+ if (index !== -1) {
60
+ this.handleSelect(index);
61
+ }
62
+ document.addEventListener('mouseup', setToFalse);
63
+ });
64
+
65
+ }
66
+
67
+ handleSelect(index) {
68
+ const [button, hex, group] = this.buttons[index];
69
+ const rgb = hexToRgb(hex);
70
+ this.dispatchEvent(new CustomEvent('select', {
71
+ detail: {
72
+ group,
73
+ hex,
74
+ rgb
75
+ }
76
+ }));
77
+ if (this.index !== -1) {
78
+ const [lastButton] = this.buttons[this.index];
79
+ lastButton.classList.toggle('active', false);
80
+ }
81
+ button.classList.toggle('active', true);
82
+ this.index = index;
83
+ }
84
+
85
+ render() {
86
+ if (this.index !== -1) {
87
+ const [lastButton] = this.buttons[this.index];
88
+ lastButton.classList.toggle('active', false);
89
+ }
90
+ const index = this.buttons.findIndex((a) => a[1] === this.value);
91
+ this.index = index;
92
+ if (this.buttons[index]) {
93
+ const [button] = this.buttons[index];
94
+ button.classList.toggle('active', true);
95
+ }
96
+ }
97
+ }
@@ -0,0 +1,357 @@
1
+ export const SWATCHES = [{
2
+ name: 'Red',
3
+ camel: 'red',
4
+ colors: [
5
+ { name: '50', hex: 'FFEBEE' },
6
+ { name: '100', hex: 'FFCDD2' },
7
+ { name: '200', hex: 'EF9A9A' },
8
+ { name: '300', hex: 'E57373' },
9
+ { name: '400', hex: 'EF5350' },
10
+ { name: '500', hex: 'F44336' },
11
+ { name: '600', hex: 'E53935' },
12
+ { name: '700', hex: 'D32F2F' },
13
+ { name: '800', hex: 'C62828' },
14
+ { name: '900', hex: 'B71C1C' },
15
+ { name: 'A100', hex: 'FF8A80' },
16
+ { name: 'A200', hex: 'FF5252' },
17
+ { name: 'A400', hex: 'FF1744' },
18
+ { name: 'A700', hex: 'D50000' }
19
+ ]
20
+ }, {
21
+ name: 'Pink',
22
+ camel: 'pink',
23
+ colors: [
24
+ { name: '50', hex: 'FCE4EC' },
25
+ { name: '100', hex: 'F8BBD0' },
26
+ { name: '200', hex: 'F48FB1' },
27
+ { name: '300', hex: 'F06292' },
28
+ { name: '400', hex: 'EC407A' },
29
+ { name: '500', hex: 'E91E63' },
30
+ { name: '600', hex: 'D81B60' },
31
+ { name: '700', hex: 'C2185B' },
32
+ { name: '800', hex: 'AD1457' },
33
+ { name: '900', hex: '880E4F' },
34
+ { name: 'A100', hex: 'FF80AB' },
35
+ { name: 'A200', hex: 'FF4081' },
36
+ { name: 'A400', hex: 'F50057' },
37
+ { name: 'A700', hex: 'C51162' }
38
+ ]
39
+ }, {
40
+ name: 'Purple',
41
+ camel: 'purple',
42
+ colors: [
43
+ { name: '50', hex: 'F3E5F5' },
44
+ { name: '100', hex: 'E1BEE7' },
45
+ { name: '200', hex: 'CE93D8' },
46
+ { name: '300', hex: 'BA68C8' },
47
+ { name: '400', hex: 'AB47BC' },
48
+ { name: '500', hex: '9C27B0' },
49
+ { name: '600', hex: '8E24AA' },
50
+ { name: '700', hex: '7B1FA2' },
51
+ { name: '800', hex: '6A1B9A' },
52
+ { name: '900', hex: '4A148C' },
53
+ { name: 'A100', hex: 'EA80FC' },
54
+ { name: 'A200', hex: 'E040FB' },
55
+ { name: 'A400', hex: 'D500F9' },
56
+ { name: 'A700', hex: 'AA00FF' }
57
+ ]
58
+ }, {
59
+ name: 'Deep Purple',
60
+ camel: 'deepPurple',
61
+ colors: [
62
+ { name: '50', hex: 'EDE7F6' },
63
+ { name: '100', hex: 'D1C4E9' },
64
+ { name: '200', hex: 'B39DDB' },
65
+ { name: '300', hex: '9575CD' },
66
+ { name: '400', hex: '7E57C2' },
67
+ { name: '500', hex: '673AB7' },
68
+ { name: '600', hex: '5E35B1' },
69
+ { name: '700', hex: '512DA8' },
70
+ { name: '800', hex: '4527A0' },
71
+ { name: '900', hex: '311B92' },
72
+ { name: 'A100', hex: 'B388FF' },
73
+ { name: 'A200', hex: '7C4DFF' },
74
+ { name: 'A400', hex: '651FFF' },
75
+ { name: 'A700', hex: '6200EA' }
76
+ ]
77
+ }, {
78
+ name: 'Indigo',
79
+ camel: 'indigo',
80
+ colors: [
81
+ { name: '50', hex: 'E8EAF6' },
82
+ { name: '100', hex: 'C5CAE9' },
83
+ { name: '200', hex: '9FA8DA' },
84
+ { name: '300', hex: '7986CB' },
85
+ { name: '400', hex: '5C6BC0' },
86
+ { name: '500', hex: '3F51B5' },
87
+ { name: '600', hex: '3949AB' },
88
+ { name: '700', hex: '303F9F' },
89
+ { name: '800', hex: '283593' },
90
+ { name: '900', hex: '1A237E' },
91
+ { name: 'A100', hex: '8C9EFF' },
92
+ { name: 'A200', hex: '536DFE' },
93
+ { name: 'A400', hex: '3D5AFE' },
94
+ { name: 'A700', hex: '304FFE' }
95
+ ]
96
+ }, {
97
+ name: 'Blue',
98
+ camel: 'blue',
99
+ colors: [
100
+ { name: '50', hex: 'E3F2FD' },
101
+ { name: '100', hex: 'BBDEFB' },
102
+ { name: '200', hex: '90CAF9' },
103
+ { name: '300', hex: '64B5F6' },
104
+ { name: '400', hex: '42A5F5' },
105
+ { name: '500', hex: '2196F3' },
106
+ { name: '600', hex: '1E88E5' },
107
+ { name: '700', hex: '1976D2' },
108
+ { name: '800', hex: '1565C0' },
109
+ { name: '900', hex: '0D47A1' },
110
+ { name: 'A100', hex: '82B1FF' },
111
+ { name: 'A200', hex: '448AFF' },
112
+ { name: 'A400', hex: '2979FF' },
113
+ { name: 'A700', hex: '2962FF' }
114
+ ]
115
+ }, {
116
+ name: 'Light Blue',
117
+ camel: 'lightBlue',
118
+ colors: [
119
+ { name: '50', hex: 'E1F5FE' },
120
+ { name: '100', hex: 'B3E5FC' },
121
+ { name: '200', hex: '81D4FA' },
122
+ { name: '300', hex: '4FC3F7' },
123
+ { name: '400', hex: '29B6F6' },
124
+ { name: '500', hex: '03A9F4' },
125
+ { name: '600', hex: '039BE5' },
126
+ { name: '700', hex: '0288D1' },
127
+ { name: '800', hex: '0277BD' },
128
+ { name: '900', hex: '01579B' },
129
+ { name: 'A100', hex: '80D8FF' },
130
+ { name: 'A200', hex: '40C4FF' },
131
+ { name: 'A400', hex: '00B0FF' },
132
+ { name: 'A700', hex: '0091EA' }
133
+ ]
134
+ }, {
135
+ name: 'Cyan',
136
+ camel: 'cyan',
137
+ colors: [
138
+ { name: '50', hex: 'E0F7FA' },
139
+ { name: '100', hex: 'B2EBF2' },
140
+ { name: '200', hex: '80DEEA' },
141
+ { name: '300', hex: '4DD0E1' },
142
+ { name: '400', hex: '26C6DA' },
143
+ { name: '500', hex: '00BCD4' },
144
+ { name: '600', hex: '00ACC1' },
145
+ { name: '700', hex: '0097A7' },
146
+ { name: '800', hex: '00838F' },
147
+ { name: '900', hex: '006064' },
148
+ { name: 'A100', hex: '84FFFF' },
149
+ { name: 'A200', hex: '18FFFF' },
150
+ { name: 'A400', hex: '00E5FF' },
151
+ { name: 'A700', hex: '00B8D4' }
152
+ ]
153
+ }, {
154
+ name: 'Teal',
155
+ camel: 'teal',
156
+ colors: [
157
+ { name: '50', hex: 'E0F2F1' },
158
+ { name: '100', hex: 'B2DFDB' },
159
+ { name: '200', hex: '80CBC4' },
160
+ { name: '300', hex: '4DB6AC' },
161
+ { name: '400', hex: '26A69A' },
162
+ { name: '500', hex: '009688' },
163
+ { name: '600', hex: '00897B' },
164
+ { name: '700', hex: '00796B' },
165
+ { name: '800', hex: '00695C' },
166
+ { name: '900', hex: '004D40' },
167
+ { name: 'A100', hex: 'A7FFEB' },
168
+ { name: 'A200', hex: '64FFDA' },
169
+ { name: 'A400', hex: '1DE9B6' },
170
+ { name: 'A700', hex: '00BFA5' }
171
+ ]
172
+ }, {
173
+ name: 'Green',
174
+ camel: 'green',
175
+ colors: [
176
+ { name: '50', hex: 'E8F5E9' },
177
+ { name: '100', hex: 'C8E6C9' },
178
+ { name: '200', hex: 'A5D6A7' },
179
+ { name: '300', hex: '81C784' },
180
+ { name: '400', hex: '66BB6A' },
181
+ { name: '500', hex: '4CAF50' },
182
+ { name: '600', hex: '43A047' },
183
+ { name: '700', hex: '388E3C' },
184
+ { name: '800', hex: '2E7D32' },
185
+ { name: '900', hex: '1B5E20' },
186
+ { name: 'A100', hex: 'B9F6CA' },
187
+ { name: 'A200', hex: '69F0AE' },
188
+ { name: 'A400', hex: '00E676' },
189
+ { name: 'A700', hex: '00C853' }
190
+ ]
191
+ }, {
192
+ name: 'Light Green',
193
+ camel: 'lightGreen',
194
+ colors: [
195
+ { name: '50', hex: 'F1F8E9' },
196
+ { name: '100', hex: 'DCEDC8' },
197
+ { name: '200', hex: 'C5E1A5' },
198
+ { name: '300', hex: 'AED581' },
199
+ { name: '400', hex: '9CCC65' },
200
+ { name: '500', hex: '8BC34A' },
201
+ { name: '600', hex: '7CB342' },
202
+ { name: '700', hex: '689F38' },
203
+ { name: '800', hex: '558B2F' },
204
+ { name: '900', hex: '33691E' },
205
+ { name: 'A100', hex: 'CCFF90' },
206
+ { name: 'A200', hex: 'B2FF59' },
207
+ { name: 'A400', hex: '76FF03' },
208
+ { name: 'A700', hex: '64DD17' }
209
+ ]
210
+ }, {
211
+ name: 'Lime',
212
+ camel: 'lime',
213
+ colors: [
214
+ { name: '50', hex: 'F9FBE7' },
215
+ { name: '100', hex: 'F0F4C3' },
216
+ { name: '200', hex: 'E6EE9C' },
217
+ { name: '300', hex: 'DCE775' },
218
+ { name: '400', hex: 'D4E157' },
219
+ { name: '500', hex: 'CDDC39' },
220
+ { name: '600', hex: 'C0CA33' },
221
+ { name: '700', hex: 'AFB42B' },
222
+ { name: '800', hex: '9E9D24' },
223
+ { name: '900', hex: '827717' },
224
+ { name: 'A100', hex: 'F4FF81' },
225
+ { name: 'A200', hex: 'EEFF41' },
226
+ { name: 'A400', hex: 'C6FF00' },
227
+ { name: 'A700', hex: 'AEEA00' }
228
+ ]
229
+ }, {
230
+ name: 'Yellow',
231
+ camel: 'yellow',
232
+ colors: [
233
+ { name: '50', hex: 'FFFDE7' },
234
+ { name: '100', hex: 'FFF9C4' },
235
+ { name: '200', hex: 'FFF59D' },
236
+ { name: '300', hex: 'FFF176' },
237
+ { name: '400', hex: 'FFEE58' },
238
+ { name: '500', hex: 'FFEB3B' },
239
+ { name: '600', hex: 'FDD835' },
240
+ { name: '700', hex: 'FBC02D' },
241
+ { name: '800', hex: 'F9A825' },
242
+ { name: '900', hex: 'F57F17' },
243
+ { name: 'A100', hex: 'FFFF8D' },
244
+ { name: 'A200', hex: 'FFFF00' },
245
+ { name: 'A400', hex: 'FFEA00' },
246
+ { name: 'A700', hex: 'FFD600' }
247
+ ]
248
+ }, {
249
+ name: 'Amber',
250
+ camel: 'amber',
251
+ colors: [
252
+ { name: '50', hex: 'FFF8E1' },
253
+ { name: '100', hex: 'FFECB3' },
254
+ { name: '200', hex: 'FFE082' },
255
+ { name: '300', hex: 'FFD54F' },
256
+ { name: '400', hex: 'FFCA28' },
257
+ { name: '500', hex: 'FFC107' },
258
+ { name: '600', hex: 'FFB300' },
259
+ { name: '700', hex: 'FFA000' },
260
+ { name: '800', hex: 'FF8F00' },
261
+ { name: '900', hex: 'FF6F00' },
262
+ { name: 'A100', hex: 'FFE57F' },
263
+ { name: 'A200', hex: 'FFD740' },
264
+ { name: 'A400', hex: 'FFC400' },
265
+ { name: 'A700', hex: 'FFAB00' }
266
+ ]
267
+ }, {
268
+ name: 'Orange',
269
+ camel: 'orange',
270
+ colors: [
271
+ { name: '50', hex: 'FFF3E0' },
272
+ { name: '100', hex: 'FFE0B2' },
273
+ { name: '200', hex: 'FFCC80' },
274
+ { name: '300', hex: 'FFB74D' },
275
+ { name: '400', hex: 'FFA726' },
276
+ { name: '500', hex: 'FF9800' },
277
+ { name: '600', hex: 'FB8C00' },
278
+ { name: '700', hex: 'F57C00' },
279
+ { name: '800', hex: 'EF6C00' },
280
+ { name: '900', hex: 'E65100' },
281
+ { name: 'A100', hex: 'FFD180' },
282
+ { name: 'A200', hex: 'FFAB40' },
283
+ { name: 'A400', hex: 'FF9100' },
284
+ { name: 'A700', hex: 'FF6D00' }
285
+ ]
286
+ }, {
287
+ name: 'Deep Orange',
288
+ camel: 'deepOrange',
289
+ colors: [
290
+ { name: '50', hex: 'FBE9E7' },
291
+ { name: '100', hex: 'FFCCBC' },
292
+ { name: '200', hex: 'FFAB91' },
293
+ { name: '300', hex: 'FF8A65' },
294
+ { name: '400', hex: 'FF7043' },
295
+ { name: '500', hex: 'FF5722' },
296
+ { name: '600', hex: 'F4511E' },
297
+ { name: '700', hex: 'E64A19' },
298
+ { name: '800', hex: 'D84315' },
299
+ { name: '900', hex: 'BF360C' },
300
+ { name: 'A100', hex: 'FF9E80' },
301
+ { name: 'A200', hex: 'FF6E40' },
302
+ { name: 'A400', hex: 'FF3D00' },
303
+ { name: 'A700', hex: 'DD2C00' }
304
+ ]
305
+ }, {
306
+ name: 'Brown',
307
+ camel: 'brown',
308
+ colors: [
309
+ { name: '50', hex: 'EFEBE9' },
310
+ { name: '100', hex: 'D7CCC8' },
311
+ { name: '200', hex: 'BCAAA4' },
312
+ { name: '300', hex: 'A1887F' },
313
+ { name: '400', hex: '8D6E63' },
314
+ { name: '500', hex: '795548' },
315
+ { name: '600', hex: '6D4C41' },
316
+ { name: '700', hex: '5D4037' },
317
+ { name: '800', hex: '4E342E' },
318
+ { name: '900', hex: '3E2723' }
319
+ ]
320
+ }, {
321
+ name: 'Grey',
322
+ camel: 'grey',
323
+ colors: [
324
+ { name: '50', hex: 'FAFAFA' },
325
+ { name: '100', hex: 'F5F5F5' },
326
+ { name: '200', hex: 'EEEEEE' },
327
+ { name: '300', hex: 'E0E0E0' },
328
+ { name: '400', hex: 'BDBDBD' },
329
+ { name: '500', hex: '9E9E9E' },
330
+ { name: '600', hex: '757575' },
331
+ { name: '700', hex: '616161' },
332
+ { name: '800', hex: '424242' },
333
+ { name: '900', hex: '212121' }
334
+ ]
335
+ }, {
336
+ name: 'Blue Grey',
337
+ camel: 'blueGrey',
338
+ colors: [
339
+ { name: '50', hex: 'ECEFF1' },
340
+ { name: '100', hex: 'CFD8DC' },
341
+ { name: '200', hex: 'B0BEC5' },
342
+ { name: '300', hex: '90A4AE' },
343
+ { name: '400', hex: '78909C' },
344
+ { name: '500', hex: '607D8B' },
345
+ { name: '600', hex: '546E7A' },
346
+ { name: '700', hex: '455A64' },
347
+ { name: '800', hex: '37474F' },
348
+ { name: '900', hex: '263238' }
349
+ ]
350
+ }, {
351
+ name: 'Misc',
352
+ camel: '',
353
+ colors: [
354
+ { name: 'white', hex: 'FFFFFF', x: 19, y: 0 },
355
+ { name: 'black', hex: '000000', x: 19, y: 1 }
356
+ ]
357
+ }];
@@ -0,0 +1,3 @@
1
+ import PgColor from './color';
2
+
3
+ export default PgColor;
@@ -0,0 +1,27 @@
1
+ export function hexToRgb(hex): { r: number, g: number, b: number} | null {
2
+ var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
3
+ return result ? {
4
+ r: parseInt(result[1], 16),
5
+ g: parseInt(result[2], 16),
6
+ b: parseInt(result[3], 16)
7
+ } : null;
8
+ };
9
+
10
+ export function normalizeHex(hex: string) {
11
+ const h = hex.toUpperCase();
12
+ if (h.length === 7) {
13
+ return h;
14
+ } else if (h.length === 4) {
15
+ return `#${h[1]}${h[1]}${h[2]}${h[2]}${h[3]}${h[3]}`;
16
+ }
17
+ return '#000000';
18
+ }
19
+
20
+ export function cToHex(c) {
21
+ var hex = c.toString(16);
22
+ return hex.length == 1 ? "0" + hex : hex;
23
+ };
24
+
25
+ export function rgbToHex(r, g, b) {
26
+ return "#" + cToHex(r) + cToHex(g) + cToHex(b);
27
+ };
@@ -0,0 +1,28 @@
1
+ # `<pg-database>`
2
+
3
+ Out of all the components this is the most useful one as it controls the local cache of icon data. From a high level this component gives access to a `DatabaseService` instance.
4
+
5
+ ```typescript
6
+ import '@pictogrammers/components/pgAnnoy.js';
7
+ ```
8
+
9
+ ## Usage
10
+
11
+ | Events | Description |
12
+ | ------ | ----------- |
13
+ | `onsync` | `event = { detail: { db } }` |
14
+ | `onerror` | `event = { detail: { message }}` |
15
+
16
+ > Note: We will try to recover and if there is no way the database is deleted and resynced. Onerror is only called on failure to serialize data not on network issues!
17
+
18
+
19
+ ## Development
20
+
21
+ Understanding the data workflow will give you an idea of all the steps of syncing icon data.
22
+
23
+ ```
24
+ # Set some kind of isLoading
25
+ connect -> data exists
26
+ -> true -> onsync -> sync data -> onsync
27
+ -> sync data -> onsync
28
+ ```
@@ -0,0 +1,9 @@
1
+ <div class="example">
2
+ <pg-database part="database"></pg-database>
3
+ <div>
4
+ Total Icons: <code part="count"></code>
5
+ </div>
6
+ <div>
7
+ Icon Objects: <code part="total"></code>
8
+ </div>
9
+ </div>
@@ -0,0 +1,37 @@
1
+ import { Component, Part, Prop } from '@pictogrammers/element';
2
+ import PgDatabase from 'pg/database/database';
3
+ import { Icon } from '../../../shared/models/icon';
4
+
5
+ import template from './basic.html';
6
+
7
+ @Component({
8
+ selector: 'x-pg-database-basic',
9
+ template
10
+ })
11
+ export default class XPgDatabaseBasic extends HTMLElement {
12
+
13
+ @Prop() fontId = 'D051337E-BC7E-11E5-A4E9-842B2B6CFE1B';
14
+
15
+ @Part() $database: PgDatabase;
16
+
17
+ @Part() $count: HTMLSpanElement;
18
+ @Part() $total: HTMLSpanElement;
19
+
20
+ icons: Icon[] = [];
21
+
22
+ connectedCallback() {
23
+ this.$database.addEventListener('sync', this.handleSync.bind(this));
24
+ this.$database.font = this.fontId;
25
+ }
26
+
27
+ async handleSync(e: CustomEvent) {
28
+ const { db } = e.detail;
29
+ const count = await db.getCount(this.fontId);
30
+ this.$count.innerText = count;
31
+ const icons = await db.getIcons(this.fontId);
32
+ this.$total.innerText = icons.length;
33
+
34
+ // Optionally Cache outide of IndexedDB
35
+ this.icons = icons;
36
+ }
37
+ }
File without changes
File without changes
@@ -0,0 +1,42 @@
1
+ import { Component, Prop, Part } from '@pictogrammers/element';
2
+
3
+ import template from './database.html';
4
+ import style from './database.css';
5
+
6
+ import { DatabaseService } from '../shared/databaseService';
7
+
8
+ const db = new DatabaseService();
9
+
10
+ @Component({
11
+ selector: 'pg-database',
12
+ style,
13
+ template
14
+ })
15
+ export default class PgDatabase extends HTMLElement {
16
+ @Prop() font: string = '';
17
+
18
+ async render() {
19
+ if (this.font !== '') {
20
+ const exists = await db.exists(this.font);
21
+ let delay = true;
22
+ if (exists) {
23
+ this.dispatchEvent(new CustomEvent('sync', {
24
+ detail: {
25
+ db,
26
+ delay
27
+ }
28
+ }));
29
+ }
30
+ const modified = await db.sync(this.font);
31
+ if (modified) {
32
+ delay = false;
33
+ this.dispatchEvent(new CustomEvent('sync', {
34
+ detail: {
35
+ db,
36
+ delay
37
+ }
38
+ }));
39
+ }
40
+ }
41
+ }
42
+ }
@@ -0,0 +1,3 @@
1
+ import PgDatabase from './database';
2
+
3
+ export default PgDatabase;