halfmoonui / halfmoon

Halfmoon is a highly customizable, drop-in Bootstrap replacement. It comes with three built-in core themes, with dark mode support for all themes and components.
https://www.gethalfmoon.com
MIT License
3.03k stars 118 forks source link

Constants, variables computed or inherited #55

Closed Swizz closed 3 years ago

Swizz commented 3 years ago

Hi there, you did an awesome job here !

I have only one little concern. I was playing arround with .custom-switch>(input+label) especially about width ; when I found this :

--switch-width: 3.2rem;
--switch-slider-width-height: 1.2rem;
--switch-slider-left: 0.5rem;
--switch-slider-left-checked: 1.5rem;

Trying to change the width of the switch, I was wondering how the --switch-slider-left-checked was calculated. Then I came to this :

--switch-slider-left-checked: calc(
  var(--switch-width) - var(--switch-slider-width-height) - var(--switch-slider-left)
);

So I did a little quick search, and found another constants that are somehow calculated but written by hand ; and a little fews or no calc().

So here is the question :

Somehow, setting only a variable that will snow ball all the others ones that may depend on it, could be so powerful ! What do you think ?

Cheers,

halfmoonui commented 3 years ago

Good point. This type of thing was definitely not a core design choice on my part. The simple truth is that there are so many variables that I simply missed out on places where the calc() function could be used to great effect. The example you gave with the switch is a great example of such a scenario. There are probably many more places where calc() can be used to improve the extensibility of the framework, and if someone points out more, I would greatly appreciate that.

About your specific change, I can hopefully patch this out in the next (minor) release.

halfmoonui commented 3 years ago

This has been fixed in the latest release. Moreover, I have created a pinned issue to finding other places where calc() can be used: https://github.com/halfmoonui/halfmoon/issues/62

Thank you for bringing this up. I will go ahead and close this.