retypeapp / retype

Retype is an ✨ ultra-high-performance✨ static site generator that builds a website based on simple text files.
https://retype.com
Other
1.08k stars 204 forks source link

Add CSS escape hatches #639

Open patricklafrance opened 1 year ago

patricklafrance commented 1 year ago

I would like to propose the introduction of CSS escape hatches to Retype. I believe that could benefit not only myself but also potentially a wider range of developers and use cases as layout preferences tend to be very subjective.

By adding CSS escape hatches, that would enable developers to customize a few parts of Retype's layouts using CSS and would alleviate the pressure on the Retype core team to work on layout issues until they are ready to do so. Of course, that would be at the own risk of the developers who choose to leverage the CSS escape hatches.

In my experience, it's a pretty low effort solution to put in place and doesn't negatively impact the maintenance of the project afterward.

Personally, I would like Retype to provide CSS escape hatches so I can hide a few elements of the mobile layout.

There are examples of other platforms using CSS escape hatches to allow this type of customization, one of those is Storybook.

What is exactly CSS escape hatches? It's giving the ability to the developers to target specific elements that are rendered by Retype by adding a unique CSS class or ID to those elements.

Here's a few elements that I would like to have CSS escape hatches for.

Desktop layout:

css_escape_hatches_2

Mobile layout:

css_escape_hatches_3

Mobile layout, menu opened:

css_escape_hatches_4

Let me know what you think!

Thank you,

Patrick

geoffreymcgill commented 1 year ago

Yes, this is definitely something we can do. It's a relatively easy task.

Some of these elements already have id's or unique CSS classes applied, although not consistently.

What is your opinion on namespacing the id values with a retype- prefix? For example, using retype-header-nav vs header-nav.

The retype- prefix would help avoid id collisions with other custom elements that authors or plugins might add to the HTML, but the downside is a longer id value. Collisions without namespacing may be rare and id values are cleaner when they follow a predictable generic simplified naming convention.

patricklafrance commented 1 year ago

I agree, prefixing the ids with retype- is a great idea and a pattern that we usually also implements for our own libraries 👍🏻