openui / open-ui

Maintain an open standard for UI and promote its adherence and adoption.
https://open-ui.org
Other
3.58k stars 191 forks source link

Migrate static site away from Gatsby. #485

Closed andrico1234 closed 1 year ago

andrico1234 commented 2 years ago

Research: Migrate static site away from Gatsby

This is a proof-of-concept to understand the complexities of moving our Open UI site away from Gatsby, to something more simple, like 11ty or SvelteKit.

Why do we want to do migrate away from React/Gatsby?

For the most part, the Open UI site is a data-driven and static site.

For almost every page, we render static content using MDX or JSON data, yet we're requiring contributors to understand React and Gatsby to easily make changes to the Open UI site.

While Gatsby's purpose is to develop blazing-fast websites, it requires knowledge of:

This adds a huge level of friction for those who want to contribute to Open UI. This isn't conducive for a community where anyone can easily contribute, not just React developers.

We want to reduce as much friction for people to contribute to the repo, by bringing the tech stack down to the lowest level needed. Ideally, down to little more than HTML, CSS, and JavaScript

Also, on several occassions, various members of the Open UI community have had problems with installing Gatsby, due to the notoriously fickle Sharp module.

image image image

The results of such a migration will ensure that the Open UI site is:

The aim of this proof-of-concept is to validate whether migrating to a tool like 11ty leads to the above effects.

I'm currently exploring this in the spike/11ty-exploration branch if anyone's interested in seeing this PoC in action.

Option 1: 11ty

I've begun exploring 11ty, which gives us flexibility in how we write our HTML templates and define our data. There are a handful

Option 2: ...

Suggest your own,

though I've considered tools like Rocket and Sveltekit as possible options.

Todo

Settle on a templating engine

11ty lets us choose from a handful of templating engines out of the box, such as Markdown, Nunjucks, EJS, and vanilla JS.

MDX is notably omitted, which is the template language we use for the majority of our static content in the existing site. We could look to use an MDX plugin for 11ty, but there look to be significant tradeoffs with doing so.

Prove migrating styles

In the current site, Open UI uses several methods for managing styles:

Components like the Header component have their own inline styles

There are also a handful of additional *.css files:

global.css, table-anatomy.css, spec.css, and anatomy.css.

Gatsby uses the Typography.js plugin to generate our styles at build-time and is then served as a static .css file.

Migrating styles

Using a standard .css solution may be simple enough for a such a site. To simplify the migration of the typography.js styles, we can leverage its toString() API which allows us to write out a css file at build time.

Typography offers an API that lets us convert the design object to a CSS output. We can invoke this function when our build starts to automatically generate our css file. Eleventy then handles the rest.

Prove migration of interactive elements

Instead of using React to manage complex UI, we can leverage web components instead.

One example of how to do this can be found here, but will add complexity to our build tooling.

Template engines like Nunjucks will allow us to reuse layouts, via frontmatters layout key, while we can use macros to reuse component logic.

While I'm still in the exploration phase with Nunjucks, the approach of using macros to reuse components doesn't feel as intuitive as writing JSZ, and passing through props. If this issue persists, it goes against one of the principles of this rewrite, to make the repo easier to contribute to.

Other possible avenues could be to:

Migration plan

Proof of concept

Pre-merge

Post-merge

daKmoR commented 2 years ago

Rockets goal is to be as close as possible to web standards... for example no dedicated template engine... using tagged template literals in html, markdown and js. Components are web components. Fully ESM.

I guess that would be a nice fit 💪

there are also major improvements happening right now 🎉 including SSR of web components 😱

https://twitter.com/daKmoR/status/1506601983293235209?s=20&t=SQN4cq-AV7mMi91aY11c-g

WIP website https://next.rocket.modern-web.dev/

andrico1234 commented 2 years ago

Thanks @daKmoR for commenting,

I've been playing with Rocket as an option since initially posting this issue. 😄 I haven't gotten too far with it, but having an mdjs file format was one of the biggest draws!

andrico1234 commented 2 years ago

Catch up 12/08/22

Agenda

Open Questions (for future)

Notes

github-actions[bot] commented 1 year ago

There hasn't been any discussion on this issue for a while, so we're marking it as stale. If you choose to kick off the discussion again, we'll remove the 'stale' label.

lukewarlow commented 1 year ago

The site now uses astro