A crazy-small framework for building brutal/brutalist web applications
110 source lines of code. 2 functions: R
and render
This is React/JSX:
function ButtonWidget(props) {
return (
<button onClick={() => showModal(props.name)}>
Show {props.name} Modal
</button>
);
}
This is R/brutal.js:
function ButtonWidget({name}) {
return R`
<button click=${() => showModal(name)}>
Show ${name} Modal
</button>
`;
}
Basic usage:
render(App(), document.getElementById('root'));
- Event listeners are named by event names directly. No
on-
prefix. So useclick
notonlclick
- There is never any need to quote an attribute, brutal does it for you, so
title=${title}
nevertitle="${title}"
- every bit of HTML is tagged with an R and written with backticks. Technically, this is an ES6 template literal and template tag function.
- Every replaced value is enclosed in
${...}
instead of{...}
To me, brutalist means as close to the basic raw HTML/ JavaScript as possible. There's more to do on the roadmap, but for many projects, these simple functions are enough. For example, take a look at a working TodoMVC example made with brutal.js. Everything in brutal is "as close to the metal" ( the JS / HTML ) as possible. This is ensured by their being minimal JS code, minimal opinionation (everything is just HTML elements and event handlers), leaving you free to structure things however you like.
- Server side rendering / client-server symmetry
- Encourage / macro-ise targeted forms and named iframes ( sooo brutal )
- Encourage / bundle brutalist CSS sheets
If you know HTML and JS, you know brutal.js. Give it a spin, open an issue, make a PR, and let me know how you're using it, and where you think it should go.