инженер
тимлид
спикер
зачем мне еще одна библиотека?!
Есть же NextJS!
Addy Osmani
Simple vs Easy
Rajat Kumar — Conditional modules & dynamic bundling, a Netflix original
Навигация в HTML
...
<nav class="menu">
<ul>
<li><a href="#">Главная</a></li>
<li><a href="#">О нас</a></li>
<li><a href="#">Контакты</a></li>
</ul>
</nav>
<main id="content"></main>
...
<a href="/">Главная</a>
<a
href="/"
navigation=true
selector="#content">Главная</a>
document.addEventListener("click", async (event) => {
const { selector, navigation } = event.target.dataset;
const url = event.target.getAttribute("href");
if (navigation) {
event.preventDefault();
event.stopPropagation();
}
// Распарсить ответ, получить по селектору
const r = await getFromUrlBySelector(url, selector);
target.innerHTML = r;
});
htmx gives you access to AJAX, CSS Transitions, WebSockets and Server Sent Events directly in HTML, using attributes, so you can build modern user interfaces with the simplicity and power of hypertext
htmx gives you access to AJAX, CSS Transitions, WebSockets and Server Sent Events directly in HTML, using attributes, so you can build modern user interfaces with the simplicity and power of hypertext
htmx gives you access to AJAX, CSS Transitions, WebSockets and Server Sent Events directly in HTML, using attributes, so you can build modern user interfaces with the simplicity and power of hypertext
htmx gives you access to AJAX, CSS Transitions, WebSockets and Server Sent Events directly in HTML, using attributes, so you can build modern user interfaces with the simplicity and power of hypertext
<script src="https://unpkg.com/htmx.org@1.9.12"></script>
<!-- have a button POST a click via AJAX -->
<button hx-post="/clicked" hx-swap="outerHTML">
Click Me
</button>
<div hx-boost="true">
<a href="/page1">Go To Page 1</a>
<a href="/page2">Go To Page 2</a>
</div>
<form hx-boost="true" action="/example" method="post">
<input name="email" type="email">
<button>Submit</button>
</form>
<div hx-get="/example">Get Some HTML</div>
<div hx-get="/clicked" hx-trigger="click[ctrlKey]">
Control Click Me
</div>
<div hx-get="/news" hx-trigger="every 2s"></div>
<div hx-get="/graph" hx-trigger="load">
<img alt="Result loading..." class="htmx-indicator" width="150" src="/img/bars.svg"/>
</div>
.htmx-settling img {
opacity: 0;
}
img {
transition: opacity 300ms ease-in;
}
<header hx-get="/header" hx-trigger="load">
Здесь будет шапка...
</header>
<main>
<section>Content...</section>
<aside hx-get="/companies"
hx-trigger="load">
Здесь будут компании...
</aside>
</main>
<input id="search"
type="search"
name="q"
value="{{ request.args.get('q') or '' }}"
hx-get="/contacts"
hx-trigger="change, keyup delay:200ms changed"
hx-target="tbody"
hx-push-url="true"/>
app.ws("/ws", (ws) => {
let counter = 0;
setInterval(() => {
const result = `<div
hx-swap-oob="afterbegin:#content">
<button
class="btn btn-primary"
data-bs-toggle="modal"
data-bs-target="#exampleModal">
${counter}
</button></div>`;
ws.send(result);
counter++;
}, 1000);
});
<div id="content" hx-ws="connect:/ws"></div>
<style>
.fade-me-out.htmx-swapping {
opacity: 0;
transition: opacity 1s ease-out;
}
</style>
<button class="fade-me-out"
hx-delete="/fade_out_demo"
hx-swap="outerHTML swap:1s">
Fade Me Out
</button>
|
|
|