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

How can someone that integrates Sparnatural in its own webpage customize the CSS ? #435

Closed
tfrancart opened this issue Jan 3, 2023 · 7 comments
Labels
kind: Enhancement 📈 New feature or request what: Packaging/Webpack Related to final bundle and webpack config what: UI/UX Affecting the UI or UX

Comments

@tfrancart
Copy link
Contributor

As the CSS is compiled and minified at compile-time, I don't think someone using this can adapt.
We have requests to be able to customize the CSS, maybe only the values that are in the "themes.scss" file. Maybe that file could be left external to the compiled CSS, so that users can adapt it (without having to recompile the whole thing) ?

See also #410 to provide 2 or 3 default color themes, which could be a temporary workaround

@SteinerPascal do you have an idea on this ?

In relation to this, I would find it nice if the "backgroundColor" config property be also part of the CSS theme, and not part of the settings passed to the Javascript. This would be more consistent.

@tfrancart tfrancart added kind: Enhancement 📈 New feature or request what: Packaging/Webpack Related to final bundle and webpack config what: UI/UX Affecting the UI or UX labels Jan 3, 2023
@SteinerPascal
Copy link
Collaborator

SteinerPascal commented Jan 10, 2023

Hi yes okay well i would not adivse on the customizing CSS solution. Because this would mean that people have to adapt the css within /node_modules folder. Now this folder should always remain idempotent regarding installs. Because as soon as Sparnatural would update, npm would pull the new version and overwrite the sparnatural folder within the node_modules ( and therefore the css as well). Additionally, the node_modules/ folder gets often deleted when having build or dependency issues. So if somebody deletes the node_modules/ folder and then does a reinstall with npm install would cause the css to be changed back again.

Edit:
Also if somebody uses sparnatural in its project and adapts the css within the node_modules will only work if this person also pushes its node_modules folder on his GitHub project (which obviously nobody does). otherwise somebody will download the project using sparnatual and do a npm install and npm will pull the sparnatural on the registry which has default css styling.

I would handle it incode i think... Maybe something like a single configuration property being a styling object. This could look like this in a website integration:

let style = {
  backgroundBaseColor: 'blabla',
  arrowColor: 'hexvalue',
  ...
}

Please note: I'm not an expert on these things so maybe you get a second opinion on this...

@tfrancart
Copy link
Contributor Author

I see it more as a CSS custom properties thing : https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_properties

@SteinerPascal
Copy link
Collaborator

Cool! yes I like it. If I understood it correctly, then there are two goals here. The first is to provide 2-3 different themes and the second objective is to provide the possibility to let the site authors adapt the component and it's vars. But there are definitely some things to consider. For the first goal I can see something similar like here:
https://sap.github.io/ui5-webcomponents/playground/customizing/theme/
Where we provide some single css theme sheets and people can just import their favourite?

For the second objective:
https://vaadin.com/blog/styling-web-components-with-css-variables
But I hink some things have to be considered here:

  • Namespaces for css are sometimes encabsulated in FrontEnd frameworks or by css bundlers
  • The css variable namespace should be best kept on Sparnatural scope. We don't want to clutter global namespaces
  • This requires some good documentation
  • This requires the site author to include the customization in their css

As you already thought, for the first solution this requires some webpack managing. But it seems pretty easy. If you or @antoine37120 provide two theme styles in seperate css sheets than i will handle the webpack part. Just open a new branch or for that

@SteinerPascal
Copy link
Collaborator

Be aware though that I think the theme should import the sparnatural.scss and not sparnatural.scss imports multiple themes.
Like so: https://webdesign.tutsplus.com/tutorials/how-to-use-sass-to-build-one-project-with-multiple-themes--cms-22104

@SteinerPascal
Copy link
Collaborator

@tfrancart I'm going to close this since I think it's done? Otherwise just reopen it

@tfrancart
Copy link
Contributor Author

tfrancart commented Feb 27, 2023 via email

@SteinerPascal
Copy link
Collaborator

Hi @tfrancart, I have ansered via mail!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: Enhancement 📈 New feature or request what: Packaging/Webpack Related to final bundle and webpack config what: UI/UX Affecting the UI or UX
Projects
None yet
Development

No branches or pull requests

2 participants