Controlling overflow with tailwindcss
Posts tagged: webdev
All posts with the tag "webdev"
Default scrollbars on a dark theme website are just the ugliest thing. This page covers all the pseudo selectors needed to style the scrollbar.
All the hover, select, autofil, focus combinations have left me confused on how to consistently get my form elements styled in dark mode
This snippet from CSS tricks has fixed all the different states for me to give me full control.
arel is a “Lightweight browser hot reload for Python ASGI web apps”
I just implemented this on my thoughts website using fastapi, and it’s incredibly fast and lightweight. There just two lines of js that make a web socket connection back to the backend that watches for changes.
When in development mode, this snippet gets injected directly on the page and does a refresh when arel detects a change.
import os import arel from fastapi import FastAPI, Request from fastapi.templating import Jinja2Templates app = FastAPI() templates = Jinja2Templates("templates") if _debug := os.getenv("DEBUG"): hot_reload = arel.HotReload(paths=[arel.Path(".")]) app.add_websocket_route("/hot-reload", route=hot_reload, name="hot-reload") app.add_event_handler("startup", hot_reload.startup) app.add_event_handler("shutdown", hot_reload.shutdown) templates.env.globals["DEBUG"] = _debug templates.env.globals["hot_reload"] = hot_reload @app.get("/") def index(request: Request): return templates.TemplateResponse("index.html", context={"request": request}) # run: # DEBUG=true uvicorn main:app --reload
I just discovered arel for hot reloading python applications when content changes from this snippet that implements it for fatapi.
...
HATEOAS gonna hate. More and more htmx seems like the js library for backend devs. So rather than making 55 rest calls here, just make an endpoint that does what you want it to do with one, or a few requests.
why-is-postgres-default
Serious question.
But, why. It’s the most loved db, right? Right? Maybe it’s time to rethink it.
Don’t get me wrong, if I need a relational db as a service, PostgreSQL is going to be my first choice, but why do I need to run a separate application for it?
...
Pagefind is absolutely insane. I’ve tried a number of static site searches, and found them all hard to get get going, clunky and not the best experience as a user or developer.
I setup pagefind in about 2 minutes on my site where it found and indexed 833 pages in 2 minutes.
The only downside I see so far is that it is a lot of bandwidth to the user. On simulated slow 3G you can definitly feel it, but not terrible. Anything slower and its going to start feeling frustrating.
edit: I have actually fully deployed it on waylonwalker.com, and its fast!
...
A Case For Tailwindcss
I was watching @theprimeagen recently and I think he sold me on using tailwindcss. The thing about tailwind is that it is not a big component library, it’s a set of css classes mapped to a few (usually one) style.
All css classes are shitty, so you might as well use someone else’s shitty css classes on all your projects rather than thinking you’re being smart with a new set of classes that you will hate in 6 months when you come back to the project. roughly quoted from memory of @theprimeagen
So unlike big component libraries like tailwind, it comes with a cli that that it uses to create the final css file. It is able to treeshake out all the tailwind classes that you are not using and only ship the ones that you are using.
...
This is the greatest nvim emmet plugin I have tried. In the past I had tried the vim plugin a few times and just could not get a good flow with the keybindings and found it confusing for my occasional use. emmet-ls just uses lsp-completion, so its the same flow as other completions.
You can try it out by installing with :Mason
Tried out biome today and it worked better than prettier on jinja templates, I might adopt this over prettier.
An extension to disable elements during flight of an htmx request, Looks super useful for things like a create or delete button where the server would end up with an error if you double delete or double create. This eliminates an error path that the user might see under normal use of the ui.
The htmx-request class is added to htmx-target elements. You can target this css selector to create loading state throbbers.
By default the target element will the self, but you can use the typical htmx css selector to select which element will recieve the htmx-request class while the request is running.
The only way to override the name of the class is through config.
Prime concisely made sense of why htmx is so awesome compared to what has become modern reactive web dev in 2 minutes. I had never thought of it this way and it’s incredible.
One thing I have comepletely missed out on with my use of htmx is setting the disabled state while the server is working, what a genius move!
Three ways to support updating other content. Fantastic article walking through the different ways to update other parts of the screen using htmx.
In htmx there is no 2 way data binding, the dom is your state, and if you have elements derived from the same data on the screen in different places you need to think about how to keep them in sync.
Fastapi lets you tag your APIRouter’s so that the swagger docs are grouped according to the router.
router = APIRouter(tags=['router'])
Now all routes in router will appear in the router group in the swagger docs.
Tailwind css component library. There are many examples with copy and pastabily with the tailwind classes already setup.
A nice searchable cheatsheet for tailwindcss classes.
> A command-line utility for taking automated screenshots of websites
Daaaang, this is such an elegantly simple way to get web screenshots with a cli. I was literally up and running with two commands on my arch linux machine (which it warned was unsupported by playwright).
pip install shot-scraper # Now install the browser it needs: shot-scraper install shot-scraper waylonwalker.com shot-scraper https://datasette.io/ shot-scraper https://datasette.io/ -h 1280 -w 1920 shot-scraper https://datasette.io/ -h 480 -w 720 shot-scraper shot --selector '#posts' https://thoughts.waylonwalker.com/post/89
Note
shot-scraper https://datasette.io/is a full length screenshot of the entire page.Oh and its pretty dang fast, let alone the setup time, this crushes on startup time in my attempts to use a headless browser in the past.
An alternative approach to building modern web withhout heavy js and json, but instead html over the wire, keeping the logic in the backend of rails.