yaminncco / vue-sidebar-menu

A Vue.js Sidebar Menu Component
MIT License
656 stars 193 forks source link

styling improvements #221

Closed mariusa closed 2 years ago

mariusa commented 2 years ago

Hi,

Would it be possible please to prefix scss variables with sidebar-menu- ? eg $primary-color -> $sidebar-menu-primary-color This way they won't conflict with other components.

Would be good to have this separated as well, with the default value $primary-color, but possible to overwrite: box-shadow: 3px 0px 0px 0px $primary-color inset; -> box-shadow: 3px 0px 0px 0px $sidebar-menu-shadow-color inset;

Thank you!

yaminncco commented 2 years ago

What about using the @use rule over @import?

mariusa commented 2 years ago

Interesting idea. I've tried in my app styles.scss

@import "variables";
@use "vue-sidebar-menu/src/scss/vue-sidebar-menu.scss";

but that gives

[vite] Internal server error: @use rules must be written before any other rules.
  ╷
3 │ @use "vue-sidebar-menu/src/scss/vue-sidebar-menu.scss";
  │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  ╵
  src/assets/scss/style.scss 3:1  root stylesheet

If I move use at the top, I can't overwrite variables anymore.

Also, I was expecting to overwrite vars like this

vue-sidebar-menu.$primary-color: #ffffff;

but that gives a warning identifier expected.

Now I overwrite with

$primary-color: #ffffff; 

and this works fine. The issue is that $primary-color is very generic instead of being specific to this library.

yaminncco commented 2 years ago
@use "./variables.scss" as variables;
@use "vue-sidebar-menu/src/scss/vue-sidebar-menu.scss" with (
  $primary-color: variables.$sidebar-menu-primary-color
);

Where $sidebar-menu-primary-color is in variables.scss

mariusa commented 2 years ago

Thank you!

Shall I make a PR with Would be good to have this separated as well, with the default value $primary-color, but possible to overwrite:

box-shadow: 3px 0px 0px 0px $primary-color inset; 
// to
box-shadow: 3px 0px 0px 0px $shadow-color inset;
yaminncco commented 2 years ago

Added $item-active-line-color in v5.2.0.

mariusa commented 2 years ago

Works great, thank you!