@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.
- package/@types/css.d.ts +4 -0
- package/@types/html.d.ts +4 -0
- package/README.md +49 -0
- package/dist/main.js +3819 -0
- package/dist/pgAnnoy.js +116 -0
- package/dist/pgAvatar.js +136 -0
- package/dist/pgButton.js +116 -0
- package/dist/pgButtonGroup.js +116 -0
- package/dist/pgButtonLink.js +116 -0
- package/dist/pgButtonToggle.js +146 -0
- package/dist/pgCard.js +116 -0
- package/dist/pgCardUser.js +196 -0
- package/dist/pgColor.js +136 -0
- package/dist/pgDatabase.js +236 -0
- package/dist/pgDropdown.js +686 -0
- package/dist/pgGrid.js +126 -0
- package/dist/pgHeader.js +116 -0
- package/dist/pgIcon.js +116 -0
- package/dist/pgInputCheck.js +116 -0
- package/dist/pgInputCheckList.js +126 -0
- package/dist/pgInputFileLocal.js +116 -0
- package/dist/pgInputHexRgb.js +126 -0
- package/dist/pgInputRange.js +116 -0
- package/dist/pgInputSelect.js +116 -0
- package/dist/pgInputText.js +116 -0
- package/dist/pgInputTextIcon.js +176 -0
- package/dist/pgInputUserSelect.js +116 -0
- package/dist/pgListTag.js +136 -0
- package/dist/pgMarkdown.js +346 -0
- package/dist/pgMenuIcon.js +206 -0
- package/dist/pgModalAlert.js +126 -0
- package/dist/pgModification.js +396 -0
- package/dist/pgNav.js +116 -0
- package/dist/pgOverlay.js +96 -0
- package/dist/pgPicker.js +116 -0
- package/dist/pgPreview.js +116 -0
- package/dist/pgScroll.js +266 -0
- package/dist/pgSearch.js +146 -0
- package/dist/pgTab.js +116 -0
- package/dist/pgTabs.js +136 -0
- package/dist/pgToast.js +136 -0
- package/dist/pgToasts.js +136 -0
- package/dist/pgTooltip.js +126 -0
- package/index.html +302 -0
- package/package.json +25 -0
- package/pg/annoy/README.md +18 -0
- package/pg/annoy/__examples__/basic/basic.html +8 -0
- package/pg/annoy/__examples__/basic/basic.ts +11 -0
- package/pg/annoy/annoy.css +238 -0
- package/pg/annoy/annoy.html +59 -0
- package/pg/annoy/annoy.ts +48 -0
- package/pg/annoy/index.ts +3 -0
- package/pg/avatar/README.md +23 -0
- package/pg/avatar/__examples__/basic/basic.html +6 -0
- package/pg/avatar/__examples__/basic/basic.ts +41 -0
- package/pg/avatar/__examples__/basic/constants.ts +1 -0
- package/pg/avatar/avatar.css +45 -0
- package/pg/avatar/avatar.html +8 -0
- package/pg/avatar/avatar.spec.ts +51 -0
- package/pg/avatar/avatar.ts +37 -0
- package/pg/avatar/index.ts +3 -0
- package/pg/button/README.md +51 -0
- package/pg/button/__examples__/basic/basic.html +11 -0
- package/pg/button/__examples__/basic/basic.ts +11 -0
- package/pg/button/__examples__/states/states.html +8 -0
- package/pg/button/__examples__/states/states.ts +20 -0
- package/pg/button/button.css +91 -0
- package/pg/button/button.html +3 -0
- package/pg/button/button.ts +45 -0
- package/pg/button/index.ts +3 -0
- package/pg/buttonGroup/README.md +28 -0
- package/pg/buttonGroup/__examples__/basic/basic.html +12 -0
- package/pg/buttonGroup/__examples__/basic/basic.ts +11 -0
- package/pg/buttonGroup/buttonGroup.css +4 -0
- package/pg/buttonGroup/buttonGroup.html +1 -0
- package/pg/buttonGroup/buttonGroup.spec.ts +30 -0
- package/pg/buttonGroup/buttonGroup.ts +50 -0
- package/pg/buttonGroup/index.ts +3 -0
- package/pg/buttonLink/README.md +51 -0
- package/pg/buttonLink/__examples__/basic/basic.html +17 -0
- package/pg/buttonLink/__examples__/basic/basic.ts +11 -0
- package/pg/buttonLink/buttonLink.css +91 -0
- package/pg/buttonLink/buttonLink.html +3 -0
- package/pg/buttonLink/buttonLink.ts +46 -0
- package/pg/buttonLink/index.ts +3 -0
- package/pg/buttonToggle/README.md +54 -0
- package/pg/buttonToggle/__examples__/basic/basic.html +10 -0
- package/pg/buttonToggle/__examples__/basic/basic.ts +23 -0
- package/pg/buttonToggle/buttonToggle.css +8 -0
- package/pg/buttonToggle/buttonToggle.html +4 -0
- package/pg/buttonToggle/buttonToggle.ts +44 -0
- package/pg/buttonToggle/index.ts +3 -0
- package/pg/card/README.md +21 -0
- package/pg/card/__examples__/basic/basic.html +5 -0
- package/pg/card/__examples__/basic/basic.ts +11 -0
- package/pg/card/card.css +11 -0
- package/pg/card/card.html +3 -0
- package/pg/card/card.spec.ts +30 -0
- package/pg/card/card.ts +13 -0
- package/pg/card/index.ts +3 -0
- package/pg/cardUser/README.md +22 -0
- package/pg/cardUser/__examples__/basic/basic.html +3 -0
- package/pg/cardUser/__examples__/basic/basic.ts +30 -0
- package/pg/cardUser/__examples__/basic/constants.ts +1 -0
- package/pg/cardUser/cardUser.css +67 -0
- package/pg/cardUser/cardUser.html +23 -0
- package/pg/cardUser/cardUser.spec.ts +46 -0
- package/pg/cardUser/cardUser.ts +53 -0
- package/pg/cardUser/index.ts +3 -0
- package/pg/color/README.md +13 -0
- package/pg/color/__examples__/basic/basic.html +4 -0
- package/pg/color/__examples__/basic/basic.ts +20 -0
- package/pg/color/color.css +21 -0
- package/pg/color/color.html +1 -0
- package/pg/color/color.ts +97 -0
- package/pg/color/constants.ts +357 -0
- package/pg/color/index.ts +3 -0
- package/pg/color/utils.ts +27 -0
- package/pg/database/README.md +28 -0
- package/pg/database/__examples__/basic/basic.html +9 -0
- package/pg/database/__examples__/basic/basic.ts +37 -0
- package/pg/database/database.css +0 -0
- package/pg/database/database.html +0 -0
- package/pg/database/database.ts +42 -0
- package/pg/database/index.ts +3 -0
- package/pg/dropdown/README.md +13 -0
- package/pg/dropdown/__examples__/basic/basic.html +14 -0
- package/pg/dropdown/__examples__/basic/basic.ts +11 -0
- package/pg/dropdown/dropdown.css +46 -0
- package/pg/dropdown/dropdown.html +5 -0
- package/pg/dropdown/dropdown.ts +60 -0
- package/pg/dropdown/index.ts +3 -0
- package/pg/grid/README.md +97 -0
- package/pg/grid/__examples__/basic/basic.html +29 -0
- package/pg/grid/__examples__/basic/basic.ts +139 -0
- package/pg/grid/grid.css +68 -0
- package/pg/grid/grid.html +6 -0
- package/pg/grid/grid.spec.ts +66 -0
- package/pg/grid/grid.ts +417 -0
- package/pg/grid/index.ts +3 -0
- package/pg/header/README.md +23 -0
- package/pg/header/__examples__/basic/basic.html +8 -0
- package/pg/header/__examples__/basic/basic.ts +11 -0
- package/pg/header/header.css +42 -0
- package/pg/header/header.html +15 -0
- package/pg/header/header.ts +28 -0
- package/pg/header/index.ts +3 -0
- package/pg/icon/README.md +26 -0
- package/pg/icon/__examples__/basic/basic.html +16 -0
- package/pg/icon/__examples__/basic/basic.ts +34 -0
- package/pg/icon/__examples__/basic/constants.ts +2 -0
- package/pg/icon/icon.css +9 -0
- package/pg/icon/icon.html +3 -0
- package/pg/icon/icon.spec.ts +46 -0
- package/pg/icon/icon.ts +23 -0
- package/pg/icon/index.ts +3 -0
- package/pg/inputCheck/README.md +32 -0
- package/pg/inputCheck/__examples__/basic/basic.html +8 -0
- package/pg/inputCheck/__examples__/basic/basic.ts +23 -0
- package/pg/inputCheck/index.ts +3 -0
- package/pg/inputCheck/inputCheck.css +45 -0
- package/pg/inputCheck/inputCheck.html +6 -0
- package/pg/inputCheck/inputCheck.ts +42 -0
- package/pg/inputCheckList/README.md +35 -0
- package/pg/inputCheckList/__examples__/basic/basic.html +4 -0
- package/pg/inputCheckList/__examples__/basic/basic.ts +31 -0
- package/pg/inputCheckList/index.ts +3 -0
- package/pg/inputCheckList/inputCheckList.css +70 -0
- package/pg/inputCheckList/inputCheckList.html +1 -0
- package/pg/inputCheckList/inputCheckList.ts +103 -0
- package/pg/inputCheckList/templates/option.html +8 -0
- package/pg/inputFileLocal/README.md +30 -0
- package/pg/inputFileLocal/__examples__/basic/basic.html +4 -0
- package/pg/inputFileLocal/__examples__/basic/basic.ts +23 -0
- package/pg/inputFileLocal/index.ts +3 -0
- package/pg/inputFileLocal/inputFileLocal.css +80 -0
- package/pg/inputFileLocal/inputFileLocal.html +5 -0
- package/pg/inputFileLocal/inputFileLocal.ts +82 -0
- package/pg/inputHexRgb/README.md +15 -0
- package/pg/inputHexRgb/__examples__/basic/basic.html +4 -0
- package/pg/inputHexRgb/__examples__/basic/basic.ts +23 -0
- package/pg/inputHexRgb/index.ts +3 -0
- package/pg/inputHexRgb/inputHexRgb.css +96 -0
- package/pg/inputHexRgb/inputHexRgb.html +9 -0
- package/pg/inputHexRgb/inputHexRgb.ts +79 -0
- package/pg/inputHexRgb/utils.ts +27 -0
- package/pg/inputRange/README.md +18 -0
- package/pg/inputRange/__examples__/basic/basic.html +9 -0
- package/pg/inputRange/__examples__/basic/basic.ts +30 -0
- package/pg/inputRange/index.ts +3 -0
- package/pg/inputRange/inputRange.css +0 -0
- package/pg/inputRange/inputRange.html +1 -0
- package/pg/inputRange/inputRange.ts +53 -0
- package/pg/inputSelect/README.md +25 -0
- package/pg/inputSelect/__examples__/basic/basic.html +6 -0
- package/pg/inputSelect/__examples__/basic/basic.ts +30 -0
- package/pg/inputSelect/index.ts +3 -0
- package/pg/inputSelect/inputSelect.css +36 -0
- package/pg/inputSelect/inputSelect.html +4 -0
- package/pg/inputSelect/inputSelect.ts +57 -0
- package/pg/inputText/README.md +27 -0
- package/pg/inputText/__examples__/basic/basic.html +9 -0
- package/pg/inputText/__examples__/basic/basic.ts +30 -0
- package/pg/inputText/index.ts +3 -0
- package/pg/inputText/inputText.css +20 -0
- package/pg/inputText/inputText.html +1 -0
- package/pg/inputText/inputText.spec.ts +59 -0
- package/pg/inputText/inputText.ts +59 -0
- package/pg/inputTextIcon/README.md +26 -0
- package/pg/inputTextIcon/index.ts +3 -0
- package/pg/inputTextIcon/inputTextIcon.css +24 -0
- package/pg/inputTextIcon/inputTextIcon.html +4 -0
- package/pg/inputTextIcon/inputTextIcon.spec.ts +44 -0
- package/pg/inputTextIcon/inputTextIcon.ts +26 -0
- package/pg/inputUserSelect/README.md +31 -0
- package/pg/inputUserSelect/__examples__/basic/basic.html +4 -0
- package/pg/inputUserSelect/__examples__/basic/basic.ts +25 -0
- package/pg/inputUserSelect/__examples__/basic/constants.ts +33 -0
- package/pg/inputUserSelect/index.ts +3 -0
- package/pg/inputUserSelect/inputUserSelect.css +174 -0
- package/pg/inputUserSelect/inputUserSelect.html +18 -0
- package/pg/inputUserSelect/inputUserSelect.ts +266 -0
- package/pg/listTag/README.md +26 -0
- package/pg/listTag/__examples__/basic/basic.html +16 -0
- package/pg/listTag/__examples__/basic/basic.ts +53 -0
- package/pg/listTag/__examples__/basic/constants.ts +22 -0
- package/pg/listTag/index.ts +3 -0
- package/pg/listTag/listTag.css +9 -0
- package/pg/listTag/listTag.html +1 -0
- package/pg/listTag/listTag.ts +48 -0
- package/pg/listTag/partials/tag.html +3 -0
- package/pg/markdown/README.md +13 -0
- package/pg/markdown/__examples__/basic/basic.html +3 -0
- package/pg/markdown/__examples__/basic/basic.ts +51 -0
- package/pg/markdown/__examples__/basic/constants.ts +129 -0
- package/pg/markdown/index.ts +5 -0
- package/pg/markdown/markdown.css +760 -0
- package/pg/markdown/markdown.html +1 -0
- package/pg/markdown/markdown.md +123 -0
- package/pg/markdown/markdown.spec.ts +87 -0
- package/pg/markdown/markdown.ts +381 -0
- package/pg/markdown/markdownReplace.ts +7 -0
- package/pg/menuIcon/README.md +13 -0
- package/pg/menuIcon/__examples__/basic/basic.html +3 -0
- package/pg/menuIcon/__examples__/basic/basic.ts +15 -0
- package/pg/menuIcon/index.ts +3 -0
- package/pg/menuIcon/menuIcon.css +168 -0
- package/pg/menuIcon/menuIcon.html +64 -0
- package/pg/menuIcon/menuIcon.ts +271 -0
- package/pg/modalAlert/README.md +17 -0
- package/pg/modalAlert/__examples__/basic/basic.html +4 -0
- package/pg/modalAlert/__examples__/basic/basic.ts +27 -0
- package/pg/modalAlert/index.ts +3 -0
- package/pg/modalAlert/modalAlert.css +43 -0
- package/pg/modalAlert/modalAlert.html +22 -0
- package/pg/modalAlert/modalAlert.ts +45 -0
- package/pg/modification/README.md +34 -0
- package/pg/modification/__examples__/basic/basic.html +8 -0
- package/pg/modification/__examples__/basic/basic.ts +63 -0
- package/pg/modification/__examples__/basic/constants.ts +416 -0
- package/pg/modification/index.ts +3 -0
- package/pg/modification/modification.css +311 -0
- package/pg/modification/modification.html +1 -0
- package/pg/modification/modification.spec.ts +33 -0
- package/pg/modification/modification.ts +201 -0
- package/pg/modification/type/date.html +1 -0
- package/pg/modification/type/iconAliasCreated.html +13 -0
- package/pg/modification/type/iconAliasDeleted.html +13 -0
- package/pg/modification/type/iconAuthorModified.html +13 -0
- package/pg/modification/type/iconCreated.html +13 -0
- package/pg/modification/type/iconDeleted.html +13 -0
- package/pg/modification/type/iconDeprecated.html +13 -0
- package/pg/modification/type/iconDescriptionModified.html +10 -0
- package/pg/modification/type/iconModified.html +14 -0
- package/pg/modification/type/iconRenamed.html +13 -0
- package/pg/modification/type/iconTagCreated.html +13 -0
- package/pg/modification/type/iconTagDeleted.html +13 -0
- package/pg/modification/type/news.html +5 -0
- package/pg/nav/README.md +16 -0
- package/pg/nav/__examples__/basic/basic.html +5 -0
- package/pg/nav/__examples__/basic/basic.ts +11 -0
- package/pg/nav/index.ts +3 -0
- package/pg/nav/nav.css +14 -0
- package/pg/nav/nav.html +16 -0
- package/pg/nav/nav.ts +21 -0
- package/pg/overlay/README.md +37 -0
- package/pg/overlay/__examples__/basic/basic.css +3 -0
- package/pg/overlay/__examples__/basic/basic.html +3 -0
- package/pg/overlay/__examples__/basic/basic.ts +13 -0
- package/pg/overlay/index.ts +3 -0
- package/pg/overlay/overlay.ts +26 -0
- package/pg/picker/README.md +13 -0
- package/pg/picker/index.ts +3 -0
- package/pg/picker/picker.css +56 -0
- package/pg/picker/picker.html +8 -0
- package/pg/picker/picker.ts +66 -0
- package/pg/preview/README.md +19 -0
- package/pg/preview/__examples__/basic/basic.html +11 -0
- package/pg/preview/__examples__/basic/basic.ts +22 -0
- package/pg/preview/index.ts +3 -0
- package/pg/preview/preview.css +34 -0
- package/pg/preview/preview.html +5 -0
- package/pg/preview/preview.ts +38 -0
- package/pg/scroll/README.md +42 -0
- package/pg/scroll/__examples__/basic/basic.css +4 -0
- package/pg/scroll/__examples__/basic/basic.html +11 -0
- package/pg/scroll/__examples__/basic/basic.ts +88 -0
- package/pg/scroll/index.ts +3 -0
- package/pg/scroll/scroll.css +7 -0
- package/pg/scroll/scroll.html +3 -0
- package/pg/scroll/scroll.ts +158 -0
- package/pg/search/README.md +59 -0
- package/pg/search/__examples__/basic/basic.html +3 -0
- package/pg/search/__examples__/basic/basic.ts +29 -0
- package/pg/search/__examples__/basic/constants.ts +3 -0
- package/pg/search/index.ts +3 -0
- package/pg/search/search.css +188 -0
- package/pg/search/search.html +18 -0
- package/pg/search/search.ts +252 -0
- package/pg/search/utils.ts +12 -0
- package/pg/shared/README.md +28 -0
- package/pg/shared/copy.ts +25 -0
- package/pg/shared/database.ts +35 -0
- package/pg/shared/databaseService.ts +230 -0
- package/pg/shared/debounce.ts +12 -0
- package/pg/shared/enums/modificationType.ts +19 -0
- package/pg/shared/filter.ts +14 -0
- package/pg/shared/http.ts +83 -0
- package/pg/shared/iconFilter.spec.ts +61 -0
- package/pg/shared/iconFilter.ts +71 -0
- package/pg/shared/list.ts +34 -0
- package/pg/shared/models/alias.ts +40 -0
- package/pg/shared/models/font.ts +31 -0
- package/pg/shared/models/fontIcon.ts +25 -0
- package/pg/shared/models/fontVersion.ts +22 -0
- package/pg/shared/models/icon.ts +97 -0
- package/pg/shared/models/modification.ts +45 -0
- package/pg/shared/models/style.ts +12 -0
- package/pg/shared/models/tag.ts +37 -0
- package/pg/shared/models/user.ts +35 -0
- package/pg/shared/models/version.ts +20 -0
- package/pg/shared/removeDiacritics.ts +94 -0
- package/pg/shared/toast.ts +47 -0
- package/pg/shared/uuid.ts +6 -0
- package/pg/tab/README.md +18 -0
- package/pg/tab/index.ts +3 -0
- package/pg/tab/tab.css +13 -0
- package/pg/tab/tab.html +3 -0
- package/pg/tab/tab.ts +51 -0
- package/pg/tabs/README.md +31 -0
- package/pg/tabs/__examples__/basic/basic.html +13 -0
- package/pg/tabs/__examples__/basic/basic.ts +11 -0
- package/pg/tabs/index.ts +3 -0
- package/pg/tabs/partials/tab.html +3 -0
- package/pg/tabs/tabs.css +69 -0
- package/pg/tabs/tabs.html +4 -0
- package/pg/tabs/tabs.ts +102 -0
- package/pg/toast/README.md +13 -0
- package/pg/toast/index.ts +3 -0
- package/pg/toast/toast.css +112 -0
- package/pg/toast/toast.html +13 -0
- package/pg/toast/toast.ts +39 -0
- package/pg/toasts/README.md +37 -0
- package/pg/toasts/__examples__/basic/basic.html +11 -0
- package/pg/toasts/__examples__/basic/basic.ts +86 -0
- package/pg/toasts/index.ts +3 -0
- package/pg/toasts/toasts.css +8 -0
- package/pg/toasts/toasts.html +1 -0
- package/pg/toasts/toasts.ts +51 -0
- package/pg/tooltip/README.md +51 -0
- package/pg/tooltip/__examples__/basic/basic.css +38 -0
- package/pg/tooltip/__examples__/basic/basic.html +21 -0
- package/pg/tooltip/__examples__/basic/basic.ts +55 -0
- package/pg/tooltip/addTooltip.ts +31 -0
- package/pg/tooltip/index.ts +20 -0
- package/pg/tooltip/position.ts +15 -0
- package/pg/tooltip/tooltip.css +36 -0
- package/pg/tooltip/tooltip.html +4 -0
- package/pg/tooltip/tooltip.ts +170 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Component, Prop, Part } from '@pictogrammers/element';
|
|
2
|
+
import { uuid } from '../shared/uuid';
|
|
3
|
+
import { removeToast } from '../shared/toast';
|
|
4
|
+
|
|
5
|
+
import template from './toast.html';
|
|
6
|
+
import style from './toast.css';
|
|
7
|
+
|
|
8
|
+
@Component({
|
|
9
|
+
selector: 'pg-toast',
|
|
10
|
+
style,
|
|
11
|
+
template
|
|
12
|
+
})
|
|
13
|
+
export default class PgToast extends HTMLElement {
|
|
14
|
+
@Prop() loading: boolean = false;
|
|
15
|
+
@Prop() message: string = '';
|
|
16
|
+
@Prop() type: string = 'default';
|
|
17
|
+
@Prop() key: string = uuid();
|
|
18
|
+
|
|
19
|
+
@Part() $button: HTMLButtonElement;
|
|
20
|
+
@Part() $loadingIcon: SVGElement;
|
|
21
|
+
@Part() $closeIcon: SVGElement;
|
|
22
|
+
@Part() $message: HTMLSpanElement;
|
|
23
|
+
@Part() $loading: HTMLSpanElement;
|
|
24
|
+
|
|
25
|
+
toasts: any[] = [];
|
|
26
|
+
|
|
27
|
+
connectedCallback() {
|
|
28
|
+
this.$button.addEventListener('click', () => {
|
|
29
|
+
removeToast(this.key);
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
render() {
|
|
34
|
+
this.$message.innerText = this.message;
|
|
35
|
+
this.$loading.classList.toggle('hide', !this.loading);
|
|
36
|
+
this.$button.classList.toggle('error', this.type === 'error');
|
|
37
|
+
this.$button.classList.toggle('warning', this.type === 'warning');
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# `<pg-toast>`
|
|
2
|
+
|
|
3
|
+
The `pg-toasts` will create instances of `pg-toast`.
|
|
4
|
+
|
|
5
|
+
```typescript
|
|
6
|
+
import '@pictogrammers/components/pgToast.js';
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
```html
|
|
10
|
+
<pg-toasts></pg-toasts>
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Open Toast
|
|
14
|
+
|
|
15
|
+
All of these functions will return the unique key used to track them. Note by default toasts disappear after `3` seconds. Setting `0` seconds will keep the toast opened indefinitely.
|
|
16
|
+
|
|
17
|
+
```js
|
|
18
|
+
import { addToast, addInfoToast } from '@pictogrammers/web-component';
|
|
19
|
+
// Info
|
|
20
|
+
addInfoToast(message, seconds = 3);
|
|
21
|
+
addInfoToast('Hello World!');
|
|
22
|
+
// Generic
|
|
23
|
+
const key = addToast({
|
|
24
|
+
message: 'Hello World!',
|
|
25
|
+
seconds: 10,
|
|
26
|
+
loading: true
|
|
27
|
+
});
|
|
28
|
+
// removeToast(key)
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Close or Remove Toast
|
|
32
|
+
|
|
33
|
+
Toasts that define an `key` can also be removed.
|
|
34
|
+
|
|
35
|
+
```js
|
|
36
|
+
removeToast(key);
|
|
37
|
+
```
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<div>
|
|
2
|
+
<div class="example">
|
|
3
|
+
<pg-toasts></pg-toasts>
|
|
4
|
+
</div>
|
|
5
|
+
<button part="toastInfo">Info</button>
|
|
6
|
+
<button part="toastWarning">Warning</button>
|
|
7
|
+
<button part="toastError">Error</button>
|
|
8
|
+
<button part="toastLoading">Loading</button>
|
|
9
|
+
<button part="toastRemove">Remove Loading</button>
|
|
10
|
+
<p>Note: This just triggers the show to make styling easier.</p>
|
|
11
|
+
</div>
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { Component, Part, Prop } from '@pictogrammers/element';
|
|
2
|
+
|
|
3
|
+
import template from './basic.html';
|
|
4
|
+
|
|
5
|
+
function uuid() {
|
|
6
|
+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
|
|
7
|
+
var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
|
|
8
|
+
return v.toString(16);
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
@Component({
|
|
13
|
+
selector: 'x-pg-toasts-basic',
|
|
14
|
+
template
|
|
15
|
+
})
|
|
16
|
+
export default class XPgToastsBasic extends HTMLElement {
|
|
17
|
+
|
|
18
|
+
@Part() $toastInfo: HTMLButtonElement;
|
|
19
|
+
@Part() $toastWarning: HTMLButtonElement;
|
|
20
|
+
@Part() $toastError: HTMLButtonElement;
|
|
21
|
+
@Part() $toastLoading: HTMLButtonElement;
|
|
22
|
+
@Part() $toastRemove: HTMLButtonElement;
|
|
23
|
+
|
|
24
|
+
connectedCallback() {
|
|
25
|
+
this.$toastInfo.addEventListener('click', this.handleInfo.bind(this));
|
|
26
|
+
this.$toastWarning.addEventListener('click', this.handleWarning.bind(this));
|
|
27
|
+
this.$toastError.addEventListener('click', this.handleError.bind(this));
|
|
28
|
+
this.$toastLoading.addEventListener('click', this.handleLoading.bind(this));
|
|
29
|
+
this.$toastRemove.addEventListener('click', this.handleRemove.bind(this));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
handleInfo() {
|
|
33
|
+
document.body.dispatchEvent(new CustomEvent('pgtoastadd', {
|
|
34
|
+
detail: {
|
|
35
|
+
type: 'info',
|
|
36
|
+
message: 'Hello World! With really long content that wraps rows.',
|
|
37
|
+
key: uuid()
|
|
38
|
+
}
|
|
39
|
+
}));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
handleWarning() {
|
|
43
|
+
document.body.dispatchEvent(new CustomEvent('pgtoastadd', {
|
|
44
|
+
detail: {
|
|
45
|
+
type: 'warning',
|
|
46
|
+
message: 'Hello World! Warning',
|
|
47
|
+
key: uuid()
|
|
48
|
+
}
|
|
49
|
+
}));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
handleError() {
|
|
53
|
+
document.body.dispatchEvent(new CustomEvent('pgtoastadd', {
|
|
54
|
+
detail: {
|
|
55
|
+
type: 'error',
|
|
56
|
+
message: 'Hello World! Error',
|
|
57
|
+
key: uuid()
|
|
58
|
+
}
|
|
59
|
+
}));
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
handleLoading() {
|
|
63
|
+
this.key = uuid();
|
|
64
|
+
document.body.dispatchEvent(new CustomEvent('pgtoastadd', {
|
|
65
|
+
detail: {
|
|
66
|
+
type: 'info',
|
|
67
|
+
message: 'Loading...',
|
|
68
|
+
loading: true,
|
|
69
|
+
key: this.key
|
|
70
|
+
}
|
|
71
|
+
}));
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
key: string = '';
|
|
75
|
+
handleRemove() {
|
|
76
|
+
if (this.key) {
|
|
77
|
+
document.body.dispatchEvent(new CustomEvent('pgtoastremove', {
|
|
78
|
+
detail: {
|
|
79
|
+
key: this.key
|
|
80
|
+
}
|
|
81
|
+
}));
|
|
82
|
+
this.key = '';
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<div part="container"></div>
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Component, Prop, Part } from '@pictogrammers/element';
|
|
2
|
+
import { observeToasts } from '../shared/toast';
|
|
3
|
+
import PgToast from '../toast/toast';
|
|
4
|
+
|
|
5
|
+
import template from './toasts.html';
|
|
6
|
+
import style from './toasts.css';
|
|
7
|
+
|
|
8
|
+
@Component({
|
|
9
|
+
selector: 'pg-toasts',
|
|
10
|
+
style,
|
|
11
|
+
template
|
|
12
|
+
})
|
|
13
|
+
export default class PgToasts extends HTMLElement {
|
|
14
|
+
toasts: any[] = [];
|
|
15
|
+
|
|
16
|
+
@Part() $container: HTMLDivElement;
|
|
17
|
+
|
|
18
|
+
connectedCallback() {
|
|
19
|
+
observeToasts({
|
|
20
|
+
add: (toast) => {
|
|
21
|
+
this.toasts.push(toast);
|
|
22
|
+
this.render();
|
|
23
|
+
},
|
|
24
|
+
remove: (key) => {
|
|
25
|
+
const index = this.toasts.findIndex(t => t.key === key);
|
|
26
|
+
if (index !== -1) {
|
|
27
|
+
var [toast] = this.toasts.splice(index, 1);
|
|
28
|
+
this.$container.querySelector(`[key="${toast.key}"]`)?.remove();
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
render() {
|
|
35
|
+
this.toasts.forEach((toast) => {
|
|
36
|
+
const existing = this.$container.querySelector(`[key="${toast.key}"]`) as PgToast;
|
|
37
|
+
if (existing) {
|
|
38
|
+
existing.message = toast.message;
|
|
39
|
+
existing.loading = toast.loading;
|
|
40
|
+
existing.type = toast.type;
|
|
41
|
+
} else {
|
|
42
|
+
const ele = document.createElement('pg-toast') as PgToast;
|
|
43
|
+
ele.setAttribute('key', toast.key);
|
|
44
|
+
ele.message = toast.message;
|
|
45
|
+
ele.loading = toast.loading;
|
|
46
|
+
ele.type = toast.type;
|
|
47
|
+
this.$container.appendChild(ele);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# `<pg-tooltip>`
|
|
2
|
+
|
|
3
|
+
The `pg-tooltip` component should be placed on the top level. It then is wired to a shared event.
|
|
4
|
+
|
|
5
|
+
```typescript
|
|
6
|
+
import '@pictogrammers/components/pg/tooltip';
|
|
7
|
+
import PgTooltip from '@pictogrammers/components/pg/tooltip';
|
|
8
|
+
import { addTooltip } from '@pictogrammers/components/pg/addTooltip';
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
```html
|
|
12
|
+
<pg-icon path="..."></pg-icon>
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
| Attributes | Tested | Description |
|
|
16
|
+
| ---------- | -------- | ----------- |
|
|
17
|
+
| path | ✅ | Set path data |
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
Wire up the tooltip listener.
|
|
23
|
+
|
|
24
|
+
```javascript
|
|
25
|
+
@Part() $tooltip: PgTooltip;
|
|
26
|
+
|
|
27
|
+
connectedCallback() {
|
|
28
|
+
this.addEventListener('tooltip', this.handleTooltip.bind(this));
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
handleTooltip(e) {
|
|
32
|
+
const { visible, rect, text, position } = e.detail;
|
|
33
|
+
this.$tooltip.visible = visible;
|
|
34
|
+
this.$tooltip.rect = rect;
|
|
35
|
+
this.$tooltip.text = text;
|
|
36
|
+
this.$tooltip.position = position;
|
|
37
|
+
e.stopPropagation();
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Triggering a tooltip on a part.
|
|
42
|
+
|
|
43
|
+
```javascript
|
|
44
|
+
import { addTooltip } from '@pictogrammers/components/pg/tooltip/addTooltip';
|
|
45
|
+
|
|
46
|
+
connectedCallback() {
|
|
47
|
+
addTooltip(this.$partName, () => {
|
|
48
|
+
return `Sponsor ${this.user.name} on GitHub`;
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
```
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
.tooltip-grid {
|
|
2
|
+
height: 300px;
|
|
3
|
+
display: grid;
|
|
4
|
+
grid-template-rows: 4rem 4rem 1fr 4rem 4rem;
|
|
5
|
+
grid-template-columns: 4rem 4rem 1fr 4rem 4rem;
|
|
6
|
+
}
|
|
7
|
+
.tooltip-grid button {
|
|
8
|
+
width: 3rem;
|
|
9
|
+
height: 3rem;
|
|
10
|
+
align-self: center;
|
|
11
|
+
justify-self: center;
|
|
12
|
+
}
|
|
13
|
+
[part="tooltipSource1"] {
|
|
14
|
+
grid-column: 3;
|
|
15
|
+
grid-row: 3;
|
|
16
|
+
}
|
|
17
|
+
[part="tooltipSource2"] {
|
|
18
|
+
grid-column: 3;
|
|
19
|
+
grid-row: 3;
|
|
20
|
+
}
|
|
21
|
+
[part="tooltipSource1"] {
|
|
22
|
+
margin-right: 10rem;
|
|
23
|
+
}
|
|
24
|
+
[part="tooltipSource2"] {
|
|
25
|
+
margin-left: 10rem;
|
|
26
|
+
}
|
|
27
|
+
[part="tooltipTopStart"] { grid-column: 2; grid-row: 1; }
|
|
28
|
+
[part="tooltipTop"] { grid-column: 3; grid-row: 1; }
|
|
29
|
+
[part="tooltipTopEnd"] { grid-column: 4; grid-row: 1; }
|
|
30
|
+
[part="tooltipRightStart"] { grid-column: 5; grid-row: 2; }
|
|
31
|
+
[part="tooltipRight"] { grid-column: 5; grid-row: 3; }
|
|
32
|
+
[part="tooltipRightEnd"] { grid-column: 5; grid-row: 4; }
|
|
33
|
+
[part="tooltipBottomStart"] { grid-column: 2; grid-row: 5; }
|
|
34
|
+
[part="tooltipBottom"] { grid-column: 3; grid-row: 5; }
|
|
35
|
+
[part="tooltipBottomEnd"] { grid-column: 4; grid-row: 5; }
|
|
36
|
+
[part="tooltipLeftStart"] { grid-column: 1; grid-row: 2; }
|
|
37
|
+
[part="tooltipLeft"] { grid-column: 1; grid-row: 3; }
|
|
38
|
+
[part="tooltipLeftEnd"] { grid-column: 1; grid-row: 4; }
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<pg-tooltip part="tooltip1"></pg-tooltip>
|
|
2
|
+
<pg-tooltip part="tooltip2"></pg-tooltip>
|
|
3
|
+
|
|
4
|
+
<div class="example">
|
|
5
|
+
<div class="tooltip-grid">
|
|
6
|
+
<button part="tooltipSource1"></button>
|
|
7
|
+
<button part="tooltipSource2"></button>
|
|
8
|
+
<button part="tooltipTop"></button>
|
|
9
|
+
<button part="tooltipTopStart"></button>
|
|
10
|
+
<button part="tooltipTopEnd"></button>
|
|
11
|
+
<button part="tooltipRight"></button>
|
|
12
|
+
<button part="tooltipRightStart"></button>
|
|
13
|
+
<button part="tooltipRightEnd"></button>
|
|
14
|
+
<button part="tooltipBottom"></button>
|
|
15
|
+
<button part="tooltipBottomStart"></button>
|
|
16
|
+
<button part="tooltipBottomEnd"></button>
|
|
17
|
+
<button part="tooltipLeft"></button>
|
|
18
|
+
<button part="tooltipLeftStart"></button>
|
|
19
|
+
<button part="tooltipLeftEnd"></button>
|
|
20
|
+
</div>
|
|
21
|
+
</div>
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Component, Part, Prop } from '@pictogrammers/element';
|
|
2
|
+
import PgTooltip from '../../tooltip';
|
|
3
|
+
|
|
4
|
+
import template from './basic.html';
|
|
5
|
+
import style from './basic.css';
|
|
6
|
+
|
|
7
|
+
@Component({
|
|
8
|
+
selector: 'x-pg-tooltip-basic',
|
|
9
|
+
template,
|
|
10
|
+
style
|
|
11
|
+
})
|
|
12
|
+
export default class XPgTooltipBasic extends HTMLElement {
|
|
13
|
+
|
|
14
|
+
@Part() $tooltip1: PgTooltip;
|
|
15
|
+
@Part() $tooltip2: PgTooltip;
|
|
16
|
+
@Part() $tooltipSource1: PgTooltip;
|
|
17
|
+
@Part() $tooltipSource2: PgTooltip;
|
|
18
|
+
@Part() $tooltipTop: HTMLButtonElement;
|
|
19
|
+
@Part() $tooltipTopStart: HTMLButtonElement;
|
|
20
|
+
@Part() $tooltipTopEnd: HTMLButtonElement;
|
|
21
|
+
@Part() $tooltipRight: HTMLButtonElement;
|
|
22
|
+
@Part() $tooltipRightStart: HTMLButtonElement;
|
|
23
|
+
@Part() $tooltipRightEnd: HTMLButtonElement;
|
|
24
|
+
@Part() $tooltipBottom: HTMLButtonElement;
|
|
25
|
+
@Part() $tooltipBottomStart: HTMLButtonElement;
|
|
26
|
+
@Part() $tooltipBottomEnd: HTMLButtonElement;
|
|
27
|
+
@Part() $tooltipLeft: HTMLButtonElement;
|
|
28
|
+
@Part() $tooltipLeftStart: HTMLButtonElement;
|
|
29
|
+
@Part() $tooltipLeftEnd: HTMLButtonElement;
|
|
30
|
+
|
|
31
|
+
connectedCallback() {
|
|
32
|
+
const setPosition = (position) => {
|
|
33
|
+
this.$tooltip1.position = position;
|
|
34
|
+
this.$tooltip2.position = position;
|
|
35
|
+
this.$tooltip1.visible = true;
|
|
36
|
+
this.$tooltip1.rect = this.$tooltipSource1.getBoundingClientRect();
|
|
37
|
+
this.$tooltip1.text = 'Hello World!';
|
|
38
|
+
this.$tooltip2.visible = true;
|
|
39
|
+
this.$tooltip2.rect = this.$tooltipSource2.getBoundingClientRect();
|
|
40
|
+
this.$tooltip2.text = '-';
|
|
41
|
+
}
|
|
42
|
+
this.$tooltipTop.addEventListener('click', () => { setPosition('top'); });
|
|
43
|
+
this.$tooltipTopStart.addEventListener('click', () => { setPosition('top-start'); });
|
|
44
|
+
this.$tooltipTopEnd.addEventListener('click', () => { setPosition('top-end'); });
|
|
45
|
+
this.$tooltipRight.addEventListener('click', () => { setPosition('right'); });
|
|
46
|
+
this.$tooltipRightStart.addEventListener('click', () => { setPosition('right-start'); });
|
|
47
|
+
this.$tooltipRightEnd.addEventListener('click', () => { setPosition('right-end'); });
|
|
48
|
+
this.$tooltipBottom.addEventListener('click', () => { setPosition('bottom'); });
|
|
49
|
+
this.$tooltipBottomStart.addEventListener('click', () => { setPosition('bottom-start'); });
|
|
50
|
+
this.$tooltipBottomEnd.addEventListener('click', () => { setPosition('bottom-end'); });
|
|
51
|
+
this.$tooltipLeft.addEventListener('click', () => { setPosition('left'); });
|
|
52
|
+
this.$tooltipLeftStart.addEventListener('click', () => { setPosition('left-start'); });
|
|
53
|
+
this.$tooltipLeftEnd.addEventListener('click', () => { setPosition('left-end'); });
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export function addTooltip($part, render, position?) {
|
|
2
|
+
function handleMouseEnter() {
|
|
3
|
+
$part.dispatchEvent(
|
|
4
|
+
new CustomEvent('tooltip', {
|
|
5
|
+
detail: {
|
|
6
|
+
visible: true,
|
|
7
|
+
rect: $part.getBoundingClientRect(),
|
|
8
|
+
text: render(),
|
|
9
|
+
position: position
|
|
10
|
+
},
|
|
11
|
+
bubbles: true,
|
|
12
|
+
composed: true
|
|
13
|
+
})
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function handleMouseLeave() {
|
|
18
|
+
$part.dispatchEvent(
|
|
19
|
+
new CustomEvent('tooltip', {
|
|
20
|
+
detail: {
|
|
21
|
+
visible: false
|
|
22
|
+
},
|
|
23
|
+
bubbles: true,
|
|
24
|
+
composed: true
|
|
25
|
+
})
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
$part.addEventListener('mouseenter', handleMouseEnter);
|
|
30
|
+
$part.addEventListener('mouseleave', handleMouseLeave);
|
|
31
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import PgTooltip from './tooltip';
|
|
2
|
+
|
|
3
|
+
export { addTooltip } from './addTooltip';
|
|
4
|
+
|
|
5
|
+
export {
|
|
6
|
+
TOP,
|
|
7
|
+
TOP_START,
|
|
8
|
+
TOP_END,
|
|
9
|
+
RIGHT,
|
|
10
|
+
RIGHT_START,
|
|
11
|
+
RIGHT_END,
|
|
12
|
+
BOTTOM,
|
|
13
|
+
BOTTOM_START,
|
|
14
|
+
BOTTOM_END,
|
|
15
|
+
LEFT,
|
|
16
|
+
LEFT_START,
|
|
17
|
+
LEFT_END
|
|
18
|
+
} from './position';
|
|
19
|
+
|
|
20
|
+
export default PgTooltip;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export const TOP = 'top';
|
|
2
|
+
export const TOP_START = 'top-start';
|
|
3
|
+
export const TOP_END = 'top-end';
|
|
4
|
+
|
|
5
|
+
export const RIGHT = 'right';
|
|
6
|
+
export const RIGHT_START = 'right-start';
|
|
7
|
+
export const RIGHT_END = 'right-end';
|
|
8
|
+
|
|
9
|
+
export const BOTTOM = 'bottom';
|
|
10
|
+
export const BOTTOM_START = 'bottom-start';
|
|
11
|
+
export const BOTTOM_END = 'bottom-end';
|
|
12
|
+
|
|
13
|
+
export const LEFT = 'left';
|
|
14
|
+
export const LEFT_START = 'left-start';
|
|
15
|
+
export const LEFT_END = 'left-end';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
pointer-events: none;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
[part~=tooltip] {
|
|
6
|
+
position: relative;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
[part~=tooltipText] {
|
|
10
|
+
position: absolute;
|
|
11
|
+
background: #737E9E;
|
|
12
|
+
border-radius: 0.25rem;
|
|
13
|
+
color: #FFF;
|
|
14
|
+
padding: 0.15rem 0.5rem 0.3rem 0.5rem;
|
|
15
|
+
white-space: nowrap;
|
|
16
|
+
left: 0;
|
|
17
|
+
top: 0;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
[part~=tooltipArrow] {
|
|
21
|
+
left: 16px;
|
|
22
|
+
top: -7px;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
[part~=tooltipArrow],
|
|
26
|
+
[part~=tooltipArrow]::before {
|
|
27
|
+
position: absolute;
|
|
28
|
+
width: 10px;
|
|
29
|
+
height: 10px;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
[part~=tooltipArrow]::before {
|
|
33
|
+
content: '';
|
|
34
|
+
transform: rotate(45deg);
|
|
35
|
+
background: #737E9E;
|
|
36
|
+
}
|