File tree Expand file tree Collapse file tree 5 files changed +94
-6
lines changed
Expand file tree Collapse file tree 5 files changed +94
-6
lines changed Original file line number Diff line number Diff line change 11# HTML Sheet Element
2+
23HTML Custom Element for creating sheets
34
5+
46## Features
7+
58- There is a draggable area to resize the sheet
69- The sheet can be closed using a button in the top right corner, using the ` Esc ` key, or by clicking outside the bottom sheet
710 - This behavior is configurable. You can turn off the ` Esc ` or the click outside the sheet when you want.
811
12+
13+ ## API Documentation
14+
15+ You can find API documentation [ here] ( ./documentation/API.md )
16+
Original file line number Diff line number Diff line change 33HTML Custom Element for creating sheets
44
55<details open >
6- <summary ><b >Example:</b > Define the element in the registry</summary >
6+ <summary ><b >Example:</b > Define the element in the registry and use it in your HTML </summary >
77
88``` jsx
99customElements .define (" ui-sheet" , SheetElement)
10+
11+ // in HTML:
12+ < ui- sheet>
13+ < p> Hello World! < / p>
14+ < / ui- sheet>
15+ ```
16+
17+ </details >
18+
19+ <details open >
20+ <summary ><b >Example:</b > Sheet open by default</summary >
21+
22+ ``` jsx
23+ < ui- sheet open>
24+ < p> Hello World! < / p>
25+ < / ui- sheet>
1026```
1127
1228</details >
@@ -42,11 +58,43 @@ sheet.show()
4258</details >
4359
4460
61+ ## ` options `
62+
63+ Options for behavior customization
64+
65+ <details open >
66+ <summary ><b >Example:</b > Make the sheet <i >not</i > close on background click</summary >
67+
68+ ``` jsx
69+ < ui- sheet ignore- background- click>
70+ ...
71+ < / ui- sheet>
72+ ```
73+
74+ </details >
75+
76+ <details open >
77+ <summary ><b >Example:</b > Make the sheet <i >not</i > close when pressing Escape</summary >
78+
79+ ``` jsx
80+ < ui- sheet ignore- escape- key>
81+ ...
82+ < / ui- sheet>
83+ ```
84+
85+ </details >
86+
87+
4588## ` showModal(): void `
4689
4790Open the sheet
4891
4992
93+ ## ` show(): void `
94+
95+ Open the sheet
96+
97+
5098## ` close(): void `
5199
52100Collapse the sheet
@@ -69,4 +117,4 @@ sheet.open = true // the same as executing sheet.showModal()
69117sheet .open = false // the same as executing sheet.close()
70118```
71119
72- </details >
120+ </details >
Original file line number Diff line number Diff line change @@ -96,6 +96,10 @@ class DocumentationGenerator {
9696 break
9797 }
9898
99+ if ( object . isStatic ) {
100+ name = "static " + name
101+ }
102+
99103 return "`" + name + "`"
100104 }
101105
@@ -120,9 +124,10 @@ class DocumentationGenerator {
120124 }
121125
122126 static generateExample ( tag ) {
123- const summaryMatchGroup = / \< c a p t i o n \> ( [ ^ \< \> ] * ) \< \/ c a p t i o n \> / . exec ( tag . doc )
127+ const summaryMatchGroup = / \< c a p t i o n \> ( ( [ ^ \< \n ] | < \/ ? i > | < \/ ? b > | < \/ ? u > | < \/ ? a > ) * ) \< \/ c a p t i o n \> / . exec ( tag . doc )
124128 const summaryString = summaryMatchGroup ?. [ 1 ] ?? ""
125129 const summaryCode = summaryString ? `<b>Example:</b> ${ summaryString } ` : "<b>Example</b>"
130+
126131 const code = tag . doc
127132 . substring ( summaryMatchGroup ?. [ 0 ] . length ?? 0 )
128133 . trim ( )
@@ -137,6 +142,7 @@ class DocumentationGenerator {
137142 object . jsDoc ?. doc ,
138143 ...this . generateTags ( object ) ,
139144 ] , "\n\n" ) ,
145+ ...( object . classDef ?. properties . map ( property => this . generate ( property , deepnessLevel + 1 ) ) ?? [ ] ) ,
140146 ...( object . classDef ?. methods . map ( method => this . generate ( method , deepnessLevel + 1 ) ) ?? [ ] ) ,
141147 ] , "\n\n\n" )
142148 }
Original file line number Diff line number Diff line change @@ -11,9 +11,19 @@ import { styleSheet } from "./styleSheet.js"
1111/**
1212 * HTML Custom Element for creating sheets
1313 *
14- * @example <caption>Define the element in the registry</caption>
14+ * @example <caption>Define the element in the registry and use it in your HTML </caption>
1515 * customElements.define("ui-sheet", SheetElement)
1616 *
17+ * // in HTML:
18+ * <ui-sheet>
19+ * <p>Hello World!</p>
20+ * </ui-sheet>
21+ *
22+ * @example <caption>Sheet open by default</caption>
23+ * <ui-sheet open>
24+ * <p>Hello World!</p>
25+ * </ui-sheet>
26+ *
1727 * @example <caption>Execute certain actions when the sheet opens or closes</caption>
1828 * const sheet = document.querySelector("...")
1929 *
@@ -57,6 +67,19 @@ export class SheetElement extends HTMLElement {
5767 onClick : this . #onClick. bind ( this )
5868 }
5969
70+ /**
71+ * Options for behavior customization
72+ *
73+ * @example <caption>Make the sheet <i>not</i> close on background click</caption>
74+ * <ui-sheet ignore-background-click>
75+ * ...
76+ * </ui-sheet>
77+ *
78+ * @example <caption>Make the sheet <i>not</i> close when pressing Escape</caption>
79+ * <ui-sheet ignore-escape-key>
80+ * ...
81+ * </ui-sheet>
82+ */
6083 options = {
6184 closeOnBackgroundClick : true ,
6285 closeOnEscapeKey : true
@@ -132,7 +155,9 @@ export class SheetElement extends HTMLElement {
132155 /**
133156 * Open the sheet
134157 */
135- show = this . showModal
158+ show ( ) {
159+ this . showModal ( )
160+ }
136161
137162 /**
138163 * Collapse the sheet
Original file line number Diff line number Diff line change 2020 },
2121 "scripts" : {
2222 "dev" : " vite --config test/vite.config.js" ,
23- "build" : " vite build"
23+ "build" : " vite build" ,
24+ "docs:api" : " deno run -A documentation/generateDocumentation.js"
2425 },
2526 "devDependencies" : {
2627 "vite" : " ^4.3.0"
You can’t perform that action at this time.
0 commit comments