Ajouter des fichiers et des modifications existants

This commit is contained in:
Pierre Berthe 2024-02-29 11:24:22 +01:00
commit 4ea514650d
13 changed files with 1481 additions and 0 deletions

View file

@ -0,0 +1,9 @@
<!-- prettier-ignore -->
{% extends "base.html" %}
{% block title %}Another page!{% endblock %}
{% block content %}
<a href="/"> Main page </a>
<h1 class="font-bold text-indigo-500">Another page</h1>
{% endblock %}

21
templates/base.html Normal file
View file

@ -0,0 +1,21 @@
<!DOCTYPE html>
<html lang="en">
<head>
<link href="/assets/main.css" rel="stylesheet" />
<link href="https://rsms.me/inter/inter.css" rel="stylesheet" />
<!-- Allow any inheriting page to set it's own title -->
<title>{% block title %}{{ title }}{% endblock %}</title>
<!-- htmx from the unpkg CDN - your mileage may vary -->
<script src="https://unpkg.com/htmx.org@1.9.10"></script>
<!-- Allow any inheriting page to extend head with additional assets -->
{% block head %}{% endblock %}
</head>
<body hx-boost="true">
<div id="content">
<!-- Inheriting pages will have their content rendered here, similar to app root in React, Angular, etc. -->
{% block content %}{% endblock %}
</div>
</body>
</html>

24
templates/hello.html Normal file
View file

@ -0,0 +1,24 @@
<!-- prettier-ignore -->
{% extends "base.html" %}
{% block title %}Hello!{% endblock %}
{% block content %}
<div class="inline-flex flex-row space-x-2">
<h1 class="text-green-500">Howdy!</h1>
<a
href="/another-page"
class="text-indigo-500 underline hover:text-indigo-300"
>Another page</a
>
<button
type="button"
hx-get="/api/hello"
hx-swap="innerHtml"
class="rounded-md bg-indigo-600 px-2.5 py-1.5 text-sm font-semibold text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600"
>
Say hello
</button>
</div>
{% include "todo-form.html" %} {% endblock %}

20
templates/todo-form.html Normal file
View file

@ -0,0 +1,20 @@
<form hx-post="/api/todos" hx-target="#todos" class="max-w-md">
<label for="todo" class="block text-sm font-medium leading-6 text-gray-900"
>Todo</label
>
<div class="mt-2 inline-flex flex-row space-x-2">
<input
type="text"
name="name"
class="block w-full rounded-md border-0 py-1.5 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6"
placeholder="Replace frontend with htmx"
/>
<button
type="submit"
class="rounded-md bg-indigo-600 px-2.5 py-1.5 text-sm font-semibold text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600"
>
Add
</button>
</div>
</form>
<div id="todos"></div>

3
templates/todo-list.html Normal file
View file

@ -0,0 +1,3 @@
{% for todo in todos %}
<p class="text-lg">{{ todo }}</p>
{% endfor %}