Skip to content

Strip CSS from React App #1952

Open
@rgaiacs

Description

@rgaiacs

This is related with #1856.

We are using a combination of Jinja2 and React.

  1. Jinja2 renders https://github.com/jupyterhub/binderhub/blob/1a445a2903910670bbc654b66eae870f96ad65c1/binderhub/templates/page.html into HTML.
  2. HTML is sent to the user's web browser.
  3. User's web browser parsers the HTML and make requests for assets.
  4. User's web browser receives https://github.com/jupyterhub/binderhub/blob/1a445a2903910670bbc654b66eae870f96ad65c1/binderhub/static/js/App.jsx
  5. User's web browser executes React based app
  6. React based app appends CSS file https://github.com/jupyterhub/binderhub/blob/main/binderhub/static/js/index.scss to <head>.

Because the CSS file is appended by React, this blocks users to customise the CSS.

Proposed change

I want to move

import "./index.scss";
import "@fontsource/clear-sans/100.css";
import "@fontsource/clear-sans/300.css";
import "@fontsource/clear-sans/400.css";
to https://github.com/jupyterhub/binderhub/blob/1a445a2903910670bbc654b66eae870f96ad65c1/binderhub/templates/page.html. This way, users can provide their own additional CSS file for customisation.

This will require to convert https://github.com/jupyterhub/binderhub/blob/main/binderhub/static/js/index.scss into CSS. This can be accomplished using webpack that is already a dependency of the project.

Alternative options

I could not think of viable alternative options.

User should not have to edit https://github.com/jupyterhub/binderhub/blob/1a445a2903910670bbc654b66eae870f96ad65c1/binderhub/static/js/App.jsx to change the style.

Edit https://github.com/jupyterhub/binderhub/blob/1a445a2903910670bbc654b66eae870f96ad65c1/binderhub/templates/page.html does not work because React will append the CSS and it will have precedence.

Who would use this feature?

This will be used by GESIS as part of the server migration mentioned in jupyterhub/mybinder.org-deploy#3264.

Other users of BinderHub also have interested in custom CSS as mentioned in #1949.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions