forked from Dogfalo/materialize
-
-
Notifications
You must be signed in to change notification settings - Fork 109
Expand file tree
/
Copy pathindex.html
More file actions
181 lines (163 loc) · 6.43 KB
/
Copy pathindex.html
File metadata and controls
181 lines (163 loc) · 6.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script type="importmap">
{
"imports": {
"@materializecss/materialize/": "/"
}
}
</script>
<!-- CSS -->
<link
type="text/css"
rel="stylesheet"
href="/dist/css/materialize.min.css"
media="screen,projection"
/>
<link type="text/css" rel="stylesheet" href="/components/textfield/formfields.css" />
<link type="text/css" rel="stylesheet" href="/components/appbar/appbar.css" />
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet" />
<style>
body {
background-image: radial-gradient(#8882 1px, transparent 0);
background-size: 12px 12px;
}
</style>
</head>
<body>
<div class="container">
<h1 style="font-size: 1.5rem;">Test</h1>
<p>This is for quick testing purposes. The files are used from dist directory.</p>
<div style="border: 1px dashed #888">
<div class="appbar">Appbar</div>
<h6>Textfields</h6>
<div class="row g-1 p-3 form-wrapper">
<!-- Animated -->
<fieldset class="form-field animated s12 m4">
<legend>Given Name</legend>
<input type="text" id="my-input-1" placeholder="Given Name" />
<label for="my-input-1">Given Name</label>
</fieldset>
<!-- Preset -->
<fieldset class="form-field animated s12 m4">
<legend>Middle Name</legend>
<input type="text" id="in-middlename" placeholder="Middle Name" value="John" />
<label for="in-middlename">Middle Name</label>
</fieldset>
<!-- Disabled-->
<fieldset class="form-field s12 m4" disabled>
<legend>Family Name</legend>
<input type="text" id="my-input-2" placeholder="e.g. Doe" />
<label for="my-input-2">Family Name</label>
</fieldset>
<!-- different placeholder than label + required -->
<fieldset class="form-field s12 m4">
<legend>Birthmonth</legend>
<input type="text" id="my-input-3" placeholder="e.g. April" required />
<label for="my-input-3">Birthmonth</label>
</fieldset>
<!-- select -->
<fieldset class="form-field animated s12 m4">
<legend>Gender</legend>
<select id="my-input-gender">
<option>Male</option>
<option>Female</option>
</select>
<label for="my-input-gender">Gender</label>
</fieldset>
<!-- Compound Input -->
<fieldset class="form-field animated s12 m4">
<legend>Height</legend>
<input
type="number"
id="my-input-size"
placeholder=" "
required
style="text-align: right"
/>
<label for="my-input-size">Height</label>
<select id="my-input-unit">
<option>m</option>
<option>dm</option>
<option selected>cm</option>
</select>
<label for="my-input-unit">Unit</label>
</fieldset>
<!-- Comound with prefix -->
<fieldset class="form-field animated s12 m4">
<legend>Budget</legend>
<div class="prefix">EUR</div>
<input type="text" id="my-input-budget" placeholder=" " required />
<label for="my-input-budget">Budget</label>
</fieldset>
<!-- Date -->
<fieldset class="form-field animated s12 m4">
<legend>Birthday</legend>
<input type="date" id="my-input-birthday" placeholder=" " />
<label for="my-input-birthday">Birthday</label>
</fieldset>
</div>
<div class="my-5">
<h6>Tabs</h6>
<div style="width: 20%; height: 40px">
<ul class="tabs">
<li class="tab"><a href="#test1">Test 1</a></li>
<li class="tab"><a class="active" href="#test2">Test 2</a></li>
<li class="tab disabled"><a href="#test3">Disabled Tab</a></li>
<li class="tab"><a href="#test4">Test 4</a></li>
</ul>
<div id="test1" class="col s12">Test 1</div>
<div id="test2" class="col s12">Test 2</div>
<div id="test3" class="col s12">Test 3</div>
<div id="test4" class="col s12">Test 4</div>
</div>
</div>
</div>
<div class="app mt-5"></div>
</div>
</div>
<!-- JS -->
<script type="text/javascript" src="/dist/js/materialize.min.js"></script>
<script type="module">
import { TextField } from "@materializecss/materialize/components/textfield/textfield.mjs";
import { AppBar } from "@materializecss/materialize/components/appbar/appbar.mjs";
const appBar = new AppBar().setTitle('My App');
document.querySelector('.appbar').innerHTML = appBar.toHTML();
// create input field
//const givenName = new TextField().setLabel('Given Name').addClassname('s12');
//document.querySelector('.form-wrapper').innerHTML = givenName.toHTML();
//------------------------------------- Example (Nested components to widget)
import { createCounterApp } from '/components/button/examples.iso.js';
const app = createCounterApp();
const appHtml = app.toHTML();
console.log(appHtml);
// html => element
const template = document.createElement('template');
template.innerHTML = appHtml;
const appElem = template.content.firstElementChild;
document.querySelector('.app').replaceChildren(appElem);
function count(input) {
const value = input.value + input.increment;
return { value }
}
const state = { value: 12 };
const numberEl = appElem.querySelector('.mw-number'); // output
const btns = appElem.querySelectorAll('.btn'); // input
numberEl.innerHTML = state.value;
btns[0].addEventListener('click', e => {
state.value = count({ value: state.value , increment: 1 }).value;
numberEl.innerHTML = state.value;
})
btns[1].addEventListener('click', e => {
state.value = count({ value: state.value , increment: -1 }).value;
numberEl.innerHTML = state.value;
})
</script>
<script>
M.AutoInit();
</script>
</body>
</html>