reactive-python / reactpy-django

It's React, but in Python. Now with Django integration.
https://reactive-python.github.io/reactpy-django/
MIT License
322 stars 18 forks source link

Link Django CSS to components (CSS Modules) #227

Open Archmonger opened 6 months ago

Archmonger commented 6 months ago

Description

Currently, styles can only loosely be tied to components via CSS. This PR allows ReactPy to parse a CSS file and apply the CSS rules as in-line styles.

These styles are applied server-side, so certain limitations are unavoidable. For example, there's no way for media queries to function under this architecture, since the server currently has no way to query client-side DOM properties.

It's going to be an uphill battle to develop support for all CSS psuedo-selectors (ex. :first-child).

Some event based psuedo-selectors are going to be challenging as well (such as :hover). For example, event-based pseudo-selectors (such as :hover) may need to be handled via automatically generated html.script. Would be some ugly stuff though.

This PR may end up pivoting to a different design, or perhaps allow configurability between different client/server side methods of applying CSS.

fix #211

Checklist

Please update this checklist as you complete each item:

By submitting this pull request I agree that all contributions comply with this project's open source license(s).