mdbootstrap / Black-Friday-2023

Black Friday & Cyber Monday Deals (UI Kits WordPress Plugins, CRMs, SEO, Courses, Books) for web developers, programmers, and software engineers.
https://mdbootstrap.com/
MIT License
780 stars 125 forks source link

variable override is not working in MDB 5 #15

Closed mannok closed 3 years ago

mannok commented 4 years ago

I cannot override color variable as what I used to.

It should work by overriding bootstrap variable in xxx\node_modules\mdb-ui-kit\src\scss\custom\_variables.scss. I added some pieces of code as following:

// Your custom variables

$secondary: #00ea12;

However, it does not work. Nothing has been overrided when I do sth like <button class="btn btn-secondary"></button>. Is this broken in MDB 5?

UPDATE:

Seems that those variable inside _variable.scss do not have !default suffix

ViRuSTriNiTy commented 4 years ago

I was wondering whether a theming support is still there but no docs can be found. So I guess it has been dropped.

mannok commented 4 years ago

I was wondering whether a theming support is still there but no docs can be found. So I guess it has been dropped.

I believe they just forget to add !default suffix into source scss file. Here is a temporary workaround for who encountered this issue like what I did.

  1. open xxx\node_modules\mdb-ui-kit\src\scss\free\_variables.scss
  2. append !default; to the line of variable which you need to override
  3. enjoy
ViRuSTriNiTy commented 4 years ago

Here is a gulp task to inject !default flag automatically:


gulp.task('preprocess-mdbootstrap-scss-variables', function () {
    let result = gulp
        .src("node_modules/mdb-ui-kit/src/scss/free/_variables.scss", {
            base: "./" // make output of gulp.dest() relative to src, https://stackoverflow.com/a/24412960/3936440
        });

    // add missing default flag to variables to allow customization
    // https://github.com/mdbootstrap/mdb-ui-kit/issues/15
    const variables = ["primary", "secondary", "light", "dark"];

    variables.forEach(function (value) {
        var regex = new RegExp(`^\\$${value}:(.*);`, "gm");

        result.pipe(replace(regex, "$primary:$1 !default;"));
    });

    return result
        .pipe(gulp.dest("./", { overwrite: true }));
});
Martussky commented 4 years ago

Hi,

have you imported .custom/variables file on the top of the list of imported files within mdb.free.scss and then recompile it? It should work.

Best, Marta

ViRuSTriNiTy commented 4 years ago

Hi,

have you imported .custom/variables file on the top of the list of imported files within mdb.free.scss and then recompile it? It should work.

Best, Marta

Recompling a node module? I hear that for the first time. Tell me more ^^

Martussky commented 4 years ago

You need to extract scss files from node_modules, put the scss files in the root directory, overwrite variables and recompile mdb css file. If you have a problem with that, please use our Webpack starter: https://github.com/mdbootstrap/mdb-webpack-starter.

giacomotaormina commented 4 years ago

@Martussky The fix of copy the scss files in the root directory is temporary or is the solution? Do you have in roadmap the add "!default" tags in scss variables or not? This is necessary to customize the theme.

Martussky commented 3 years ago

Hi, we solved this problem in our package and we will release it in two weeks - 23.11.2020. Best, Marta

smolenski-mikolaj commented 3 years ago

Fixed with today's release (2.2.1).