├── .vscode └── extensions.json ├── LICENSE ├── README.md ├── app.js ├── components.js ├── config.js ├── index.html ├── logo.svg ├── styles.css └── undraw_outer_space_re_u9vd.svg /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "ms-vscode.live-server" 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Tom Doe 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![showcase](https://d33wubrfki0l68.cloudfront.net/2581642b51e126ac5abf089fab72cab3f53d3897/19ec1/img/blog/buildless-preact.png) 2 | 3 | # buildless-preact-starter 4 | 5 | A starter intended to showcase how I'm using Preact for SPAs in buildless environments. 6 | 7 | ## Preface 8 | 9 | In the official docs, this approach is called the [No build tools route](https://preactjs.com/guide/v10/getting-started#no-build-tools-route); it leverages [HTM](https://github.com/developit/htm): 10 | 11 | > HTM is a JSX-like syntax that works in standard JavaScript. Instead of requiring a build step, it uses JavaScript's own Tagged Templates syntax, which was added in 2015 and is supported in all modern browsers. This is an increasingly popular way to write Preact apps, since there are fewer moving parts to understand than a traditional front-end build tooling setup. 12 | 13 | ## Prerequisites 14 | 15 | 1. At least 1 HTML file 16 | 2. Browser support for ` 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /logo.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /styles.css: -------------------------------------------------------------------------------- 1 | :root { 2 | --background-body: #fff; 3 | --background: #878787; 4 | --background-alt: #f7f7f7; 5 | --selection: #9e9e9e; 6 | --text-main: #121212; 7 | --text-muted: #878787; 8 | --primary: #3C2979; 9 | --secondary: #F6A000; 10 | --focus: #3C2979; 11 | --border: #3C2979; 12 | --code: #121212; 13 | --animation-duration: 0.35s; 14 | --button-hover: #878787; 15 | --scrollbar-thumb: rgb(213, 213, 213); 16 | --scrollbar-thumb-hover: rgb(196, 196, 196); 17 | --form-placeholder: #737373; 18 | --form-text: #121212; 19 | --variable: #39a33c; 20 | --highlight: #ff0; 21 | } 22 | 23 | *, 24 | *::before, 25 | *::after { 26 | box-sizing: border-box; 27 | scroll-behavior: smooth; 28 | } 29 | 30 | *:hover { 31 | transition: all .25s ease; 32 | } 33 | 34 | html { 35 | scrollbar-color: rgb(213, 213, 213) #fff; 36 | scrollbar-color: var(--scrollbar-thumb) var(--background-body); 37 | scrollbar-width: thin; 38 | font-size: 16px; 39 | } 40 | 41 | body { 42 | font-family: Lato, Arial, 'Helvetica Neue', Helvetica, sans-serif; 43 | line-height: 1.5; 44 | font-size: 1rem; 45 | margin: 0 auto; 46 | word-wrap: break-word; 47 | color: #121212; 48 | color: var(--text-main); 49 | background: #fff; 50 | background: var(--background-body); 51 | text-rendering: optimizeLegibility; 52 | } 53 | 54 | button, 55 | .btn { 56 | transition: 57 | background-color 0.1s linear, 58 | border-color 0.1s linear, 59 | color 0.1s linear, 60 | box-shadow 0.1s linear, 61 | transform 0.1s ease; 62 | transition: 63 | background-color var(--animation-duration) linear, 64 | border-color var(--animation-duration) linear, 65 | color var(--animation-duration) linear, 66 | box-shadow var(--animation-duration) linear, 67 | transform var(--animation-duration) ease; 68 | } 69 | 70 | input { 71 | transition: 72 | background-color 0.1s linear, 73 | border-color 0.1s linear, 74 | color 0.1s linear, 75 | box-shadow 0.1s linear, 76 | transform 0.1s ease; 77 | transition: 78 | background-color var(--animation-duration) linear, 79 | border-color var(--animation-duration) linear, 80 | color var(--animation-duration) linear, 81 | box-shadow var(--animation-duration) linear, 82 | transform var(--animation-duration) ease; 83 | } 84 | 85 | h1, 86 | h2, 87 | h3, 88 | h4, 89 | h5, 90 | h6 { 91 | font-family: Lato, Arial, 'Helvetica Neue', Helvetica, sans-serif; 92 | font-weight: 700; 93 | margin-top: 0; 94 | margin-bottom: 0.75rem; 95 | } 96 | 97 | h1 { 98 | color: #000; 99 | color: var(--primary); 100 | font-size: 2rem; 101 | } 102 | 103 | h2 { 104 | color: #000; 105 | color: var(--primary); 106 | font-size: 1.25rem; 107 | } 108 | 109 | h3 { 110 | color: var(--secondary); 111 | } 112 | 113 | h4 { 114 | color: #000; 115 | color: var(--text-main); 116 | } 117 | 118 | h5 { 119 | color: #000; 120 | color: var(--text-main); 121 | } 122 | 123 | h6 { 124 | color: #000; 125 | color: var(--text-main); 126 | } 127 | 128 | p { 129 | margin-top: 0; 130 | } 131 | 132 | strong { 133 | color: #000; 134 | color: var(--text-main); 135 | } 136 | 137 | b, 138 | strong, 139 | th { 140 | font-weight: 700; 141 | } 142 | 143 | button, 144 | select, 145 | input[type='submit'], 146 | input[type='button'], 147 | input[type='checkbox'], 148 | input[type='range'], 149 | input[type='radio'] { 150 | cursor: pointer; 151 | margin: 0; 152 | } 153 | 154 | input:not([type='checkbox']):not([type='radio']), 155 | select { 156 | display: block; 157 | } 158 | 159 | input { 160 | color: #000; 161 | color: var(--form-text); 162 | background-color: #fff; 163 | background-color: var(--background-body); 164 | font-family: inherit; 165 | font-size: inherit; 166 | padding: 10px; 167 | border: 1px solid var(--background); 168 | outline: none; 169 | } 170 | 171 | button { 172 | color: #000; 173 | color: var(--form-text); 174 | background-color: #fff; 175 | background-color: var(--background-body); 176 | border-radius: 0px; 177 | font-family: inherit; 178 | font-size: inherit; 179 | padding: 10px; 180 | border: 1px solid var(--background); 181 | outline: none; 182 | } 183 | 184 | input { 185 | vertical-align: top; 186 | } 187 | 188 | label { 189 | vertical-align: middle; 190 | font-size: 0.875rem; 191 | margin: 0; 192 | display: inline-block; 193 | } 194 | 195 | input:not([type='checkbox']):not([type='radio']), 196 | input[type='range'], 197 | select, 198 | button, 199 | textarea { 200 | -webkit-appearance: none; 201 | } 202 | 203 | button, 204 | input[type='submit'], 205 | input[type='button'] { 206 | padding-right: 30px; 207 | padding-left: 30px; 208 | } 209 | 210 | button:hover { 211 | background: #ddd; 212 | background: var(--button-hover); 213 | } 214 | 215 | input[type='submit']:hover { 216 | background: #ddd; 217 | background: var(--button-hover); 218 | } 219 | 220 | input[type='button']:hover { 221 | background: #ddd; 222 | background: var(--button-hover); 223 | } 224 | 225 | input:focus { 226 | box-shadow: 0 0 0 2px #0096bfab; 227 | box-shadow: 0 0 0 2px var(--focus); 228 | } 229 | 230 | select:focus { 231 | box-shadow: 0 0 0 2px #0096bfab; 232 | box-shadow: 0 0 0 2px var(--focus); 233 | } 234 | 235 | button:focus { 236 | box-shadow: 0 0 0 2px #0096bfab; 237 | box-shadow: 0 0 0 2px var(--focus); 238 | } 239 | 240 | textarea:focus { 241 | box-shadow: 0 0 0 2px #0096bfab; 242 | box-shadow: 0 0 0 2px var(--focus); 243 | } 244 | 245 | input[type='checkbox']:active, 246 | input[type='radio']:active, 247 | input[type='submit']:active, 248 | input[type='button']:active, 249 | input[type='range']:active, 250 | button:active { 251 | transform: translateY(2px); 252 | } 253 | 254 | input:disabled, 255 | select:disabled, 256 | button:disabled, 257 | textarea:disabled { 258 | cursor: not-allowed; 259 | opacity: 0.5; 260 | } 261 | 262 | ::-moz-placeholder { 263 | color: #949494; 264 | color: var(--form-placeholder); 265 | } 266 | 267 | :-ms-input-placeholder { 268 | color: #949494; 269 | color: var(--form-placeholder); 270 | } 271 | 272 | ::-ms-input-placeholder { 273 | color: #949494; 274 | color: var(--form-placeholder); 275 | } 276 | 277 | ::placeholder { 278 | color: #949494; 279 | color: var(--form-placeholder); 280 | } 281 | 282 | a { 283 | text-decoration: none; 284 | color: #0076d1; 285 | color: var(--primary); 286 | } 287 | 288 | a:hover { 289 | text-decoration: none; 290 | } 291 | 292 | img, 293 | video { 294 | max-width: 100%; 295 | height: auto; 296 | } 297 | 298 | hr { 299 | border: none; 300 | border-top: 1px solid #dbdbdb; 301 | border-top: 1px solid var(--border); 302 | } 303 | 304 | /* custom */ 305 | 306 | header { 307 | display: flex; 308 | flex-direction: row; 309 | justify-content: space-between; 310 | padding: 1rem; 311 | font-size: 1rem; 312 | } 313 | 314 | .header-logo { 315 | display: block; 316 | } 317 | 318 | footer { 319 | background: #6c757d; 320 | color: #fff; 321 | width: 100%; 322 | padding: 3rem 1rem; 323 | } 324 | 325 | .footer-row { 326 | display: flex; 327 | justify-content: center; 328 | } 329 | 330 | .footer-row a { 331 | display: block; 332 | color: #fff; 333 | margin: 0 1.25rem; 334 | } 335 | 336 | .footer-row a:hover img { 337 | opacity: 0.75; 338 | } 339 | 340 | #app-container { 341 | margin-bottom: 2.5rem; 342 | } 343 | 344 | .btn { 345 | display: inline-block; 346 | font-size: 1rem; 347 | padding: 0.5rem 1rem; 348 | } 349 | 350 | .btn-primary { 351 | background: var(--primary); 352 | border: 1px solid var(--primary); 353 | color: #fff; 354 | } 355 | 356 | .btn-primary:hover { 357 | background: var(--background-body); 358 | color: var(--primary); 359 | } 360 | 361 | .flex { 362 | display: flex; 363 | } 364 | 365 | .form-group { 366 | gap: 1rem; 367 | margin-bottom: 1rem; 368 | } 369 | 370 | .w-100 { 371 | width: 100%; 372 | } 373 | 374 | .control-group { 375 | align-items: center; 376 | margin-bottom: 0.5rem 377 | } 378 | 379 | .control-group > input { 380 | flex-shrink: 0; 381 | } 382 | 383 | .control-group > label { 384 | cursor: pointer; 385 | line-height: 1.25; 386 | margin-left: 0.75rem; 387 | } 388 | 389 | .footer-link { 390 | color: #878787; 391 | } 392 | 393 | .footer-link:hover { 394 | text-decoration: underline; 395 | } 396 | 397 | .hover-underline:hover { 398 | text-decoration: underline; 399 | } 400 | 401 | .block { 402 | display: block; 403 | } 404 | 405 | .mx-auto { 406 | margin: 0 auto; 407 | } 408 | 409 | .m-0 { 410 | margin: 0; 411 | } 412 | 413 | .my-1 { 414 | margin-top: 1rem; 415 | margin-bottom: 1rem; 416 | } 417 | 418 | .site { 419 | display: flex; 420 | flex-direction: column; 421 | min-height: 100vh; 422 | } 423 | 424 | .site-content { 425 | flex-grow: 1; 426 | padding: 0 1rem; 427 | margin: 0 auto; 428 | margin-bottom: 2rem; 429 | width: 100%; 430 | max-width: 640px; 431 | } 432 | 433 | .text-center { 434 | text-align: center; 435 | } 436 | 437 | .text-primary { 438 | color: var(--primary) 439 | } 440 | 441 | .text-muted, 442 | .text-muted:hover { 443 | color: var(--text-muted) 444 | } 445 | 446 | .text-sm { 447 | font-size: 0.75rem; 448 | } 449 | -------------------------------------------------------------------------------- /undraw_outer_space_re_u9vd.svg: -------------------------------------------------------------------------------- 1 | --------------------------------------------------------------------------------