Add more styling for forms; add rich text editor to new work page

Changed files
+153 -49
src
assets
styles
pages
works
+4 -1
package.json
···
"@tailwindcss/vite": "^4.1.13",
"astro": "^5.13.7",
"nanoid": "^5.1.5",
"tailwindcss": "^4.1.13"
},
"scripts": {
···
"daisyui": "^5.1.10"
},
"trustedDependencies": [
-
"@tailwindcss/oxide"
]
}
···
"@tailwindcss/vite": "^4.1.13",
"astro": "^5.13.7",
"nanoid": "^5.1.5",
+
"quill": "^2.0.3",
"tailwindcss": "^4.1.13"
},
"scripts": {
···
"daisyui": "^5.1.10"
},
"trustedDependencies": [
+
"@tailwindcss/oxide",
+
"esbuild",
+
"sharp"
]
}
+75
src/assets/styles/global.css
···
@utility title {
font-family: var(--font-display);
font-size: var(--text-xl);
}
···
@utility title {
font-family: var(--font-display);
font-size: var(--text-xl);
+
}
+
+
body {
+
height: 100vh;
+
font-family: var(--body);
+
font-size: var(--step-0);
+
line-height: 1.5;
+
}
+
+
h1 {
+
font-size: 1.5em;
+
font-weight: bold;
+
}
+
+
label {
+
display: block;
+
font-size: .8em;
+
font-weight: bold;
+
}
+
+
input[type="text"],
+
input[type="number"],
+
input[type="email"],
+
textarea {
+
border: 1px var(--color-base-300) solid;
+
border-radius: 2px;
+
padding: 3px 5px;
+
font-size: inherit;
+
font-family: var(--sans);
+
width: 100%;
+
}
+
+
button.btn,
+
button[type="submit"],
+
input[type="submit"],
+
input[type="reset"] {
+
background-color: var(--color-primary);
+
color: var(--color-primary-content);
+
border-radius: 4px;
+
padding: 5px 10px;
+
font-size: 1em;
+
font-weight: bold;
+
text-align: center;
+
min-width: 150px;
+
transition: 0.3s;
+
position: relative;
+
}
+
+
button.btn:hover,
+
button[type="submit"]:hover,
+
input[type="submit"]:hover,
+
input[type="reset"]:hover {
+
background-color: color-mix(in srgb-linear, var(--color-primary), #000000 20%);
+
}
+
+
button.btn:active,
+
button[type="submit"]:active,
+
input[type="submit"]:active,
+
input[type="reset"]:active {
+
top: 1px;
+
}
+
+
.input-field {
+
display: block;
+
margin-bottom: 1em;
+
}
+
+
.ql-toolbar.ql-snow {
+
border-color: var(--color-base-300) !important;
+
border-radius: 2px 2px 0 0;
+
}
+
+
#content.ql-container.ql-snow {
+
border-color: var(--color-base-300);
+
border-radius: 0 0 2px 2px;
}
+74 -48
src/pages/works/add.astro
···
---
import Layout from "@/layouts/Layout.astro";
import { actions, isInputError } from "astro:actions";
const loggedInUser = Astro.locals.loggedInUser;
···
<h1>Add a new work</h1>
<form action={actions.worksActions.addWork} method="post">
-
<label for="title">title</label>
-
<input
-
type="text"
-
name="title"
-
id="title"
-
aria-describedby="title-error"
-
required
-
transition:persist
-
/>
-
{errors.title && (
-
<div id="title-error">
-
{errors.title}
-
</div>
-
)}
-
<label for="tags">add tags</label>
-
<input
-
type="text"
-
list="tags-list"
-
name="tags"
-
id="tags"
-
aria-describedby="tags-error"
-
transition:persist
-
/>
-
<!-- could be cool to fetch tags from a tags server or smth? idk -->
-
<datalist id="tags-list">
-
<option value="test">here</option>
-
<option value="tag2">another</option>
-
<option value="tag3">try them all!</option>
-
</datalist>
-
{errors.tags && (
-
<div id="tags-error">
-
{errors.tags}
-
</div>
-
)}
-
<label for="content">body</label>
-
<!-- replace this with a rich text editor / code editor later -->
-
<textarea name="content" id="content" aria-describedby="content-error" transition:persist></textarea>
-
{errors.content && (
-
<div id="content-error">
-
{errors.content}
-
</div>
-
)}
-
-
<label for="publish">Publish to your PDS?</label>
-
<input type="checkbox" name="publish" id="publish" />
-
-
<button>submit</button>
</form>
{result?.error && (
···
</div>
)}
</main>
-
</Layout>
···
---
import Layout from "@/layouts/Layout.astro";
import { actions, isInputError } from "astro:actions";
+
import "quill/dist/quill.core.css";
+
import "quill/dist/quill.snow.css";
const loggedInUser = Astro.locals.loggedInUser;
···
<h1>Add a new work</h1>
<form action={actions.worksActions.addWork} method="post">
+
<div class="input-field">
+
<label for="title">Title</label>
+
<input
+
type="text"
+
name="title"
+
id="title"
+
aria-describedby="title-error"
+
required
+
transition:persist
+
/>
+
{errors.title && (
+
<div id="title-error">
+
{errors.title}
+
</div>
+
)}
+
</div>
+
<div class="input-field">
+
<label for="tags">Add Tags</label>
+
<input
+
type="text"
+
list="tags-list"
+
name="tags"
+
id="tags"
+
aria-describedby="tags-error"
+
transition:persist
+
/>
+
<!-- could be cool to fetch tags from a tags server or smth? idk -->
+
<!-- maybe from labelers the instance is subscribed to? - @veryroundbird.house -->
+
<datalist id="tags-list">
+
<option value="test">here</option>
+
<option value="tag2">another</option>
+
<option value="tag3">try them all!</option>
+
</datalist>
+
{errors.tags && (
+
<div id="tags-error">
+
{errors.tags}
+
</div>
+
)}
+
</div>
+
<div class="input-field">
+
<label for="content">Work Text</label>
+
<div id="content" aria-describedby="content-error" transition:persist rows="50"></div>
+
{errors.content && (
+
<div id="content-error">
+
{errors.content}
+
</div>
+
)}
+
</div>
+
<div class="input-field">
+
<label for="publish"><input type="checkbox" name="publish" id="publish" /> Publish to your PDS?</label>
+
</div>
+
<div class="input-field">
+
<button type="submit">Submit</button>
+
</div>
</form>
{result?.error && (
···
</div>
)}
</main>
+
</Layout>
+
+
<script>
+
import Quill from "quill";
+
+
const quill = new Quill('#content', {
+
theme: 'snow',
+
modules: {
+
syntax: true
+
}
+
});
+
</script>
+
+
<style>
+
#content {
+
min-height: 50vh;
+
}
+
</style>