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

Evaluate svelte-package and inlining styles #1871

Open
theetrain opened this issue Dec 27, 2023 · 5 comments
Open

Evaluate svelte-package and inlining styles #1871

theetrain opened this issue Dec 27, 2023 · 5 comments
Labels
enhancement New feature or request
Milestone

Comments

@theetrain
Copy link
Collaborator

theetrain commented Dec 27, 2023

Why

svelte-package helps convert component types and preprocessors into packaged components with separate type declarations files. With this tool, it may be possible to:

  1. Write components in Typescript, and import Carbon Sass within <style lang="sass">
  2. Have output component include separate .svelte and .svelte.d.ts files, and Sass styles be converted to scoped CSS

If proven successful, users of carbon-components-svelte should be able to import components without needing to manually import entire CSS themes, nor have to install Sass just to include component-specific styles. And they can add a global theme if they wish to use a theme other than the default (white).

Out of scope

@theetrain theetrain added the enhancement New feature or request label Dec 27, 2023
@theetrain theetrain added this to the v1.0.0 milestone Dec 27, 2023
@laurenceokite
Copy link

Is this the only issue that addresses scoping? Is there a way to only have styles apply to imported components?

@metonym
Copy link
Collaborator

metonym commented Aug 5, 2024

@laurenceokite Currently, carbon-preprocess-svelte offers a Vite plugin that will prune unused Carbon CSS in the build step. I would recommend trying that if using the pre-generated CSS from this library.

@laurenceokite
Copy link

Thanks, and this should address the styling that the css file applies globally to semantic html tags?

@metonym
Copy link
Collaborator

metonym commented Aug 5, 2024

@laurenceokite That's correct; the optimizeCss plugin is cautious in its approach. To minimize false positives, the plugin will only remove Carbon-specific classes (e.g., classes starting with .bx-- prefix) for unused components. For example, .bx--breadcrumbs will be removed if Breadcrumbs is not used.

For reference, here are some basic, example set-ups.

@laurenceokite
Copy link

Thanks a lot, I appreciate the detailed and expeditious response!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants