kempo-ui 0.0.7 → 0.0.9
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/dist/src/components/Icon.js +1 -1
- package/dist/src/components/ShadowComponent.js +1 -1
- package/dist/src/components/Tree.js +37 -0
- package/docs/components/accordion.html +3 -9
- package/docs/components/card.html +3 -9
- package/docs/components/collapsible.html +3 -9
- package/docs/components/content-slider.html +4 -9
- package/docs/components/dialog.html +157 -72
- package/docs/components/focus-capture.html +3 -7
- package/docs/components/hybrid-component.html +3 -7
- package/docs/components/icon.html +3 -8
- package/docs/components/import.html +1 -6
- package/docs/components/init.js +7 -0
- package/docs/components/light-component.html +3 -7
- package/docs/components/persistant-collapsible.html +1 -8
- package/docs/components/photo-viewer.html +1 -8
- package/docs/components/resize.html +3 -9
- package/docs/components/shadow-component.html +3 -7
- package/docs/components/show-more.html +3 -9
- package/docs/components/side-menu.html +1 -6
- package/docs/components/sortable.html +3 -7
- package/docs/components/split.html +3 -7
- package/docs/components/table.html +3 -7
- package/docs/components/tableControls.html +3 -7
- package/docs/components/tableCustomFields.html +3 -7
- package/docs/components/tableFetchRecords.html +3 -7
- package/docs/components/tableFieldSortHide.html +3 -7
- package/docs/components/tablePagination.html +3 -7
- package/docs/components/tableRecordEditing.html +3 -7
- package/docs/components/tableRecordFiltering.html +3 -7
- package/docs/components/tableRecordHiding.html +3 -7
- package/docs/components/tableRecordSearching.html +3 -7
- package/docs/components/tableRecordSelection.html +3 -7
- package/docs/components/tableRowControls.html +3 -7
- package/docs/components/tableSorting.html +3 -7
- package/docs/components/tabs.html +3 -9
- package/docs/components/tags.html +3 -9
- package/docs/components/theme-switcher.html +3 -9
- package/docs/components/timestamp.html +3 -9
- package/docs/components/toast.html +80 -42
- package/docs/components/toggle.html +3 -9
- package/docs/components/tree.html +108 -21
- package/docs/index.html +10 -6
- package/docs/init.js +7 -0
- package/docs/src/components/Icon.js +1 -1
- package/docs/src/components/ShadowComponent.js +1 -1
- package/docs/src/components/Tree.js +37 -0
- package/docs/utils/debounce.html +1 -6
- package/docs/utils/drag.html +1 -6
- package/docs/utils/formatTimestamp.html +1 -6
- package/docs/utils/init.js +7 -0
- package/docs/utils/propConverters.html +1 -6
- package/docs/utils/toTitleCase.html +1 -6
- package/docs/utils/watchWindowSize.html +1 -6
- package/package.json +1 -1
- package/scripts/build.js +12 -2
- package/src/components/Card.js +2 -5
- package/src/components/Dialog.js +48 -34
- package/src/components/Icon.js +25 -18
- package/src/components/Tree.js +64 -72
|
@@ -7,4 +7,4 @@ import ShadowComponent from"./ShadowComponent.js";import{html,css,unsafeHTML}fro
|
|
|
7
7
|
height: 1.35em;
|
|
8
8
|
vertical-align: middle;
|
|
9
9
|
}
|
|
10
|
-
`;render(){return this.iconContent?html`${unsafeHTML(this.iconContent)}`:html`<slot></slot>`}static pathToIcons=["
|
|
10
|
+
`;render(){return this.iconContent?html`${unsafeHTML(this.iconContent)}`:html`<slot></slot>`}static pathToIcons=["./icons"];static fallback='\n\t\t<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path fill="currentColor" d="M480-79q-16 0-30.5-6T423-102L102-423q-11-12-17-26.5T79-480q0-16 6-31t17-26l321-321q12-12 26.5-17.5T480-881q16 0 31 5.5t26 17.5l321 321q12 11 17.5 26t5.5 31q0 16-5.5 30.5T858-423L537-102q-11 11-26 17t-31 6Zm0-80 321-321-321-321-321 321 321 321Zm-40-281h80v-240h-80v240Zm40 120q17 0 28.5-11.5T520-360q0-17-11.5-28.5T480-400q-17 0-28.5 11.5T440-360q0 17 11.5 28.5T480-320Zm0-160Z"/></svg>\n\t'}window.customElements.define("k-icon",Icon);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{LitElement}from"../lit-all.min.js";export default class ShadowComponent extends LitElement{static stylesheetPath="
|
|
1
|
+
import{LitElement}from"../lit-all.min.js";export default class ShadowComponent extends LitElement{static stylesheetPath="./kempo.min.css";createRenderRoot(){const t=this.attachShadow({mode:"open"}),e=document.createElement("link");e.rel="stylesheet",e.href=this.constructor.stylesheetPath,t.appendChild(e);const n=this.constructor.styles;if(n){const e=document.createElement("style");Array.isArray(n)?e.textContent=n.map(t=>t.cssText||t).join("\n"):e.textContent=n.cssText||n,t.appendChild(e)}const s=document.createElement("div");return s.style.display="contents",t.appendChild(s),s}}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import ShadowComponent from"./ShadowComponent.js";import{html,css,render}from"../lit-all.min.js";import{boolExists}from"../utils/propConverters.js";import"./Icon.js";export default class Tree extends ShadowComponent{static properties={data:{type:Object},depth:{type:Number,reflect:!0},editable:{type:Boolean,converter:boolExists,attribute:"editable",reflect:!0}};constructor(){super(),this.data=null,this.depth=0,this.editable=!1}render(){return this.data?"object"==typeof this.data&&null!==this.data?html`
|
|
2
|
+
<div class="tree-root">
|
|
3
|
+
${(Array.isArray(this.data)?this.data.map((e,t)=>[t,e]):Object.entries(this.data)).map(([e,t])=>Tree.renderValue(t,e,1,this.depth))}
|
|
4
|
+
</div>
|
|
5
|
+
`:html`
|
|
6
|
+
<div class="tree-root">
|
|
7
|
+
${Tree.renderValue(this.data,null,0,this.depth)}
|
|
8
|
+
</div>
|
|
9
|
+
`:html`<slot></slot>`}static leafs=[];static addLeaf=(...e)=>{e.forEach(e=>Tree.leafs.unshift(e))};static renderValue(e,t=null,s=0,r=0){const a=Tree.leafs.find(t=>t.detect(e));if(a){const s=document.createElement("span");if(s.className="d-b",null!==t){const e=document.createElement("span");e.className="number"==typeof t?"tc-muted":"",e.textContent=`${t}: `,s.appendChild(e)}const r=new a(e).render();if(r instanceof Node)s.appendChild(r);else{const e=document.createElement("span");render(r,e),s.appendChild(e)}return s}if("object"==typeof e&&null!==e){const a=new TreeBranch;return a.value=e,a.key=t,a.currentDepth=s,a.maxDepth=r,a}return html`<span class="d-b primitive">${null!==t?html`<span class="${"number"==typeof t?"tc-muted":""}">${t}: </span>`:""}${e}</span>`}}window.customElements.define("k-tree",Tree);export class TreeBranch extends ShadowComponent{static properties={value:{type:Object},key:{type:String},currentDepth:{type:Number},maxDepth:{type:Number},opened:{type:Boolean,converter:boolExists,reflect:!0}};constructor(){super(),this.value=null,this.key=null,this.currentDepth=0,this.maxDepth=0,this.opened=!1}connectedCallback(){super.connectedCallback(),this.currentDepth<=this.maxDepth&&(this.opened=!0)}get tree(){return this.closest("k-tree")}toggle=()=>{this.opened=!this.opened};render(){const e=null!==this.key?`${this.key}: `:"",t=Array.isArray(this.value)?"Array":"Object";return html`
|
|
10
|
+
<div>
|
|
11
|
+
<div class="branch-label" @click=${this.toggle}>
|
|
12
|
+
<k-icon name="chevron-right" class="toggle-icon ${this.opened?"opened":""}"></k-icon>
|
|
13
|
+
${e}${t}
|
|
14
|
+
</div>
|
|
15
|
+
${this.opened?html`
|
|
16
|
+
<div class="pl">
|
|
17
|
+
${this.value?(Array.isArray(this.value)?this.value.map((e,t)=>[t,e]):Object.entries(this.value)).map(([e,t])=>Tree.renderValue(t,e,this.currentDepth+1,this.maxDepth)):""}
|
|
18
|
+
</div>
|
|
19
|
+
`:""}
|
|
20
|
+
</div>
|
|
21
|
+
`}static styles=css`
|
|
22
|
+
:host{
|
|
23
|
+
display: block;
|
|
24
|
+
}
|
|
25
|
+
.branch-label{
|
|
26
|
+
cursor: pointer;
|
|
27
|
+
}
|
|
28
|
+
.branch-label:hover{
|
|
29
|
+
background-color: var(--c_bg__alt, #f5f5f5);
|
|
30
|
+
}
|
|
31
|
+
.toggle-icon{
|
|
32
|
+
transition: transform var(--animation_ms, 200ms);
|
|
33
|
+
}
|
|
34
|
+
.toggle-icon.opened{
|
|
35
|
+
transform: rotate(90deg);
|
|
36
|
+
}
|
|
37
|
+
`}window.customElements.define("k-tree-branch",TreeBranch);export class TreeLeaf{constructor(e=null){this.value=e}render(){return html`${this.value}`}static detect=()=>!1}export class StringLeaf extends TreeLeaf{render(){return html`<span class="tc-success">"${this.value}"</span>`}static detect=e=>"string"==typeof e}export class NumberLeaf extends TreeLeaf{render(){return html`<span class="tc-primary">${this.value}</span>`}static detect=e=>"number"==typeof e}export class BooleanLeaf extends TreeLeaf{render(){return html`<span class="${this.value?"tc-success":"tc-danger"}">${this.value}</span>`}static detect=e=>"boolean"==typeof e}export class NullLeaf extends TreeLeaf{render(){return html`<span class="tc-muted">null</span>`}static detect=e=>null===e}export class UndefinedLeaf extends TreeLeaf{render(){return html`<span class="tc-muted">undefined</span>`}static detect=e=>void 0===e}Tree.addLeaf(UndefinedLeaf,NullLeaf,BooleanLeaf,NumberLeaf,StringLeaf);
|
|
@@ -5,15 +5,9 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
6
|
<title>Accordion - Components - Kempo Docs - A Web Components Solution</title>
|
|
7
7
|
<link rel="stylesheet" href="../src/kempo-vars.css" /><link rel="stylesheet" href="../kempo.min.css" />
|
|
8
|
-
<link rel="stylesheet" href="../src/kempo-hljs.css"
|
|
9
|
-
<
|
|
10
|
-
|
|
11
|
-
import Import from '../src/components/Import.js';
|
|
12
|
-
import Icon from '../src/components/Icon.js';
|
|
13
|
-
ShadowComponent.stylesheetPath = '../kempo.min.css';
|
|
14
|
-
Import.replacements.root = '../';
|
|
15
|
-
Icon.pathToIcons = ['../icons'];
|
|
16
|
-
</script>
|
|
8
|
+
<link rel="stylesheet" href="../src/kempo-hljs.css" />
|
|
9
|
+
<link rel="stylesheet" href="../styles.css" />
|
|
10
|
+
<script type="module" src="./init.js"></script>
|
|
17
11
|
</head>
|
|
18
12
|
<body>
|
|
19
13
|
<k-import src="../nav.inc.html"></k-import>
|
|
@@ -5,15 +5,9 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
6
|
<title>Card - Components - Kempo Docs - A Web Components Solution</title>
|
|
7
7
|
<link rel="stylesheet" href="../src/kempo-vars.css" /><link rel="stylesheet" href="../kempo.min.css" />
|
|
8
|
-
<link rel="stylesheet" href="../src/kempo-hljs.css"
|
|
9
|
-
<
|
|
10
|
-
|
|
11
|
-
import Import from '../src/components/Import.js';
|
|
12
|
-
import Icon from '../src/components/Icon.js';
|
|
13
|
-
ShadowComponent.stylesheetPath = '../kempo.min.css';
|
|
14
|
-
Import.replacements.root = '../';
|
|
15
|
-
Icon.pathToIcons = ['../icons'];
|
|
16
|
-
</script>
|
|
8
|
+
<link rel="stylesheet" href="../src/kempo-hljs.css" />
|
|
9
|
+
<link rel="stylesheet" href="../styles.css" />
|
|
10
|
+
<script type="module" src="./init.js"></script>
|
|
17
11
|
</head>
|
|
18
12
|
<body>
|
|
19
13
|
<k-import src="../nav.inc.html"></k-import>
|
|
@@ -5,15 +5,9 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
6
|
<title>Collapsible - Components - Kempo Docs - A Web Components Solution</title>
|
|
7
7
|
<link rel="stylesheet" href="../src/kempo-vars.css" /><link rel="stylesheet" href="../kempo.min.css" />
|
|
8
|
-
<link rel="stylesheet" href="../src/kempo-hljs.css"
|
|
9
|
-
<
|
|
10
|
-
|
|
11
|
-
import Import from '../src/components/Import.js';
|
|
12
|
-
import Icon from '../src/components/Icon.js';
|
|
13
|
-
ShadowComponent.stylesheetPath = '../kempo.min.css';
|
|
14
|
-
Import.replacements.root = '../';
|
|
15
|
-
Icon.pathToIcons = ['../icons'];
|
|
16
|
-
</script>
|
|
8
|
+
<link rel="stylesheet" href="../src/kempo-hljs.css" />
|
|
9
|
+
<link rel="stylesheet" href="../styles.css" />
|
|
10
|
+
<script type="module" src="./init.js"></script>
|
|
17
11
|
</head>
|
|
18
12
|
<body>
|
|
19
13
|
<k-import src="../nav.inc.html"></k-import>
|
|
@@ -5,15 +5,9 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
6
|
<title>Content Slider - Components - Kempo Docs - A Web Components Solution</title>
|
|
7
7
|
<link rel="stylesheet" href="../src/kempo-vars.css" /><link rel="stylesheet" href="../kempo.min.css" />
|
|
8
|
-
<link rel="stylesheet" href="../src/kempo-hljs.css"
|
|
9
|
-
<
|
|
10
|
-
|
|
11
|
-
import Import from '../src/components/Import.js';
|
|
12
|
-
import Icon from '../src/components/Icon.js';
|
|
13
|
-
ShadowComponent.stylesheetPath = '../kempo.min.css';
|
|
14
|
-
Import.replacements.root = '../';
|
|
15
|
-
Icon.pathToIcons = ['../icons'];
|
|
16
|
-
</script>
|
|
8
|
+
<link rel="stylesheet" href="../src/kempo-hljs.css" />
|
|
9
|
+
<link rel="stylesheet" href="../styles.css" />
|
|
10
|
+
<script type="module" src="./init.js"></script>
|
|
17
11
|
</head>
|
|
18
12
|
<body>
|
|
19
13
|
<k-import src="../nav.inc.html"></k-import>
|
|
@@ -217,6 +211,7 @@
|
|
|
217
211
|
<p>Custom content for the next button. Defaults to a right chevron icon if not provided.</p>
|
|
218
212
|
|
|
219
213
|
</main>
|
|
214
|
+
<div style="height:33vh"></div>
|
|
220
215
|
<script type="module" src="../src/components/Import.js"></script>
|
|
221
216
|
<script type="module" src="../src/components/ContentSlider.js"></script>
|
|
222
217
|
</body>
|
|
@@ -5,15 +5,9 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
6
|
<title>Dialog - Components - Kempo Docs - A Web Components Solution</title>
|
|
7
7
|
<link rel="stylesheet" href="../src/kempo-vars.css" /><link rel="stylesheet" href="../kempo.min.css" />
|
|
8
|
-
<link rel="stylesheet" href="../src/kempo-hljs.css"
|
|
9
|
-
<
|
|
10
|
-
|
|
11
|
-
import Import from '../src/components/Import.js';
|
|
12
|
-
import Icon from '../src/components/Icon.js';
|
|
13
|
-
ShadowComponent.stylesheetPath = '../kempo.min.css';
|
|
14
|
-
Import.replacements.root = '../';
|
|
15
|
-
Icon.pathToIcons = ['../icons'];
|
|
16
|
-
</script>
|
|
8
|
+
<link rel="stylesheet" href="../src/kempo-hljs.css" />
|
|
9
|
+
<link rel="stylesheet" href="../styles.css" />
|
|
10
|
+
<script type="module" src="./init.js"></script>
|
|
17
11
|
</head>
|
|
18
12
|
<body>
|
|
19
13
|
<k-import src="../nav.inc.html"></k-import>
|
|
@@ -28,10 +22,12 @@
|
|
|
28
22
|
<a href="#titles">Titles</a><br />
|
|
29
23
|
<a href="#actionButtons">Action Buttons</a><br />
|
|
30
24
|
<a href="#jsUsage">JavaScript Usage</a><br />
|
|
25
|
+
<a href="#confirmDialog">Confirm Dialog</a><br />
|
|
31
26
|
|
|
32
27
|
<h6 class="mt">JavaScript Reference</h6>
|
|
33
28
|
<a href="#constructor">Constructor</a><br />
|
|
34
29
|
<a href="#requirements">Requirements</a><br />
|
|
30
|
+
<a href="#attributes">Attributes</a><br />
|
|
35
31
|
<a href="#properties">Properties</a><br />
|
|
36
32
|
<a href="#methods">Methods</a><br />
|
|
37
33
|
<a href="#staticMethods">Static Methods</a><br />
|
|
@@ -40,7 +36,7 @@
|
|
|
40
36
|
|
|
41
37
|
<h3 id="basicUsage"><a href="#basicUsage" class="no-link">Basic Usage</a></h3>
|
|
42
38
|
<p>Create dialogs using the <code>k-dialog</code> component. Open the dialog by calling the <code>open()</code> method, and close it by calling the <code>close()</code> method. Or it can be closed using the dialog's GUI (clicking the overlay, clicking the close button, or the cancel or confirm action buttons).</p>
|
|
43
|
-
<pre><code class="hljs xml"><span class="hljs-tag"><<span class="hljs-name">k-dialog</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"d1"</span>></span><br /> <span class="hljs-tag"><<span class="hljs-name">p</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"p"</span>></span>Hello World<span class="hljs-tag"></<span class="hljs-name">p</span>></span><br /><span class="hljs-tag"></<span class="hljs-name">k-dialog</span>></span><br /><span class="hljs-tag"><<span class="hljs-name">button</span> <span class="hljs-attr">onclick</span>=<span class="hljs-string">"
|
|
39
|
+
<pre><code class="hljs xml"><span class="hljs-tag"><<span class="hljs-name">k-dialog</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"d1"</span>></span><br /> <span class="hljs-tag"><<span class="hljs-name">p</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"p"</span>></span>Hello World<span class="hljs-tag"></<span class="hljs-name">p</span>></span><br /><span class="hljs-tag"></<span class="hljs-name">k-dialog</span>></span><br /><span class="hljs-tag"><<span class="hljs-name">button</span> <span class="hljs-attr">onclick</span>=<span class="hljs-string">"document.getElementById('d1').open()"</span>></span>Open Dialog<span class="hljs-tag"></<span class="hljs-name">button</span>></span></code></pre>
|
|
44
40
|
<button class="openDialog mb" data-dialog="d1" slot="right">Open Dialog</button>
|
|
45
41
|
<k-dialog id="d1">
|
|
46
42
|
<p class="p">Hello World</p>
|
|
@@ -94,20 +90,32 @@
|
|
|
94
90
|
|
|
95
91
|
<h3 id="jsUsage"><a href="#jsUsage" class="no-link">JavaScript Usage</a></h3>
|
|
96
92
|
<h5>Create Dialog</h5>
|
|
97
|
-
<pre><code class="hljs xml"><span class="hljs-tag"><<span class="hljs-name">button</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"d7"</span>></span>Open Dialog<span class="hljs-tag"></<span class="hljs-name">button</span>></span><br /><span class="hljs-tag"><<span class="hljs-name">script</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"module"</span>></span><span class="javascript"><br /> <span class="hljs-keyword">import</span> Dialog <span class="hljs-keyword">from</span> <span class="hljs-string">'
|
|
93
|
+
<pre><code class="hljs xml"><span class="hljs-tag"><<span class="hljs-name">button</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"d7"</span>></span>Open Dialog<span class="hljs-tag"></<span class="hljs-name">button</span>></span><br /><span class="hljs-tag"><<span class="hljs-name">script</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"module"</span>></span><span class="javascript"><br /> <span class="hljs-keyword">import</span> Dialog <span class="hljs-keyword">from</span> <span class="hljs-string">'../src/components/Dialog.js'</span>;<br /> <span class="hljs-built_in">document</span>.getElementById(<span class="hljs-string">'d7'</span>).addEventListener(<span class="hljs-string">'click'</span>, () => {<br /> Dialog.create(<span class="hljs-string">'Hello World'</span>);<br /> });<br /></span><span class="hljs-tag"></<span class="hljs-name">script</span>></span></code></pre>
|
|
98
94
|
<button id="d7" class="mb">Open Dialog</button>
|
|
99
95
|
<script type="module">
|
|
100
|
-
import Dialog from '
|
|
96
|
+
import Dialog from '../src/components/Dialog.js';
|
|
101
97
|
document.getElementById('d7').addEventListener('click', () => {
|
|
102
|
-
Dialog.create('
|
|
98
|
+
Dialog.create('Hello World');
|
|
99
|
+
});
|
|
100
|
+
</script>
|
|
101
|
+
|
|
102
|
+
<h5>Dialog with Title</h5>
|
|
103
|
+
<pre><code class="hljs xml"><span class="hljs-tag"><<span class="hljs-name">button</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"d7b"</span>></span>Open Dialog with Title<span class="hljs-tag"></<span class="hljs-name">button</span>></span><br /><span class="hljs-tag"><<span class="hljs-name">script</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"module"</span>></span><span class="javascript"><br /> <span class="hljs-keyword">import</span> Dialog <span class="hljs-keyword">from</span> <span class="hljs-string">'../src/components/Dialog.js'</span>;<br /> <span class="hljs-built_in">document</span>.getElementById(<span class="hljs-string">'d7b'</span>).addEventListener(<span class="hljs-string">'click'</span>, () => {<br /> Dialog.create(<span class="hljs-string">'This is the dialog content'</span>, {<br /> <span class="hljs-attr">title</span>: <span class="hljs-string">'My Dialog Title'</span><br /> });<br /> });<br /></span><span class="hljs-tag"></<span class="hljs-name">script</span>></span></code></pre>
|
|
104
|
+
<button id="d7b" class="mb">Open Dialog with Title</button>
|
|
105
|
+
<script type="module">
|
|
106
|
+
import Dialog from '../src/components/Dialog.js';
|
|
107
|
+
document.getElementById('d7b').addEventListener('click', () => {
|
|
108
|
+
Dialog.create('This is the dialog content', {
|
|
109
|
+
title: 'My Dialog Title'
|
|
110
|
+
});
|
|
103
111
|
});
|
|
104
112
|
</script>
|
|
105
113
|
|
|
106
114
|
<h5>Error Dialog</h5>
|
|
107
|
-
<pre><code class="hljs xml"><span class="hljs-tag"><<span class="hljs-name">button</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"d8"</span>></span>Open Dialog<span class="hljs-tag"></<span class="hljs-name">button</span>></span><br /><span class="hljs-tag"><<span class="hljs-name">script</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"module"</span>></span><span class="javascript"><br /> <span class="hljs-keyword">import</span> Dialog <span class="hljs-keyword">from</span> <span class="hljs-string">'
|
|
115
|
+
<pre><code class="hljs xml"><span class="hljs-tag"><<span class="hljs-name">button</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"d8"</span>></span>Open Dialog<span class="hljs-tag"></<span class="hljs-name">button</span>></span><br /><span class="hljs-tag"><<span class="hljs-name">script</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"module"</span>></span><span class="javascript"><br /> <span class="hljs-keyword">import</span> Dialog <span class="hljs-keyword">from</span> <span class="hljs-string">'../src/components/Dialog.js'</span>;<br /> <span class="hljs-built_in">document</span>.getElementById(<span class="hljs-string">'d8'</span>).addEventListener(<span class="hljs-string">'click'</span>, () => {<br /> Dialog.error(<span class="hljs-string">"Oh no, don't do that!"</span>);<br /> });<br /></span><span class="hljs-tag"></<span class="hljs-name">script</span>></span></code></pre>
|
|
108
116
|
<button id="d8" class="mb">Open Dialog</button>
|
|
109
117
|
<script type="module">
|
|
110
|
-
import Dialog from '
|
|
118
|
+
import Dialog from '../src/components/Dialog.js';
|
|
111
119
|
document.getElementById('d8').addEventListener('click', () => {
|
|
112
120
|
Dialog.error("Oh no, don't do that!");
|
|
113
121
|
});
|
|
@@ -115,10 +123,10 @@
|
|
|
115
123
|
|
|
116
124
|
<h3 id="confirmDialog"><a href="#confirmDialog" class="no-link">Confirm Dialog</a></h3>
|
|
117
125
|
<p>Use the <code>Dialog.confirm</code> static method to create a confirmation dialog. This method takes a text message, a response callback, and an options object.</p>
|
|
118
|
-
<pre><code class="hljs xml"><span class="hljs-tag"><<span class="hljs-name">button</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"d9"</span>></span>Open Confirm Dialog<span class="hljs-tag"></<span class="hljs-name">button</span>></span><br /><span class="hljs-tag"><<span class="hljs-name">script</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"module"</span>></span><span class="javascript"><br /> <span class="hljs-keyword">import</span> Dialog <span class="hljs-keyword">from</span> <span class="hljs-string">'
|
|
126
|
+
<pre><code class="hljs xml"><span class="hljs-tag"><<span class="hljs-name">button</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"d9"</span>></span>Open Confirm Dialog<span class="hljs-tag"></<span class="hljs-name">button</span>></span><br /><span class="hljs-tag"><<span class="hljs-name">script</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"module"</span>></span><span class="javascript"><br /> <span class="hljs-keyword">import</span> Dialog <span class="hljs-keyword">from</span> <span class="hljs-string">'../src/components/Dialog.js'</span>;<br /> <span class="hljs-built_in">document</span>.getElementById(<span class="hljs-string">'d9'</span>).addEventListener(<span class="hljs-string">'click'</span>, () => {<br /> Dialog.confirm(<span class="hljs-string">"Are you sure you want to proceed?"</span>, <span class="hljs-function"><span class="hljs-params">response</span> =></span> {<br /> <span class="hljs-built_in">console</span>.log(<span class="hljs-string">"User response:"</span>, response);<br /> });<br /> });<br /></span><span class="hljs-tag"></<span class="hljs-name">script</span>></span></code></pre>
|
|
119
127
|
<button id="d9" class="mb">Open Confirm Dialog</button>
|
|
120
128
|
<script type="module">
|
|
121
|
-
import Dialog from '
|
|
129
|
+
import Dialog from '../src/components/Dialog.js';
|
|
122
130
|
document.getElementById('d9').addEventListener('click', () => {
|
|
123
131
|
Dialog.confirm("Are you sure you want to proceed?", response => {
|
|
124
132
|
console.log("User response:", response);
|
|
@@ -129,62 +137,102 @@
|
|
|
129
137
|
<h2 id="jsRef">JavaScript Reference</h2>
|
|
130
138
|
|
|
131
139
|
<h3 id="constructor"><a href="#constructor" class="no-link">Constructor</a></h3>
|
|
132
|
-
<h6>Extends <a href="./
|
|
140
|
+
<h6>Extends <a href="./shadow-component.html">ShadowComponent</a></h6>
|
|
133
141
|
<h5>
|
|
134
|
-
<code>new Dialog()</code
|
|
142
|
+
<code>new Dialog()</code><br />
|
|
143
|
+
<code>new Dialog(<i>object</i> options)</code>
|
|
135
144
|
</h5>
|
|
136
145
|
|
|
137
146
|
<h4>Parameters</h4>
|
|
138
|
-
<
|
|
147
|
+
<h5><code>options<i>: object</i></code></h5>
|
|
148
|
+
<p>An object containing the initial configuration for the dialog. The options object can contain the following properties:</p>
|
|
149
|
+
<ul>
|
|
150
|
+
<li><code>opened</code>: <i>boolean</i> - Whether the dialog is initially opened.</li>
|
|
151
|
+
<li><code>closeBtn</code>: <i>boolean</i> - Whether to show the close button.</li>
|
|
152
|
+
<li><code>overlayClose</code>: <i>boolean</i> - Whether clicking the overlay closes the dialog.</li>
|
|
153
|
+
<li><code>confirmText</code>: <i>string</i> - Text for the confirm button.</li>
|
|
154
|
+
<li><code>confirmClasses</code>: <i>string</i> - Classes for the confirm button.</li>
|
|
155
|
+
<li><code>confirmAction</code>: <i>function</i> - Action to perform on confirm.</li>
|
|
156
|
+
<li><code>cancelText</code>: <i>string</i> - Text for the cancel button.</li>
|
|
157
|
+
<li><code>cancelClasses</code>: <i>string</i> - Classes for the cancel button.</li>
|
|
158
|
+
<li><code>cancelAction</code>: <i>function</i> - Action to perform on cancel.</li>
|
|
159
|
+
<li><code>closeCallback</code>: <i>function</i> - Callback to execute when the dialog is closed.</li>
|
|
160
|
+
</ul>
|
|
139
161
|
|
|
140
162
|
<h3 id="requirements"><a href="#requirements" class="no-link">Requirements</a></h3>
|
|
141
163
|
<ul>
|
|
142
164
|
<li><a href="./shadow-component.html">ShadowComponent</a></li>
|
|
143
165
|
<li><a href="./icon.html">Icon</a></li>
|
|
166
|
+
<li><a href="./focus-capture.html">FocusCapture</a></li>
|
|
144
167
|
</ul>
|
|
145
168
|
|
|
146
|
-
<h3 id="
|
|
169
|
+
<h3 id="attributes"><a href="#attributes" class="no-link">Attributes</a></h3>
|
|
147
170
|
<h5><code>opened<i>: boolean</i></code></h5>
|
|
148
|
-
<p>Whether the dialog is opened
|
|
149
|
-
|
|
150
|
-
<
|
|
151
|
-
<
|
|
152
|
-
|
|
153
|
-
<h5><code>
|
|
154
|
-
<p>
|
|
155
|
-
|
|
156
|
-
<
|
|
157
|
-
<
|
|
158
|
-
|
|
159
|
-
<h5><code>
|
|
160
|
-
<p>Classes for the
|
|
171
|
+
<p>Whether the dialog is opened.</p>
|
|
172
|
+
|
|
173
|
+
<h5><code>close-btn<i>: boolean</i></code></h5>
|
|
174
|
+
<p>Whether to show the close button. Default is <code>true</code>.</p>
|
|
175
|
+
|
|
176
|
+
<h5><code>overlay-close<i>: boolean</i></code></h5>
|
|
177
|
+
<p>Whether clicking the overlay closes the dialog. Default is <code>true</code>.</p>
|
|
178
|
+
|
|
179
|
+
<h5><code>confirm-text<i>: string</i></code></h5>
|
|
180
|
+
<p>Text for the confirm button.</p>
|
|
181
|
+
|
|
182
|
+
<h5><code>confirm-classes<i>: string</i></code></h5>
|
|
183
|
+
<p>Classes for the confirm button. Default is <code>'success ml'</code>.</p>
|
|
184
|
+
|
|
185
|
+
<h5><code>cancel-text<i>: string</i></code></h5>
|
|
186
|
+
<p>Text for the cancel button.</p>
|
|
187
|
+
|
|
188
|
+
<h5><code>cancel-classes<i>: string</i></code></h5>
|
|
189
|
+
<p>Classes for the cancel button.</p>
|
|
190
|
+
|
|
191
|
+
<h3 id="properties"><a href="#properties" class="no-link">Properties</a></h3>
|
|
161
192
|
<h5><code>confirmAction<i>: function</i></code></h5>
|
|
162
|
-
<p>Action to perform
|
|
193
|
+
<p>Action to perform on confirm. If the function calls <code>event.preventDefault()</code>, the dialog will not close automatically.</p>
|
|
194
|
+
|
|
163
195
|
<h5><code>cancelAction<i>: function</i></code></h5>
|
|
164
|
-
<p>Action to perform
|
|
196
|
+
<p>Action to perform on cancel. If the function calls <code>event.preventDefault()</code>, the dialog will not close automatically.</p>
|
|
197
|
+
|
|
165
198
|
<h5><code>closeCallback<i>: function</i></code></h5>
|
|
166
|
-
<p>Callback to execute when the dialog is closed
|
|
167
|
-
|
|
168
|
-
<
|
|
199
|
+
<p>Callback to execute when the dialog is closed.</p>
|
|
200
|
+
|
|
201
|
+
<h5><code>previousFocus<i>: HTMLElement</i></code></h5>
|
|
202
|
+
<p>Reference to the element that had focus before the dialog was opened.</p>
|
|
169
203
|
|
|
170
204
|
<h3 id="methods"><a href="#methods" class="no-link">Methods</a></h3>
|
|
171
205
|
<h5><code>open()<i>: void</i></code></h5>
|
|
172
|
-
<p>Opens the dialog.</p>
|
|
206
|
+
<p>Opens the dialog and sets focus to the first focusable element or an element with the <code>autofocus</code> attribute.</p>
|
|
207
|
+
|
|
173
208
|
<h5><code>close()<i>: void</i></code></h5>
|
|
174
|
-
<p>Closes the dialog
|
|
209
|
+
<p>Closes the dialog and calls the <code>closeCallback</code>.</p>
|
|
210
|
+
|
|
175
211
|
<h5><code>toggle()<i>: void</i></code></h5>
|
|
176
212
|
<p>Toggles the dialog open or closed.</p>
|
|
213
|
+
|
|
177
214
|
<h5><code>focus()<i>: void</i></code></h5>
|
|
178
|
-
<p>Focuses the first focusable element in the dialog.</p>
|
|
215
|
+
<p>Focuses the first focusable element in the dialog and saves the previously focused element.</p>
|
|
216
|
+
|
|
179
217
|
<h5><code>blur()<i>: void</i></code></h5>
|
|
180
218
|
<p>Returns focus to the element that had focus before the dialog was opened.</p>
|
|
181
219
|
|
|
182
220
|
<h3 id="staticMethods"><a href="#staticMethods" class="no-link">Static Methods</a></h3>
|
|
183
|
-
<h5><code>create(contents, options)<i>: Dialog</i></code></h5>
|
|
184
|
-
<p>Creates and opens a new dialog with the specified contents and options.</p>
|
|
221
|
+
<h5><code>Dialog.create(contents, options)<i>: Dialog</i></code></h5>
|
|
222
|
+
<p>Creates and opens a new dialog with the specified contents and options. Returns the created Dialog instance.</p>
|
|
223
|
+
<p>If <code>contents</code> is plain text (no HTML tags), it will automatically be wrapped in a <code><p class="p"></code> tag. If it contains HTML, it will be inserted as-is. If it's an HTMLElement or DocumentFragment, it will be appended directly.</p>
|
|
224
|
+
|
|
225
|
+
<h6>Parameters</h6>
|
|
226
|
+
<ul>
|
|
227
|
+
<li><code>contents<i>: string | HTMLElement | DocumentFragment</i></code> - The content to display in the dialog. Plain text will be wrapped in a paragraph tag automatically.</li>
|
|
228
|
+
<li><code>options<i>: object</i></code> - Configuration options for the dialog.</li>
|
|
229
|
+
</ul>
|
|
230
|
+
|
|
185
231
|
<h6>Options</h6>
|
|
186
232
|
<ul>
|
|
187
|
-
<li><code>
|
|
233
|
+
<li><code>title</code>: <i>string | HTMLElement</i> - The title to display in the dialog header. Will be wrapped in an <code><h5></code> tag with the <code>title</code> slot.</li>
|
|
234
|
+
<li><code>titleClasses</code>: <i>string</i> - CSS classes for the title element. Default is <code>'pyh px m0'</code>.</li>
|
|
235
|
+
<li><code>opened</code>: <i>boolean</i> - Whether the dialog is initially opened. Default is <code>true</code>.</li>
|
|
188
236
|
<li><code>closeBtn</code>: <i>boolean</i> - Whether to show the close button.</li>
|
|
189
237
|
<li><code>overlayClose</code>: <i>boolean</i> - Whether clicking the overlay closes the dialog.</li>
|
|
190
238
|
<li><code>confirmText</code>: <i>string</i> - Text for the confirm button.</li>
|
|
@@ -194,50 +242,87 @@
|
|
|
194
242
|
<li><code>cancelClasses</code>: <i>string</i> - Classes for the cancel button.</li>
|
|
195
243
|
<li><code>cancelAction</code>: <i>function</i> - Action to perform on cancel.</li>
|
|
196
244
|
<li><code>closeCallback</code>: <i>function</i> - Callback to execute when the dialog is closed.</li>
|
|
245
|
+
<li><code>removeOnClose</code>: <i>boolean</i> - Whether to remove the dialog from the DOM when closed. Default is <code>true</code>.</li>
|
|
246
|
+
<li><code>closeExisting</code>: <i>boolean</i> - Whether to close existing dialogs before opening this one. Default is <code>true</code>.</li>
|
|
247
|
+
<li><code>width</code>: <i>string</i> - CSS width value for the dialog.</li>
|
|
248
|
+
<li><code>minWidth</code>: <i>string</i> - CSS min-width value for the dialog.</li>
|
|
249
|
+
<li><code>maxWidth</code>: <i>string</i> - CSS max-width value for the dialog.</li>
|
|
250
|
+
<li><code>height</code>: <i>string</i> - CSS height value for the dialog.</li>
|
|
251
|
+
<li><code>minHeight</code>: <i>string</i> - CSS min-height value for the dialog.</li>
|
|
252
|
+
<li><code>maxHeight</code>: <i>string</i> - CSS max-height value for the dialog.</li>
|
|
197
253
|
</ul>
|
|
198
|
-
|
|
199
|
-
<
|
|
254
|
+
|
|
255
|
+
<h5><code>Dialog.confirm(text, responseCallback, options)<i>: Dialog</i></code></h5>
|
|
256
|
+
<p>Creates and opens a confirmation dialog with the specified text and options. The response callback receives a boolean value indicating whether the user confirmed (<code>true</code>) or canceled (<code>false</code>).</p>
|
|
257
|
+
|
|
258
|
+
<h6>Parameters</h6>
|
|
259
|
+
<ul>
|
|
260
|
+
<li><code>text<i>: string</i></code> - The message to display in the dialog.</li>
|
|
261
|
+
<li><code>responseCallback<i>: function</i></code> - Function called with the user's response (<code>true</code> for confirm, <code>false</code> for cancel).</li>
|
|
262
|
+
<li><code>options<i>: object</i></code> - Configuration options.</li>
|
|
263
|
+
</ul>
|
|
264
|
+
|
|
200
265
|
<h6>Options</h6>
|
|
201
266
|
<ul>
|
|
202
|
-
<li><code>title</code>: <i>string</i> - The title of the dialog
|
|
203
|
-
<li><code>confirmText</code>: <i>string</i> - Text for the confirm button
|
|
204
|
-
<li><code>confirmClasses</code>: <i>string</i> - Classes for the confirm button
|
|
205
|
-
<li><code>cancelText</code>: <i>string</i> - Text for the cancel button
|
|
206
|
-
<li><code>cancelClasses</code>: <i>string</i> - Classes for the cancel button
|
|
207
|
-
<li><code>closeBtn</code>: <i>boolean</i> - Whether to show the close button
|
|
208
|
-
<li><code>overlayClose</code>: <i>boolean</i> - Whether clicking the overlay closes the dialog
|
|
267
|
+
<li><code>title</code>: <i>string</i> - The title of the dialog. Default is <code>'Confirm'</code>.</li>
|
|
268
|
+
<li><code>confirmText</code>: <i>string</i> - Text for the confirm button. Default is <code>'Yes'</code>.</li>
|
|
269
|
+
<li><code>confirmClasses</code>: <i>string</i> - Classes for the confirm button. Default is <code>'success ml'</code>.</li>
|
|
270
|
+
<li><code>cancelText</code>: <i>string</i> - Text for the cancel button. Default is <code>'No'</code>.</li>
|
|
271
|
+
<li><code>cancelClasses</code>: <i>string</i> - Classes for the cancel button. Default is <code>'danger'</code>.</li>
|
|
272
|
+
<li><code>closeBtn</code>: <i>boolean</i> - Whether to show the close button. Default is <code>false</code>.</li>
|
|
273
|
+
<li><code>overlayClose</code>: <i>boolean</i> - Whether clicking the overlay closes the dialog. Default is <code>false</code>.</li>
|
|
209
274
|
</ul>
|
|
210
|
-
|
|
275
|
+
|
|
276
|
+
<h5><code>Dialog.alert(text, responseCallback, options)<i>: Dialog</i></code></h5>
|
|
211
277
|
<p>Creates and opens an alert dialog with the specified text and options.</p>
|
|
278
|
+
|
|
279
|
+
<h6>Parameters</h6>
|
|
280
|
+
<ul>
|
|
281
|
+
<li><code>text<i>: string</i></code> - The message to display in the dialog.</li>
|
|
282
|
+
<li><code>responseCallback<i>: function</i></code> - Function called when the dialog is closed.</li>
|
|
283
|
+
<li><code>options<i>: object</i></code> - Configuration options.</li>
|
|
284
|
+
</ul>
|
|
285
|
+
|
|
212
286
|
<h6>Options</h6>
|
|
213
287
|
<ul>
|
|
214
|
-
<li><code>title</code>: <i>string</i> - The title of the dialog
|
|
215
|
-
<li><code>cancelText</code>: <i>string</i> - Text for the
|
|
216
|
-
|
|
217
|
-
|
|
288
|
+
<li><code>title</code>: <i>string</i> - The title of the dialog. Default is <code>'Alert'</code>.</li>
|
|
289
|
+
<li><code>cancelText</code>: <i>string</i> - Text for the OK button. Default is <code>'Ok'</code>.</li>
|
|
290
|
+
</ul>
|
|
291
|
+
|
|
292
|
+
<h5><code>Dialog.error(text, responseCallback, options)<i>: Dialog</i></code></h5>
|
|
293
|
+
<p>Creates and opens an error dialog with the specified text and options. The title is displayed in red.</p>
|
|
294
|
+
|
|
295
|
+
<h6>Parameters</h6>
|
|
296
|
+
<ul>
|
|
297
|
+
<li><code>text<i>: string</i></code> - The error message to display in the dialog.</li>
|
|
298
|
+
<li><code>responseCallback<i>: function</i></code> - Function called when the dialog is closed.</li>
|
|
299
|
+
<li><code>options<i>: object</i></code> - Configuration options.</li>
|
|
218
300
|
</ul>
|
|
219
|
-
|
|
220
|
-
<p>Creates and opens an error dialog with the specified text and options.</p>
|
|
301
|
+
|
|
221
302
|
<h6>Options</h6>
|
|
222
303
|
<ul>
|
|
223
|
-
<li><code>title</code>: <i>string</i> - The title of the dialog
|
|
224
|
-
<li><code>cancelText</code>: <i>string</i> - Text for the
|
|
225
|
-
<li><code>closeBtn</code>: <i>boolean</i> - Whether to show the close button.</li>
|
|
226
|
-
<li><code>overlayClose</code>: <i>boolean</i> - Whether clicking the overlay closes the dialog.</li>
|
|
304
|
+
<li><code>title</code>: <i>string</i> - The title of the dialog. Default is <code>'Error'</code>.</li>
|
|
305
|
+
<li><code>cancelText</code>: <i>string</i> - Text for the OK button. Default is <code>'Ok'</code>.</li>
|
|
227
306
|
</ul>
|
|
228
|
-
|
|
229
|
-
<
|
|
307
|
+
|
|
308
|
+
<h5><code>Dialog.success(text, responseCallback, options)<i>: Dialog</i></code></h5>
|
|
309
|
+
<p>Creates and opens a success dialog with the specified text and options. The title is displayed in green.</p>
|
|
310
|
+
|
|
311
|
+
<h6>Parameters</h6>
|
|
312
|
+
<ul>
|
|
313
|
+
<li><code>text<i>: string</i></code> - The success message to display in the dialog.</li>
|
|
314
|
+
<li><code>responseCallback<i>: function</i></code> - Function called when the dialog is closed.</li>
|
|
315
|
+
<li><code>options<i>: object</i></code> - Configuration options.</li>
|
|
316
|
+
</ul>
|
|
317
|
+
|
|
230
318
|
<h6>Options</h6>
|
|
231
319
|
<ul>
|
|
232
|
-
<li><code>title</code>: <i>string</i> - The title of the dialog
|
|
233
|
-
<li><code>cancelText</code>: <i>string</i> - Text for the
|
|
234
|
-
<li><code>closeBtn</code>: <i>boolean</i> - Whether to show the close button.</li>
|
|
235
|
-
<li><code>overlayClose</code>: <i>boolean</i> - Whether clicking the overlay closes the dialog.</li>
|
|
320
|
+
<li><code>title</code>: <i>string</i> - The title of the dialog. Default is <code>'Success'</code>.</li>
|
|
321
|
+
<li><code>cancelText</code>: <i>string</i> - Text for the OK button. Default is <code>'Ok'</code>.</li>
|
|
236
322
|
</ul>
|
|
237
323
|
|
|
238
324
|
</main>
|
|
239
325
|
<div style="height:33vh"></div>
|
|
240
|
-
<script type="module" src="../src/components/Import.js"></script>
|
|
241
326
|
<script type="module" src="../src/components/Dialog.js"></script>
|
|
242
327
|
<script>
|
|
243
328
|
document.querySelectorAll('.openDialog').forEach( $btn => {
|
|
@@ -5,13 +5,9 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
6
|
<title>FocusCapture - Components - Kempo Docs - A Web Components Solution</title>
|
|
7
7
|
<link rel="stylesheet" href="../src/kempo-vars.css" /><link rel="stylesheet" href="../kempo.min.css" />
|
|
8
|
-
<link rel="stylesheet" href="../src/kempo-hljs.css"
|
|
9
|
-
<
|
|
10
|
-
|
|
11
|
-
import Icon from '../src/components/Icon.js';
|
|
12
|
-
Import.replacements.root = '../';
|
|
13
|
-
Icon.pathToIcons = ['../icons'];
|
|
14
|
-
</script>
|
|
8
|
+
<link rel="stylesheet" href="../src/kempo-hljs.css" />
|
|
9
|
+
<link rel="stylesheet" href="../styles.css" />
|
|
10
|
+
<script type="module" src="./init.js"></script>
|
|
15
11
|
</head>
|
|
16
12
|
<body>
|
|
17
13
|
<k-import src="../nav.inc.html"></k-import>
|
|
@@ -5,13 +5,9 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
6
|
<title>HybridComponent - Base Components - Kempo Docs - A Web Components Solution</title>
|
|
7
7
|
<link rel="stylesheet" href="../src/kempo-vars.css" /><link rel="stylesheet" href="../kempo.min.css" />
|
|
8
|
-
<link rel="stylesheet" href="../src/kempo-hljs.css"
|
|
9
|
-
<
|
|
10
|
-
|
|
11
|
-
import Icon from '../src/components/Icon.js';
|
|
12
|
-
Import.replacements.root = '../';
|
|
13
|
-
Icon.pathToIcons = ['../icons'];
|
|
14
|
-
</script>
|
|
8
|
+
<link rel="stylesheet" href="../src/kempo-hljs.css" />
|
|
9
|
+
<link rel="stylesheet" href="../styles.css" />
|
|
10
|
+
<script type="module" src="./init.js"></script>
|
|
15
11
|
</head>
|
|
16
12
|
<body>
|
|
17
13
|
<k-import src="../nav.inc.html"></k-import>
|
|
@@ -7,12 +7,7 @@
|
|
|
7
7
|
<link rel="stylesheet" href="../src/kempo-vars.css" /><link rel="stylesheet" href="../kempo.css" />
|
|
8
8
|
<link rel="stylesheet" href="../src/kempo-hljs.css" />
|
|
9
9
|
<link rel="stylesheet" href="../styles.css" />
|
|
10
|
-
<script type="module">
|
|
11
|
-
import Import from '../src/components/Import.js';
|
|
12
|
-
import Icon from '../src/components/Icon.js';
|
|
13
|
-
Import.replacements.root = '../';
|
|
14
|
-
Icon.pathToIcons = ['../icons'];
|
|
15
|
-
</script>
|
|
10
|
+
<script type="module" src="./init.js"></script>
|
|
16
11
|
</head>
|
|
17
12
|
<body>
|
|
18
13
|
<k-import src="../nav.inc.html"></k-import>
|
|
@@ -66,7 +61,7 @@
|
|
|
66
61
|
</div>
|
|
67
62
|
|
|
68
63
|
<h3 id="explicitSource"><a href="#explicitSource" class="no-link">Explicitly Set the Source</a></h3>
|
|
69
|
-
<p>You can use any
|
|
64
|
+
<p>You can use any SVG file that is publicly available (on your site or any other public domain) by using the <code>src</code> attribute instead of <code>name</code>. The Icon component will automatically fix the SVG to ensure compatibility by removing width/height attributes and setting fill colors to <code>currentColor</code> so the icon adapts to the current text color.</p>
|
|
70
65
|
<div class="row -mx mb">
|
|
71
66
|
<div class="col d-span-6 m-span-12 px">
|
|
72
67
|
<k-card label="HTML">
|
|
@@ -103,7 +98,7 @@
|
|
|
103
98
|
<pre><code class="hljs xml"><span class="hljs-tag"><<span class="hljs-name">script</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"module"</span>></span><span class="javascript"><br /> <span class="hljs-keyword">import</span> Icon <span class="hljs-keyword">from</span> <span class="hljs-string">'/src/components/Icon.js'</span>;<br /> Icon.pathToIcons = <span class="hljs-string">'./pathTo/icons'</span>;<br /></span><span class="hljs-tag"></<span class="hljs-name">script</span>></span></code></pre>
|
|
104
99
|
|
|
105
100
|
<h3 id="addingIcons"><a href="#addingIcons" class="no-link">Adding Icons</a></h3>
|
|
106
|
-
<p>Add your SVGs to the directory
|
|
101
|
+
<p>Add your SVGs to the directory. The Icon component will automatically remove the <code>height</code> and <code>width</code> attributes from the <code>svg</code> tag and set the fill of all objects (path, rect, circle) to <code>currentColor</code>. This allows the icon to adapt to the font color where it is rendered and ensures consistent sizing. However, you can manually prepare your icons this way for better performance.</p>
|
|
107
102
|
<div class="row -mx mb">
|
|
108
103
|
<div class="col d-span-6 m-span-12 px">
|
|
109
104
|
<k-card label="Before">
|