Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(transformer): allow inline CSS styling #1551

Merged
merged 6 commits into from
Oct 30, 2024

Conversation

saberzero1
Copy link
Collaborator

@saberzero1 saberzero1 commented Oct 29, 2024

Closes #1527

Adds support to pass inline CSS as well as URLs to transformers. This is in line with current JavaScript resource inclusion in transformers.

For example, the following makes the body all green:

    // ofm.ts
    externalResources() {
      const js: JSResource[] = []

      // rest of code

      const css: CSSResource[] = [
        {
          content: `body {
            background-color: green !important;
          }`,
          inline: true,
        },
      ]
      return { css, js }
    }

@saberzero1 saberzero1 marked this pull request as ready for review October 29, 2024 18:27
@saberzero1 saberzero1 requested a review from aarnphm October 29, 2024 18:28
@aarnphm
Copy link
Collaborator

aarnphm commented Oct 30, 2024

We can default to inline to false

I think we can do something similar to scss for components

@saberzero1
Copy link
Collaborator Author

We can default to inline to false

Sure thing.

I think we can do something similar to scss for components

I assume in a separate PR? Or shall I include it in this one?

@aarnphm
Copy link
Collaborator

aarnphm commented Oct 30, 2024

oh i meant we should support scss given that we use scss

@saberzero1
Copy link
Collaborator Author

oh i meant we should support scss given that we use scss

I see.

This is for transformers though. It is meant for injecting into the resulting page. We don't support TypeScript for inlined JSResource either.

Copy link
Collaborator

@aarnphm aarnphm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. cc Jacky on this

@aarnphm
Copy link
Collaborator

aarnphm commented Oct 30, 2024

feel free to merge this whenever you are ready.

cc @jackyzha0 so that he knows about this

@saberzero1 saberzero1 merged commit 314a88d into jackyzha0:v4 Oct 30, 2024
5 checks passed
@saberzero1 saberzero1 deleted the inline-css branch October 30, 2024 23:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support inline css in transformer plugins
2 participants