Replies: 1 comment
-
After some exploration, I decided to move on with the first option, but inspired by the second one. All variables will be moved to pure CSS (custom properties), we will get rid of Sass entirely, but we can keep some of its useful features as PostCSS plugins (such as nesting and mixins), meaning we will still ship pure CSS. This solution has the benefit of making theming much easier due to the differences in the nature of CSS custom properties as compared to Sass variables. About how the migration process, there are 2 main issues to tackle:
About the first, it's worth noting the following:
Without much further analysis, I think we can tackle them as follows: The following sources may be relevant to the conversion of Sass function to CSS: |
Beta Was this translation helpful? Give feedback.
-
Problem
With the new packaging functionality in SvelteKit, we get the benefit of being able to use TypeScript in the component source code without requiring the users to also install TypeScript (or any preprocessing we might want to do to improve Developer Experience). However, we cannot selectively apply preprocessing to some features (i.e.: TypeScript) and not others (i.e.: SCSS) without also breaking our docs since they are part of one project and the same preprocessing must be applied to all. This breaks our current schema of theme customization using SCSS.
This is currently blocking #349.
Inspiration
We can take a look at how some of the other UI libraries do styling/theming to see possible ways of going around this limitation.
Svelte UI:
createStyles
function (accepts a function with default theme that returns overridden values) in JSSvelte Material UI:
@use '@material/theme/index' as theme with ();
) + building theme with smui-theme and including as a<link>
Carbon components:
Smelte:
Sveltestrap:
Svelte Materialify (deprecated):
includePaths
, but@import
s vars instead of@use "..." as vars
so scope leaks.All of the above seem to have very different solutions than ours except for the last, which wouldn't work post SvelteKit migration.
Possible solutions
src
attribute remains on the<style>
tag, we can simply postprocess the output to remove the resulting CSS from this tag and keep SCSS required and everything as it was before the SvelteKit migration. We can also ship this "unpreprocessor" with the library instead of doing it ourselves so that users satisfied with the default styles don't need to install SCSS or preprocess anything.Personally, I'm more inclined towards the first solution, but I want to know the opinions of others who use the library.
Beta Was this translation helpful? Give feedback.
All reactions