@pictogrammers/components 0.3.2 → 0.4.0

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 (294) hide show
  1. package/README.md +11 -12
  2. package/favicon.svg +20 -0
  3. package/index.html +67 -49
  4. package/main.js +2 -0
  5. package/main.js.LICENSE.txt +10 -0
  6. package/package.json +6 -6
  7. package/pg/annoy/README.md +0 -5
  8. package/pg/annoy/__examples__/basic/basic.css +3 -0
  9. package/pg/annoy/__examples__/basic/basic.html +4 -7
  10. package/pg/annoy/__examples__/basic/basic.ts +3 -1
  11. package/pg/annoy/annoy.css +29 -198
  12. package/pg/annoy/annoy.html +5 -56
  13. package/pg/annoy/annoy.ts +4 -25
  14. package/pg/app/README.md +11 -0
  15. package/pg/app/__examples__/basic/basic.css +8 -0
  16. package/pg/app/__examples__/basic/basic.html +15 -0
  17. package/pg/app/__examples__/basic/basic.ts +13 -0
  18. package/pg/app/app.css +108 -0
  19. package/pg/app/app.html +16 -0
  20. package/pg/app/app.ts +45 -0
  21. package/pg/app/index.ts +3 -0
  22. package/pg/avatar/__examples__/basic/basic.ts +5 -3
  23. package/pg/button/README.md +3 -0
  24. package/pg/button/button.css +13 -12
  25. package/pg/button/button.spec.ts +35 -0
  26. package/pg/button/button.ts +17 -12
  27. package/pg/buttonLink/buttonLink.css +3 -2
  28. package/pg/buttonMenu/README.md +54 -0
  29. package/pg/buttonMenu/__examples__/basic/basic.html +6 -0
  30. package/pg/buttonMenu/__examples__/basic/basic.ts +43 -0
  31. package/pg/buttonMenu/buttonMenu.css +12 -0
  32. package/pg/buttonMenu/buttonMenu.html +4 -0
  33. package/pg/buttonMenu/buttonMenu.ts +63 -0
  34. package/pg/buttonMenu/index.ts +3 -0
  35. package/pg/buttonToggle/__examples__/basic/basic.ts +2 -2
  36. package/pg/buttonToggle/__examples__/persist/persist.html +10 -0
  37. package/pg/buttonToggle/__examples__/persist/persist.ts +35 -0
  38. package/pg/cardUser/__examples__/basic/basic.ts +0 -1
  39. package/pg/cardUser/cardUser.css +2 -10
  40. package/pg/cardUser/cardUser.html +0 -5
  41. package/pg/cardUser/cardUser.ts +0 -6
  42. package/pg/database/README.md +1 -1
  43. package/pg/database/__examples__/basic/basic.html +2 -1
  44. package/pg/database/__examples__/basic/basic.ts +3 -3
  45. package/pg/dropdown/dropdown.ts +0 -19
  46. package/pg/grid/__examples__/basic/basic.html +2 -2
  47. package/pg/grid/__examples__/basic/basic.ts +3 -2
  48. package/pg/grid/grid.ts +0 -1
  49. package/pg/icon/README.md +6 -5
  50. package/pg/icon/__examples__/basic/basic.html +2 -2
  51. package/pg/icon/__examples__/basic/basic.ts +1 -1
  52. package/pg/icon/icon.ts +6 -0
  53. package/pg/inputCheckList/__examples__/basic/basic.ts +5 -5
  54. package/pg/inputCheckList/inputCheckList.ts +2 -0
  55. package/pg/inputFileLocal/inputFileLocal.css +3 -2
  56. package/pg/inputPixelEditor/README.md +132 -0
  57. package/pg/inputPixelEditor/__examples__/basic/basic.css +29 -0
  58. package/pg/inputPixelEditor/__examples__/basic/basic.html +63 -0
  59. package/pg/inputPixelEditor/__examples__/basic/basic.ts +200 -0
  60. package/pg/inputPixelEditor/__examples__/basic/openUtils.ts +41 -0
  61. package/pg/inputPixelEditor/__examples__/basic/saveUtil.ts +35 -0
  62. package/pg/inputPixelEditor/index.ts +3 -0
  63. package/pg/inputPixelEditor/inputPixelEditor.css +27 -0
  64. package/pg/inputPixelEditor/inputPixelEditor.html +3 -0
  65. package/pg/inputPixelEditor/inputPixelEditor.ts +839 -0
  66. package/pg/inputPixelEditor/utils/bitmapToMask.ts +202 -0
  67. package/pg/inputPixelEditor/utils/cloneGrid.ts +17 -0
  68. package/pg/inputPixelEditor/utils/constants.ts +1 -0
  69. package/pg/inputPixelEditor/utils/createLayer.ts +8 -0
  70. package/pg/inputPixelEditor/utils/debounce.ts +5 -0
  71. package/pg/inputPixelEditor/utils/diffGrid.ts +26 -0
  72. package/pg/inputPixelEditor/utils/fillGrid.ts +11 -0
  73. package/pg/inputPixelEditor/utils/getEllipseOutlinePixels.ts +105 -0
  74. package/pg/inputPixelEditor/utils/getEllipsePixels.ts +28 -0
  75. package/pg/inputPixelEditor/utils/getGuides.ts +232 -0
  76. package/pg/inputPixelEditor/utils/getLinePixels.ts +18 -0
  77. package/pg/inputPixelEditor/utils/getRectangleOutlinePixels.ts +20 -0
  78. package/pg/inputPixelEditor/utils/getRectanglePixels.ts +15 -0
  79. package/pg/inputPixelEditor/utils/inputMode.ts +8 -0
  80. package/pg/inputPixelEditor/utils/interateGrid.ts +7 -0
  81. package/pg/inputPixelEditor/utils/isEmptyGrid.ts +3 -0
  82. package/pg/inputPixelEditor/utils/maskToBitmap.ts +66 -0
  83. package/pg/inputRange/__examples__/basic/basic.ts +4 -4
  84. package/pg/inputRange/inputRange.ts +6 -4
  85. package/pg/inputSelect/README.md +1 -1
  86. package/pg/inputSelect/__examples__/basic/basic.ts +7 -5
  87. package/pg/inputSelect/inputSelect.css +15 -12
  88. package/pg/inputSelect/inputSelect.html +3 -3
  89. package/pg/inputSelect/inputSelect.ts +33 -30
  90. package/pg/inputText/__examples__/basic/basic.ts +6 -6
  91. package/pg/inputText/inputText.css +1 -0
  92. package/pg/inputUserSelect/README.md +1 -1
  93. package/pg/inputUserSelect/inputUserSelect.ts +1 -1
  94. package/pg/listTag/__examples__/basic/basic.ts +4 -5
  95. package/pg/markdown/README.md +17 -3
  96. package/pg/markdown/__examples__/basic/basic.ts +2 -2
  97. package/pg/markdown/__examples__/basic/constants.ts +1 -1
  98. package/pg/markdown/markdown.css +11 -0
  99. package/pg/menu/README.md +46 -0
  100. package/pg/menu/__examples__/basic/basic.html +6 -0
  101. package/pg/menu/__examples__/basic/basic.ts +46 -0
  102. package/pg/menu/index.ts +3 -0
  103. package/pg/menu/menu.css +19 -0
  104. package/pg/menu/menu.html +1 -0
  105. package/pg/menu/menu.ts +119 -0
  106. package/pg/menuDivider/README.md +7 -0
  107. package/pg/menuDivider/__examples__/basic/basic.html +3 -0
  108. package/pg/menuDivider/__examples__/basic/basic.ts +28 -0
  109. package/pg/menuDivider/index.ts +3 -0
  110. package/pg/menuDivider/menuDivider.css +9 -0
  111. package/pg/menuDivider/menuDivider.html +1 -0
  112. package/pg/menuDivider/menuDivider.ts +22 -0
  113. package/pg/menuIcon/menuIcon.ts +43 -36
  114. package/pg/menuItem/README.md +32 -0
  115. package/pg/menuItem/__examples__/basic/basic.html +26 -0
  116. package/pg/menuItem/__examples__/basic/basic.ts +41 -0
  117. package/pg/menuItem/index.ts +3 -0
  118. package/pg/menuItem/menuItem.css +97 -0
  119. package/pg/menuItem/menuItem.html +1 -0
  120. package/pg/menuItem/menuItem.ts +77 -0
  121. package/pg/menuItemIcon/README.md +32 -0
  122. package/pg/menuItemIcon/__examples__/basic/basic.html +34 -0
  123. package/pg/menuItemIcon/__examples__/basic/basic.ts +55 -0
  124. package/pg/menuItemIcon/index.ts +3 -0
  125. package/pg/menuItemIcon/menuItemIcon.css +106 -0
  126. package/pg/menuItemIcon/menuItemIcon.html +4 -0
  127. package/pg/menuItemIcon/menuItemIcon.ts +156 -0
  128. package/pg/modalAlert/__examples__/basic/basic.ts +1 -1
  129. package/pg/modalAlert/modalAlert.css +1 -4
  130. package/pg/modalAlert/modalAlert.ts +18 -4
  131. package/pg/modification/__examples__/basic/basic.ts +1 -2
  132. package/pg/modification/__examples__/basic/constants.ts +25 -50
  133. package/pg/modification/modification.ts +1 -1
  134. package/pg/overlay/overlay.ts +13 -12
  135. package/pg/overlayContextMenu/README.md +35 -0
  136. package/pg/overlayContextMenu/__examples__/basic/basic.css +23 -0
  137. package/pg/overlayContextMenu/__examples__/basic/basic.html +7 -0
  138. package/pg/overlayContextMenu/__examples__/basic/basic.ts +87 -0
  139. package/pg/overlayContextMenu/index.ts +3 -0
  140. package/pg/overlayContextMenu/overlayContextMenu.css +16 -0
  141. package/pg/overlayContextMenu/overlayContextMenu.html +3 -0
  142. package/pg/overlayContextMenu/overlayContextMenu.ts +98 -0
  143. package/pg/overlayMenu/README.md +33 -0
  144. package/pg/overlayMenu/__examples__/basic/basic.css +3 -0
  145. package/pg/overlayMenu/__examples__/basic/basic.html +5 -0
  146. package/pg/overlayMenu/__examples__/basic/basic.ts +62 -0
  147. package/pg/overlayMenu/index.ts +3 -0
  148. package/pg/overlayMenu/overlayMenu.css +16 -0
  149. package/pg/overlayMenu/overlayMenu.html +3 -0
  150. package/pg/overlayMenu/overlayMenu.ts +67 -0
  151. package/pg/overlaySelectMenu/README.md +33 -0
  152. package/pg/overlaySelectMenu/__examples__/basic/basic.css +3 -0
  153. package/pg/overlaySelectMenu/__examples__/basic/basic.html +5 -0
  154. package/pg/overlaySelectMenu/__examples__/basic/basic.ts +62 -0
  155. package/pg/overlaySelectMenu/index.ts +3 -0
  156. package/pg/overlaySelectMenu/overlaySelectMenu.css +17 -0
  157. package/pg/overlaySelectMenu/overlaySelectMenu.html +3 -0
  158. package/pg/overlaySelectMenu/overlaySelectMenu.ts +96 -0
  159. package/pg/overlaySubMenu/README.md +35 -0
  160. package/pg/overlaySubMenu/index.ts +3 -0
  161. package/pg/overlaySubMenu/overlaySubMenu.css +27 -0
  162. package/pg/overlaySubMenu/overlaySubMenu.html +3 -0
  163. package/pg/overlaySubMenu/overlaySubMenu.ts +103 -0
  164. package/pg/picker/picker.ts +1 -19
  165. package/pg/scroll/__examples__/basic/basic.ts +1 -1
  166. package/pg/search/__examples__/basic/basic.ts +10 -7
  167. package/pg/search/search.css +2 -2
  168. package/pg/shared/models/user.ts +0 -2
  169. package/pg/tab/tab.ts +0 -10
  170. package/pg/tabs/partials/tab.css +42 -0
  171. package/pg/tabs/partials/tab.ts +70 -0
  172. package/pg/tabs/tabs.css +0 -53
  173. package/pg/tabs/tabs.ts +54 -70
  174. package/pg/toast/README.md +35 -6
  175. package/pg/toast/__examples__/basic/basic.html +7 -0
  176. package/pg/toast/__examples__/basic/basic.ts +76 -0
  177. package/pg/toast/toast.css +3 -0
  178. package/pg/toast/toast.ts +20 -4
  179. package/pg/tooltip/addTooltip.ts +3 -1
  180. package/pg/tooltip/tooltip.ts +1 -1
  181. package/pg/tree/README.md +67 -0
  182. package/pg/tree/__examples__/basic/basic.html +10 -0
  183. package/pg/tree/__examples__/basic/basic.ts +162 -0
  184. package/pg/tree/index.ts +3 -0
  185. package/pg/tree/tree.css +28 -0
  186. package/pg/tree/tree.html +1 -0
  187. package/pg/tree/tree.ts +217 -0
  188. package/pg/treeButtonIcon/README.md +39 -0
  189. package/pg/treeButtonIcon/index.ts +3 -0
  190. package/pg/treeButtonIcon/treeButtonIcon.css +18 -0
  191. package/pg/treeButtonIcon/treeButtonIcon.html +3 -0
  192. package/pg/treeButtonIcon/treeButtonIcon.ts +42 -0
  193. package/pg/treeItem/README.md +3 -0
  194. package/pg/treeItem/index.ts +3 -0
  195. package/pg/treeItem/treeItem.css +263 -0
  196. package/pg/treeItem/treeItem.html +16 -0
  197. package/pg/treeItem/treeItem.ts +558 -0
  198. package/pgAnnoy.js +1 -0
  199. package/pgApp.js +1 -0
  200. package/pgAvatar.js +1 -0
  201. package/pgButton.js +1 -0
  202. package/pgButtonGroup.js +1 -0
  203. package/pgButtonLink.js +1 -0
  204. package/pgButtonMenu.js +1 -0
  205. package/pgButtonToggle.js +1 -0
  206. package/pgCard.js +1 -0
  207. package/pgCardUser.js +1 -0
  208. package/pgColor.js +1 -0
  209. package/pgDatabase.js +1 -0
  210. package/pgDropdown.js +1 -0
  211. package/pgGrid.js +1 -0
  212. package/pgHeader.js +1 -0
  213. package/pgIcon.js +1 -0
  214. package/pgInputCheck.js +1 -0
  215. package/pgInputCheckList.js +1 -0
  216. package/pgInputFileLocal.js +1 -0
  217. package/pgInputHexRgb.js +1 -0
  218. package/pgInputPixelEditor.js +1 -0
  219. package/pgInputRange.js +1 -0
  220. package/pgInputSelect.js +1 -0
  221. package/pgInputText.js +1 -0
  222. package/pgInputTextIcon.js +1 -0
  223. package/pgInputUserSelect.js +1 -0
  224. package/pgListTag.js +1 -0
  225. package/pgMarkdown.js +2 -0
  226. package/pgMarkdown.js.LICENSE.txt +10 -0
  227. package/pgMenu.js +1 -0
  228. package/pgMenuDivider.js +1 -0
  229. package/pgMenuIcon.js +1 -0
  230. package/pgMenuItem.js +1 -0
  231. package/pgMenuItemIcon.js +1 -0
  232. package/pgModalAlert.js +1 -0
  233. package/pgModification.js +1 -0
  234. package/pgNav.js +1 -0
  235. package/pgOverlay.js +1 -0
  236. package/pgOverlayContextMenu.js +1 -0
  237. package/pgOverlayMenu.js +1 -0
  238. package/pgOverlaySelectMenu.js +1 -0
  239. package/pgOverlaySubMenu.js +1 -0
  240. package/pgPicker.js +1 -0
  241. package/pgPreview.js +1 -0
  242. package/pgScroll.js +1 -0
  243. package/pgSearch.js +1 -0
  244. package/pgTab.js +1 -0
  245. package/pgTabs.js +1 -0
  246. package/pgToast.js +1 -0
  247. package/pgToasts.js +1 -0
  248. package/pgTooltip.js +1 -0
  249. package/pgTree.js +1 -0
  250. package/pgTreeButtonIcon.js +1 -0
  251. package/pgTreeItem.js +1 -0
  252. package/theme-ui3.css +31 -0
  253. package/@types/css.d.ts +0 -4
  254. package/@types/html.d.ts +0 -4
  255. package/dist/main.js +0 -3819
  256. package/dist/pgAnnoy.js +0 -116
  257. package/dist/pgAvatar.js +0 -136
  258. package/dist/pgButton.js +0 -116
  259. package/dist/pgButtonGroup.js +0 -116
  260. package/dist/pgButtonLink.js +0 -116
  261. package/dist/pgButtonToggle.js +0 -146
  262. package/dist/pgCard.js +0 -116
  263. package/dist/pgCardUser.js +0 -196
  264. package/dist/pgColor.js +0 -136
  265. package/dist/pgDatabase.js +0 -236
  266. package/dist/pgDropdown.js +0 -686
  267. package/dist/pgGrid.js +0 -126
  268. package/dist/pgHeader.js +0 -116
  269. package/dist/pgIcon.js +0 -116
  270. package/dist/pgInputCheck.js +0 -116
  271. package/dist/pgInputCheckList.js +0 -126
  272. package/dist/pgInputFileLocal.js +0 -116
  273. package/dist/pgInputHexRgb.js +0 -126
  274. package/dist/pgInputRange.js +0 -116
  275. package/dist/pgInputSelect.js +0 -116
  276. package/dist/pgInputText.js +0 -116
  277. package/dist/pgInputTextIcon.js +0 -176
  278. package/dist/pgInputUserSelect.js +0 -116
  279. package/dist/pgListTag.js +0 -136
  280. package/dist/pgMarkdown.js +0 -346
  281. package/dist/pgMenuIcon.js +0 -206
  282. package/dist/pgModalAlert.js +0 -126
  283. package/dist/pgModification.js +0 -396
  284. package/dist/pgNav.js +0 -116
  285. package/dist/pgOverlay.js +0 -96
  286. package/dist/pgPicker.js +0 -116
  287. package/dist/pgPreview.js +0 -116
  288. package/dist/pgScroll.js +0 -266
  289. package/dist/pgSearch.js +0 -146
  290. package/dist/pgTab.js +0 -116
  291. package/dist/pgTabs.js +0 -136
  292. package/dist/pgToast.js +0 -136
  293. package/dist/pgToasts.js +0 -136
  294. package/dist/pgTooltip.js +0 -126
package/pg/app/app.ts ADDED
@@ -0,0 +1,45 @@
1
+ import { Component, Part, Prop } from '@pictogrammers/element';
2
+
3
+ import template from './app.html';
4
+ import style from './app.css';
5
+
6
+ @Component({
7
+ selector: 'pg-app',
8
+ style,
9
+ template
10
+ })
11
+ export default class PgApp extends HTMLElement {
12
+ @Part() $logo: HTMLButtonElement;
13
+ @Part() $home: HTMLDivElement;
14
+ @Part() $side: HTMLDivElement;
15
+ @Part() $resize: HTMLButtonElement;
16
+
17
+ connectedCallback() {
18
+ this.$logo.addEventListener('click', this.#handleClick.bind(this));
19
+ this.$resize.addEventListener('pointerdown', this.#handlePointerDown.bind(this));
20
+ }
21
+
22
+ #handleClick() {
23
+ this.$logo.classList.toggle('selected');
24
+ this.$home.classList.toggle('hide');
25
+ }
26
+
27
+ #handlePointerDown(e: PointerEvent) {
28
+ const { clientX } = e;
29
+ this.$resize.classList.add('dragging');
30
+ const currentWidth = this.$side.getBoundingClientRect().width;
31
+ let currentX = clientX;
32
+ const handlePointerMove = (ee: PointerEvent) => {
33
+ const x = currentX - ee.clientX;
34
+ const width = currentWidth - x;
35
+ this.$side.style.width = `${width}px`;
36
+ }
37
+ const handlePointerUp = () => {
38
+ this.$resize.classList.remove('dragging');
39
+ document.removeEventListener('pointermove', handlePointerMove);
40
+ document.removeEventListener('pointerup', handlePointerUp);
41
+ }
42
+ document.addEventListener('pointermove', handlePointerMove);
43
+ document.addEventListener('pointerup', handlePointerUp);
44
+ }
45
+ }
@@ -0,0 +1,3 @@
1
+ import PgApp from './app';
2
+
3
+ export default PgApp;
@@ -33,9 +33,11 @@ export default class XPgAvatarBasic extends HTMLElement {
33
33
  handleTooltip(e) {
34
34
  const { visible, rect, text, position } = e.detail;
35
35
  this.$tooltip.visible = visible;
36
- this.$tooltip.rect = rect;
37
- this.$tooltip.text = text;
38
- this.$tooltip.position = position;
36
+ if (visible) {
37
+ this.$tooltip.rect = rect;
38
+ this.$tooltip.text = text;
39
+ this.$tooltip.position = position;
40
+ }
39
41
  e.stopPropagation();
40
42
  }
41
43
  }
@@ -38,6 +38,9 @@ import PgButton from '@pictogrammers/components/pg/button';
38
38
  | `--pg-button-active-color` | `#fff` | `active` Text color |
39
39
  | `--pg-button-active-background-color` | `#453C4F` | `active` Background color |
40
40
  | `--pg-button-active-border-color` | `#453C4F` | `active` Border color |
41
+ | `--pg-button-padding` | `0.25rem 0.5rem` | Padding. |
42
+ | `--pg-button-font-size` | `1rem` | Font size. |
43
+ | `--pg-button-line-height` | `1.5rem` | Line height. |
41
44
 
42
45
  ### Slots
43
46
 
@@ -1,19 +1,19 @@
1
1
  :host {
2
- display: flex;
2
+ display: contents;
3
3
  }
4
4
 
5
5
  [part="button"] {
6
- display: inline-flex;
6
+ display: flex;
7
7
  align-items: center;
8
8
  align-content: center;
9
9
  font-family: var(--pg-font-family);
10
- font-size: 1rem;
11
- line-height: 1.5rem;
10
+ font-size: var(--pg-button-font-size, 1rem);
11
+ line-height: var(--pg-button-line-height, 1.5rem);
12
12
  border: 1px solid var(--pg-button-border-color, #453C4F);
13
- background-color: var(--pg-button-background-color, #fff);
13
+ background-color: var(--pg-button-background-color, #FFFFFF);
14
14
  color: var(--pg-button-color, #453C4F);
15
15
  padding: var(--pg-button-padding, 0.25rem 0.5rem);
16
- border-radius: 0.25rem;
16
+ border-radius: var(--pg-button-border-radius, 0.25rem);
17
17
  outline: none;
18
18
  --pg-icon-color: var(--pg-button-color, #453C4F);
19
19
  }
@@ -21,8 +21,8 @@
21
21
  [part="button"]:hover {
22
22
  border: 1px solid var(--pg-button-hover-border-color, #453C4F);
23
23
  background-color: var(--pg-button-hover-background-color, #453C4F);
24
- color: var(--pg-button-hover-color, #fff);
25
- --pg-icon-color: var(--pg-button-hover-color, #fff);
24
+ color: var(--pg-button-hover-color, #FFFFFF);
25
+ --pg-icon-color: var(--pg-button-hover-color, #FFFFFF);
26
26
  }
27
27
 
28
28
  [part="button"]:active {
@@ -41,18 +41,19 @@
41
41
  right: -1px;
42
42
  bottom: -1px;
43
43
  left: -1px;
44
- border-radius: 0.25rem;
45
- box-shadow: 0 0 0 3px var(--pg-search-focus-glow, rgb(79, 143, 249, 0.6));
44
+ border-radius: var(--pg-button-border-radius, 0.25rem);
45
+ box-shadow: 0 0 0 3px var(--pg-focus-color, rgb(79, 143, 249, 0.6));
46
46
  }
47
47
  [part="button"]:focus::before {
48
+ pointer-events: none;
48
49
  content: '';
49
50
  position: absolute;
50
51
  top: -1px;
51
52
  right: -1px;
52
53
  bottom: -1px;
53
54
  left: -1px;
54
- border-radius: 0.25rem;
55
- box-shadow: 0 0 0 3px var(--pg-search-focus-glow, rgb(79, 143, 249, 0.5));
55
+ border-radius: var(--pg-button-border-radius, 0.25rem);
56
+ box-shadow: 0 0 0 3px var(--pg-focus-color, rgb(79, 143, 249, 0.5));
56
57
  }
57
58
 
58
59
  [part="button"].start {
@@ -0,0 +1,35 @@
1
+ import { selectComponent, getProps } from '@pictogrammers/element';
2
+
3
+ import './button';
4
+ import PgButton from './button';
5
+
6
+ const PG_BUTTON = 'pg-button';
7
+
8
+ describe('pg-button', () => {
9
+
10
+ beforeEach(() => {
11
+ var c = document.createElement(PG_BUTTON);
12
+ document.body.appendChild(c);
13
+ });
14
+
15
+ afterEach(() => {
16
+ while (document.body.firstChild) {
17
+ document.body.removeChild(document.body.firstChild);
18
+ }
19
+ });
20
+
21
+ it('should be registered', () => {
22
+ expect(customElements.get(PG_BUTTON)).toBeDefined();
23
+ });
24
+
25
+ it('should only expose known props', () => {
26
+ const props = getProps(PG_BUTTON);
27
+ expect(props.length).toBe(5);
28
+ expect(props).toContain('active');
29
+ expect(props).toContain('block');
30
+ expect(props).toContain('start');
31
+ expect(props).toContain('center');
32
+ expect(props).toContain('end');
33
+ });
34
+
35
+ });
@@ -1,4 +1,4 @@
1
- import { Component, Part, Prop } from '@pictogrammers/element';
1
+ import { Component, Part, Prop, normalizeBoolean } from '@pictogrammers/element';
2
2
 
3
3
  import template from './button.html';
4
4
  import style from './button.css';
@@ -9,13 +9,15 @@ import style from './button.css';
9
9
  template
10
10
  })
11
11
  export default class PgButton extends HTMLElement {
12
- @Prop() active: string | boolean = false;
13
- @Prop() block: string | boolean = false;
14
- @Prop() start: string | boolean = false;
15
- @Prop() center: string | boolean = false;
16
- @Prop() end: string | boolean = false;
12
+ @Prop(normalizeBoolean) active: boolean = false;
13
+ @Prop(normalizeBoolean) block: boolean = false;
14
+ @Prop(normalizeBoolean) start: boolean = false;
15
+ @Prop(normalizeBoolean) center: boolean = false;
16
+ @Prop(normalizeBoolean) end: boolean = false;
17
17
 
18
18
  @Part() $button: HTMLButtonElement;
19
+ @Part() $number: HTMLSpanElement;
20
+ @Part() $bar: HTMLSpanElement;
19
21
 
20
22
  connectedCallback() {
21
23
  this.$button.addEventListener('click', (e) => {
@@ -25,21 +27,24 @@ export default class PgButton extends HTMLElement {
25
27
  }
26
28
 
27
29
  render(changes) {
28
- const t = [true, 'true', ''];
29
30
  if (changes.active) {
30
- this.$button.classList.toggle('active', t.includes(this.active));
31
+ this.$button.classList.toggle('active', this.active);
31
32
  }
32
33
  if (changes.start) {
33
- this.$button.classList.toggle('start', t.includes(this.start));
34
+ this.$button.classList.toggle('start', this.start);
34
35
  }
35
36
  if (changes.end) {
36
- this.$button.classList.toggle('end', t.includes(this.end));
37
+ this.$button.classList.toggle('end', this.end);
37
38
  }
38
39
  if (changes.center) {
39
- this.$button.classList.toggle('center', t.includes(this.center));
40
+ this.$button.classList.toggle('center', this.center);
40
41
  }
41
42
  if (changes.block) {
42
- this.$button.classList.toggle('block', t.includes(this.block));
43
+ this.$button.classList.toggle('block', this.block);
43
44
  }
44
45
  }
46
+
47
+ getBoundingClientRect(): DOMRect {
48
+ return this.$button.getBoundingClientRect();
49
+ }
45
50
  }
@@ -46,9 +46,10 @@
46
46
  bottom: -1px;
47
47
  left: -1px;
48
48
  border-radius: 0.25rem;
49
- box-shadow: 0 0 0 3px var(--pg-search-focus-glow, rgb(79, 143, 249, 0.6));
49
+ box-shadow: 0 0 0 3px var(--pg-focus-color, rgb(79, 143, 249, 0.6));
50
50
  }
51
51
  [part="button"]:focus::before {
52
+ pointer-events: none;
52
53
  content: '';
53
54
  position: absolute;
54
55
  top: -1px;
@@ -56,7 +57,7 @@
56
57
  bottom: -1px;
57
58
  left: -1px;
58
59
  border-radius: 0.25rem;
59
- box-shadow: 0 0 0 3px var(--pg-search-focus-glow, rgb(79, 143, 249, 0.5));
60
+ box-shadow: 0 0 0 3px var(--pg-focus-color, rgb(79, 143, 249, 0.5));
60
61
  }
61
62
 
62
63
  [part="button"].start {
@@ -0,0 +1,54 @@
1
+ # `<pg-button-toggle>`
2
+
3
+ The `pg-button-toggle` component is essentially just a button with swappable slotted content. Commonly used with icons, but using `span` elements will allow assigning text content.
4
+
5
+ ```typescript
6
+ import '@pictogrammers/components/pg/buttonToggle';
7
+ import PgButtonToggle from '@pictogrammers/components/pg/buttonToggle';
8
+ ```
9
+
10
+ ```html
11
+ <pg-button-toggle>
12
+ <pg-icon slot="active" path="M...Z"></pg-icon>
13
+ <pg-icon slot="inactive" path="M...Z"></pg-icon>
14
+ </pg-button-toggle>
15
+ ```
16
+
17
+ | Slots | Tested | Description |
18
+ | ----------- | -------- | ----------- |
19
+ | default | &#x2705; | Button contents. |
20
+
21
+ | Attribute | Tested | Description |
22
+ | ---------- | -------- | ----------- |
23
+ | block | | block sizing |
24
+ | active | | Depressed visual state. |
25
+ | start | | Internal Only |
26
+ | end | | Internal Only |
27
+ | center | | Internal Only |
28
+
29
+ | Events | Tested | Description |
30
+ | ---------- | -------- | ----------- |
31
+ | click | &#x2705; | Standard click. |
32
+
33
+ | CSS Variables | Default | Description |
34
+ | ------------------- | --------- | ----------- |
35
+ | `--pg-button-color` | `#453C4F` | Text color |
36
+ | `--pg-button-background-color` | `#fff` | Background color |
37
+ | `--pg-button-border-color` | `#453C4F` | Border color |
38
+ | `--pg-button-hover-color` | `#fff` | `:hover` Text color |
39
+ | `--pg-button-hover-background-color` | `#453C4F` | `:hover` Background color |
40
+ | `--pg-button-hover-border-color` | `#453C4F` | `:hover` Border color |
41
+ | `--pg-button-active-color` | `#fff` | `active` Text color |
42
+ | `--pg-button-active-background-color` | `#453C4F` | `active` Background color |
43
+ | `--pg-button-active-border-color` | `#453C4F` | `active` Border color |
44
+
45
+ ### Slots
46
+
47
+ Special styling is applied for `pg-icon`.
48
+
49
+ ```html
50
+ <pg-button-toggle>
51
+ <pg-icon slot="active" path="M...Z"></pg-icon>
52
+ <pg-icon slot="inactive" path="M...Z"></pg-icon>
53
+ </pg-button-toggle>
54
+ ```
@@ -0,0 +1,6 @@
1
+ <div class="example">
2
+ <pg-button-menu part="menu"></pg-button-menu>
3
+ <div>
4
+ <code>value: <code part="value"></code></code>
5
+ </div>
6
+ </div>
@@ -0,0 +1,43 @@
1
+ import { Component, Part } from '@pictogrammers/element';
2
+ import PgButtonMenu from '../../buttonMenu';
3
+ import PgMenuItemIcon from '../../../menuItemIcon/menuItemIcon';
4
+
5
+ import template from './basic.html';
6
+
7
+ const IconAccount = 'M12,4A4,4 0 0,1 16,8A4,4 0 0,1 12,12A4,4 0 0,1 8,8A4,4 0 0,1 12,4M12,14C16.42,14 20,15.79 20,18V20H4V18C4,15.79 7.58,14 12,14Z';
8
+
9
+ @Component({
10
+ selector: 'x-pg-button-menu-basic',
11
+ template
12
+ })
13
+ export default class XPgButtonMenuBasic extends HTMLElement {
14
+
15
+ @Part() $menu: PgButtonMenu;
16
+ @Part() $value: HTMLSpanElement;
17
+
18
+ connectedCallback() {
19
+ this.$menu.label = 'Options';
20
+ this.$menu.items = [{
21
+ value: 'item1',
22
+ label: 'Item 1',
23
+ icon: IconAccount,
24
+ type: PgMenuItemIcon,
25
+ items: [{
26
+ value: 'subitem1',
27
+ label: 'Sub Item 1',
28
+ icon: IconAccount,
29
+ type: PgMenuItemIcon
30
+ }]
31
+ }, {
32
+ value: 'item2',
33
+ label: 'Item 2'
34
+ }];
35
+ this.$menu.value = this.$menu.items[0];
36
+ this.$menu.addEventListener('change', this.handleChange.bind(this));
37
+ }
38
+
39
+ handleChange(e: any) {
40
+ const { active } = e.detail;
41
+ this.$value.textContent = `${active}`;
42
+ }
43
+ }
@@ -0,0 +1,12 @@
1
+ :host {
2
+ display: inline-flex;
3
+ }
4
+
5
+ span {
6
+ align-self: center;
7
+ display: flex;
8
+ }
9
+
10
+ [part=collapse] {
11
+ display: none;
12
+ }
@@ -0,0 +1,4 @@
1
+ <pg-button part="button">
2
+ <span part="label"></span>
3
+ <pg-icon part="icon" path="M7.41,8.58L12,13.17L16.59,8.58L18,10L12,16L6,10L7.41,8.58Z"></pg-icon>
4
+ </pg-button>
@@ -0,0 +1,63 @@
1
+ import { Component, Part, Prop } from '@pictogrammers/element';
2
+
3
+ import PgMenuItem from '../menuItem/menuItem';
4
+ import PgIcon from '../icon/icon';
5
+ import PgOverlayMenu from '../overlayMenu/overlayMenu';
6
+
7
+ import '../button/button';
8
+ import PgButton from '../button/button';
9
+
10
+ import template from './buttonMenu.html';
11
+ import style from './buttonMenu.css';
12
+
13
+ const IconExpand = 'M7.41,8.58L12,13.17L16.59,8.58L18,10L12,16L6,10L7.41,8.58Z';
14
+ const IconCollapse = 'M7.41,15.41L12,10.83L16.59,15.41L18,14L12,8L6,14L7.41,15.41Z';
15
+
16
+ @Component({
17
+ selector: 'pg-button-menu',
18
+ style,
19
+ template
20
+ })
21
+ export default class PgButtonMenu extends HTMLElement {
22
+ @Prop() items: any[] = [];
23
+ @Prop() value: any = null;
24
+ @Prop() label: string = '';
25
+ @Prop() default: any = null;
26
+
27
+ @Part() $button: PgButton;
28
+ @Part() $icon: PgIcon;
29
+ @Part() $label: HTMLSpanElement;
30
+
31
+ connectedCallback() {
32
+ this.$button.addEventListener('click', this.#handleClick.bind(this));
33
+ }
34
+
35
+ render(changes) {
36
+ if (changes.label) {
37
+ this.$label.textContent = this.label;
38
+ }
39
+ }
40
+
41
+ #menuOpen = false;
42
+ async #handleClick() {
43
+ this.#menuOpen = !this.#menuOpen;
44
+ this.$icon.path = this.#menuOpen ? IconCollapse : IconExpand;
45
+ if (!this.#menuOpen) { return; }
46
+ // Create Menu
47
+ const result = await PgOverlayMenu.open({
48
+ source: this,
49
+ default: this.default ?? this.items[0],
50
+ value: this.items.find(x => x.value === this.value) ?? null,
51
+ items: this.items
52
+ });
53
+ this.$icon.path = IconExpand;
54
+ if (result !== undefined) {
55
+ this.dispatchEvent(new CustomEvent('change', {
56
+ detail: {
57
+ value: result.value
58
+ }
59
+ }));
60
+ }
61
+ this.#menuOpen = false;
62
+ }
63
+ }
@@ -0,0 +1,3 @@
1
+ import PgButtonMenu from './buttonMenu';
2
+
3
+ export default PgButtonMenu;
@@ -1,4 +1,4 @@
1
- import { Component, Part, Prop } from '@pictogrammers/element';
1
+ import { Component, Part } from '@pictogrammers/element';
2
2
  import PgButtonToggle from '../../buttonToggle';
3
3
 
4
4
  import template from './basic.html';
@@ -18,6 +18,6 @@ export default class XPgButtonToggleBasic extends HTMLElement {
18
18
 
19
19
  handleClick(e) {
20
20
  const { active } = e.detail;
21
- this.$value.innerText = `${active}`;
21
+ this.$value.textContent = `${active}`;
22
22
  }
23
23
  }
@@ -0,0 +1,10 @@
1
+ <div class="example">
2
+ <p>click to toggle and persist state in LocalStorage</p>
3
+ <pg-button-toggle part="button">
4
+ <pg-icon slot="inactive" path="M7.41,8.58L12,13.17L16.59,8.58L18,10L12,16L6,10L7.41,8.58Z"></pg-icon>
5
+ <pg-icon slot="active" path="M7.41,15.41L12,10.83L16.59,15.41L18,14L12,8L6,14L7.41,15.41Z"></pg-icon>
6
+ </pg-button-toggle>
7
+ <div>
8
+ <code>button onclick: <code part="value"></code></code>
9
+ </div>
10
+ </div>
@@ -0,0 +1,35 @@
1
+ import { Component, Local, Part } from '@pictogrammers/element';
2
+ import PgButtonToggle from '../../buttonToggle';
3
+
4
+ import template from './persist.html';
5
+
6
+ @Component({
7
+ selector: 'x-pg-button-toggle-persist',
8
+ template
9
+ })
10
+ export default class XPgButtonTogglePersist extends HTMLElement {
11
+
12
+ @Part() $button: PgButtonToggle;
13
+ @Part() $value: HTMLSpanElement;
14
+
15
+ // Get shared example store
16
+ @Local('example') #store = new Map<string, any>([
17
+ // example:toggle defaults to false
18
+ ['toggle', false]
19
+ ]);
20
+
21
+ connectedCallback() {
22
+ // replace with toggle event??? and throw for click events
23
+ this.$button.addEventListener('click', this.#handleClick.bind(this));
24
+ if (this.#store.get('toggle')) {
25
+ this.$button.active = true;
26
+ this.$value.textContent = 'true';
27
+ }
28
+ }
29
+
30
+ #handleClick(e: any) {
31
+ const { active } = e.detail;
32
+ this.$value.textContent = `${active}`;
33
+ this.#store.set('toggle', active);
34
+ }
35
+ }
@@ -20,7 +20,6 @@ export default class XPgCardUserBasic extends HTMLElement {
20
20
  "description": "Hello, I am a developer that gets bored and makes icons, then websites for icons, then more icons. Open Source is pretty awesome.",
21
21
  "base64": AVATAR,
22
22
  "github": "Templarian",
23
- "twitter": "Templarian",
24
23
  "iconCount": 928,
25
24
  "website": "http:\/\/templarian.com",
26
25
  "sponsored": true,
@@ -43,8 +43,7 @@
43
43
  font-weight: bold;
44
44
  }
45
45
 
46
- [part="github"] svg,
47
- [part="twitter"] svg {
46
+ [part="github"] svg {
48
47
  width: 1.5rem;
49
48
  height: 1.5rem;
50
49
  }
@@ -55,13 +54,6 @@
55
54
  color: #333;
56
55
  }
57
56
 
58
- [part="twitter"] {
59
- grid-row: 2;
60
- grid-column: 3;
61
- color: #333;
62
- }
63
-
64
- [part="github"]:hover,
65
- [part="twitter"]:hover {
57
+ [part="github"]:hover {
66
58
  color: #4f8ff9;
67
59
  }
@@ -14,10 +14,5 @@
14
14
  <path fill="currentColor" d="M12,2A10,10 0 0,0 2,12C2,16.42 4.87,20.17 8.84,21.5C9.34,21.58 9.5,21.27 9.5,21C9.5,20.77 9.5,20.14 9.5,19.31C6.73,19.91 6.14,17.97 6.14,17.97C5.68,16.81 5.03,16.5 5.03,16.5C4.12,15.88 5.1,15.9 5.1,15.9C6.1,15.97 6.63,16.93 6.63,16.93C7.5,18.45 8.97,18 9.54,17.76C9.63,17.11 9.89,16.67 10.17,16.42C7.95,16.17 5.62,15.31 5.62,11.5C5.62,10.39 6,9.5 6.65,8.79C6.55,8.54 6.2,7.5 6.75,6.15C6.75,6.15 7.59,5.88 9.5,7.17C10.29,6.95 11.15,6.84 12,6.84C12.85,6.84 13.71,6.95 14.5,7.17C16.41,5.88 17.25,6.15 17.25,6.15C17.8,7.5 17.45,8.54 17.35,8.79C18,9.5 18.38,10.39 18.38,11.5C18.38,15.32 16.04,16.16 13.81,16.41C14.17,16.72 14.5,17.33 14.5,18.26C14.5,19.6 14.5,20.68 14.5,21C14.5,21.27 14.66,21.59 15.17,21.5C19.14,20.16 22,16.42 22,12A10,10 0 0,0 12,2Z" />
15
15
  </svg>
16
16
  </a>
17
- <a part="twitter">
18
- <svg viewBox="0 0 24 24">
19
- <path fill="currentColor" d="M22.46,6C21.69,6.35 20.86,6.58 20,6.69C20.88,6.16 21.56,5.32 21.88,4.31C21.05,4.81 20.13,5.16 19.16,5.36C18.37,4.5 17.26,4 16,4C13.65,4 11.73,5.92 11.73,8.29C11.73,8.63 11.77,8.96 11.84,9.27C8.28,9.09 5.11,7.38 3,4.79C2.63,5.42 2.42,6.16 2.42,6.94C2.42,8.43 3.17,9.75 4.33,10.5C3.62,10.5 2.96,10.3 2.38,10C2.38,10 2.38,10 2.38,10.03C2.38,12.11 3.86,13.85 5.82,14.24C5.46,14.34 5.08,14.39 4.69,14.39C4.42,14.39 4.15,14.36 3.89,14.31C4.43,16 6,17.26 7.89,17.29C6.43,18.45 4.58,19.13 2.56,19.13C2.22,19.13 1.88,19.11 1.54,19.07C3.44,20.29 5.7,21 8.12,21C16,21 20.33,14.46 20.33,8.79C20.33,8.6 20.33,8.42 20.32,8.23C21.16,7.63 21.88,6.87 22.46,6Z" />
20
- </svg>
21
- </a>
22
17
  </div>
23
18
  </pg-card>
@@ -21,7 +21,6 @@ export default class PgCardUser extends HTMLElement {
21
21
  @Part() $user: HTMLDivElement;
22
22
  @Part() $name: HTMLDivElement;
23
23
  @Part() $github: HTMLAnchorElement;
24
- @Part() $twitter: HTMLAnchorElement;
25
24
  @Part() $iconCountValue: HTMLDivElement;
26
25
  @Part() $avatar: PgAvatar;
27
26
 
@@ -29,9 +28,6 @@ export default class PgCardUser extends HTMLElement {
29
28
  addTooltip(this.$github, () => {
30
29
  return `View ${this.user?.github} on GitHub`;
31
30
  });
32
- addTooltip(this.$twitter, () => {
33
- return `View ${this.user?.twitter} on Twitter`;
34
- });
35
31
  }
36
32
 
37
33
  render(changes) {
@@ -41,8 +37,6 @@ export default class PgCardUser extends HTMLElement {
41
37
  this.$iconCountValue.innerText = `${this.user.iconCount}`;
42
38
  this.$github.href = `https://github.com/${this.user.github}`;
43
39
  this.$github.style.setProperty('display', this.user.github ? null : 'none');
44
- this.$twitter.href = `https://github.com/${this.user.twitter}`;
45
- this.$twitter.style.setProperty('display', this.user.twitter ? null : 'none');
46
40
  this.$user.style.setProperty('display', null);
47
41
  this.$loading.style.setProperty('display', 'none');
48
42
  } else {
@@ -3,7 +3,7 @@
3
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
4
 
5
5
  ```typescript
6
- import '@pictogrammers/components/pgAnnoy.js';
6
+ import '@pictogrammers/components/pgDatabase.js';
7
7
  ```
8
8
 
9
9
  ## Usage
@@ -1,5 +1,6 @@
1
1
  <div class="example">
2
- <pg-database part="database"></pg-database>
2
+ <!-- disable for now -->
3
+ <!--<pg-database part="database"></pg-database>-->
3
4
  <div>
4
5
  Total Icons: <code part="count"></code>
5
6
  </div>
@@ -12,7 +12,7 @@ export default class XPgDatabaseBasic extends HTMLElement {
12
12
 
13
13
  @Prop() fontId = 'D051337E-BC7E-11E5-A4E9-842B2B6CFE1B';
14
14
 
15
- @Part() $database: PgDatabase;
15
+ //@Part() $database: PgDatabase;
16
16
 
17
17
  @Part() $count: HTMLSpanElement;
18
18
  @Part() $total: HTMLSpanElement;
@@ -20,8 +20,8 @@ export default class XPgDatabaseBasic extends HTMLElement {
20
20
  icons: Icon[] = [];
21
21
 
22
22
  connectedCallback() {
23
- this.$database.addEventListener('sync', this.handleSync.bind(this));
24
- this.$database.font = this.fontId;
23
+ //this.$database.addEventListener('sync', this.handleSync.bind(this));
24
+ //this.$database.font = this.fontId;
25
25
  }
26
26
 
27
27
  async handleSync(e: CustomEvent) {
@@ -1,5 +1,4 @@
1
1
  import { Component, Prop, Part } from '@pictogrammers/element';
2
- import { createPopper } from '@popperjs/core';
3
2
 
4
3
  import template from './dropdown.html';
5
4
  import style from './dropdown.css';
@@ -28,24 +27,6 @@ export default class PgDropdown extends HTMLElement {
28
27
  }
29
28
 
30
29
  wireUpPopover(node) {
31
- createPopper(node, this.$popover, {
32
- placement: 'bottom-start',
33
- modifiers: [
34
- {
35
- name: 'offset',
36
- options: {
37
- offset: [-4, 8],
38
- },
39
- },
40
- {
41
- name: 'arrow',
42
- options: {
43
- element: this.$arrow,
44
- padding: 0,
45
- },
46
- },
47
- ]
48
- });
49
30
  this.$popover.style.visibility = 'hidden';
50
31
  node.addEventListener('click', (e) => {
51
32
  this.$popover.style.visibility = this.isVisible ? 'hidden' : 'visible';
@@ -22,8 +22,8 @@
22
22
  </label>
23
23
  </p>
24
24
  <div class="example">
25
- <pg-database part="database"></pg-database>
25
+ <!--<pg-database part="database"></pg-database>
26
26
  <pg-grid part="grid">
27
27
  <p>No Icons Found! default slot content</p>
28
- </pg-grid>
28
+ </pg-grid>-->
29
29
  </div>