Skip to content

Commit 7b3c51f

Browse files
committed
Added form elements
1 parent a7e1e8d commit 7b3c51f

File tree

4 files changed

+57
-1
lines changed

4 files changed

+57
-1
lines changed

src/component/form/FormElement.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
2+
import { LitElement, html, css } from 'lit';
3+
4+
/**
5+
* FormElement
6+
*/
7+
export class FormElement extends LitElement {
8+
constructor() {
9+
super();
10+
// Default properties
11+
this.name = 'wc-form';
12+
this.method = "POST";
13+
this.action = "#";
14+
}
15+
static get properties() {
16+
return {
17+
/**
18+
* Name of the form
19+
* @type {String}
20+
*/
21+
name: { type: String },
22+
23+
/**
24+
* The method for submitting the form (POST or GET)
25+
* @type {string}
26+
*/
27+
method: { type: String },
28+
29+
/**
30+
* The action when submitting the form
31+
* @type {string}
32+
*/
33+
action: { type: String },
34+
};
35+
}
36+
render() {
37+
return html`
38+
<form method="${this.method}" action="${this.action}"><slot></slot></form>
39+
`;
40+
}
41+
}
42+
43+
customElements.define('wc-form', FormElement);

src/component/form/FormInputElement.js

Whitespace-only changes.

src/index.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,15 @@ <h1>Modal</h1>
9898
</div>
9999
</wc-sidemodal>
100100
</div>
101+
<hr>
102+
103+
<div class="container">
104+
<wc-form>
105+
<h1>Form</h1>
106+
<wc-form-input name="name" label="Name" placeholder="Enter your name" required></wc-form-input>
107+
</wc-form>
108+
</div>
109+
101110
</body>
102111

103112
</html>

src/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,17 @@ import './component/icon/IconElement';
1717
import './component/nav/NavBarElement';
1818
import './component/nav/NavItemElement';
1919

20-
// Modals
20+
// Modal Elements
2121
import './component/modal/ModalElement';
2222
import './component/modal/SideModalElement';
2323

24+
// Form Elements
25+
import './component/form/FormElement';
26+
2427
// CSS
2528
import './css/core.css';
2629
import './css/document.css';
2730

31+
// Other
2832
import './esbuild.js';
2933
import './test.js';

0 commit comments

Comments
 (0)