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: implement adoptedStyleSheets + optional native CSS nesting #420

Closed
wants to merge 3 commits into from

Conversation

shaal
Copy link
Contributor

@shaal shaal commented Aug 22, 2023

Description

This PR simplifies how we add slot styles from within the component.

  • Style Manager controller does the following:

  • Reads the CSS (that alternatively could be loaded globally by the consumer)

  • Only if generateRandomId === true -

    • Generate unique ID for the component (highest specificity)
    • Formats the CSS as a string, strips :host and :root
    • Uses native CSS nesting to add the unique ID ahead of the CSS rules
  • Uses adoptedStylesheets to modify the document's CSS (instead adding CSS into the DOM)

@shaal shaal self-assigned this Aug 22, 2023
@changeset-bot
Copy link

changeset-bot bot commented Aug 22, 2023

⚠️ No Changeset found

Latest commit: 2a7f342

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@netlify
Copy link

netlify bot commented Aug 22, 2023

Deploy Preview for outlinejs ready!

Name Link
🔨 Latest commit 2a7f342
🔍 Latest deploy log https://app.netlify.com/sites/outlinejs/deploys/65c264982a5ace0008a4845c
😎 Deploy Preview https://deploy-preview-420--outlinejs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@himerus himerus added Why: Reduce adoption friction Why: Improve security Difficulty: High Severity: Critical Held for Review Held for review. Considered as a Draft/POC. Why: Increase standardization Type: Controller Suggestion Use this label for any issue that is a recommendation for a specific type of controller. labels Aug 22, 2023
Copy link
Contributor

@himerus himerus left a comment

Choose a reason for hiding this comment

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

I think a lot of this is great.

We need to, however, consider the browser impact of the Native CSS nesting. It limits us to more browsers than adoptedStylesheet does presently. In 6 months, maybe a year, I think we'll be there. Based on several discussions around the browser support and our ongoing requirements, it's not a safe time to implement native nesting. We still have (and will for some time) have postcss in our toolchain.

If we could:

  • Remove CSS Nesting
  • Evaluate addPrefixToCurlyGroups when we aren't using native nesting
  • Focus on the functionality of addSlotStyles

This controller should primarily be responsible for:

  • Attaching a previously processed CSS file to adoptedStylesheet
  • Optionally wrapping the CSS file in a configurable selector. (Random ID, Class, Component, etc.)

@shaal shaal changed the title feat: implement adoptedStyleSheets + native CSS nesting feat: implement adoptedStyleSheets + optional native CSS nesting Aug 29, 2023
@himerus himerus marked this pull request as draft September 7, 2023 00:40
@himerus himerus added the CANNOT MERGE Temporary flag for a PR that has failing tests, broken pipelines, etc. label Sep 7, 2023
Copy link

coderabbitai bot commented Feb 6, 2024

Important

Auto Review Skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository.

To trigger a single review, invoke the @coderabbitai review command.


Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

@himerus
Copy link
Contributor

himerus commented Feb 6, 2024

Closing in favor of the slim @phase2/outline-adopted-stylesheets-controller controller

@himerus himerus closed this Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CANNOT MERGE Temporary flag for a PR that has failing tests, broken pipelines, etc. Difficulty: High Held for Review Held for review. Considered as a Draft/POC. Severity: Critical Type: Controller Suggestion Use this label for any issue that is a recommendation for a specific type of controller. Why: Improve security Why: Increase standardization Why: Reduce adoption friction
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants