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

Skills module doesn't respect selected styles. #864

Open
RogerAntonio opened this issue May 13, 2022 · 5 comments
Open

Skills module doesn't respect selected styles. #864

RogerAntonio opened this issue May 13, 2022 · 5 comments

Comments

@RogerAntonio
Copy link

RogerAntonio commented May 13, 2022

The selected styles don't get printed as classes.
Therefore it becomes difficult to apply styling to it.
The image below has 3 skills each with a different style selected.
image
image

The module also doesn't include default CSS which can make it seem broken.
Could bootstrap classes get implemented by default so they at least look good straight out of the box?

@peter-mw
Copy link
Member

Hi, we will fix them, the module is in this repo https://github.com/microweber-modules/skills

Seems the CSS disappeared

@RogerAntonio
Copy link
Author

Found out, that it's just "print" which is missing for the styles.
<?php print $skill['style'] ?>

@RogerAntonio
Copy link
Author

RogerAntonio commented May 15, 2022

I rewrote a bit of the module to overwrite in my template.
Feel free to use/alter this code.

This uses Bootstrap 5.

Also, I used another Script for the animating of the progress bar because the original one had issues where it would bounce instead of animate and stop.

My default.php

<?php

/*

type: layout

name: Default

description: Default

*/
?>
<div class="skills">
  <script>
    $(document).ready(function() {
      var isInViewport = function(elem) {
        var distance = elem.getBoundingClientRect();
        return (
          distance.top >= 0 &&
          distance.left >= 0 &&
          distance.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&
          distance.right <= (window.innerWidth || document.documentElement.clientWidth)
        );
      };
      var findMe = document.querySelectorAll('.progress');

      // add event on scroll
      window.addEventListener('scroll', function(event) {
        findMe.forEach(element => {
          //if in Viewport
          if (isInViewport(element)) {
            element.classList.remove("initial-progress");
          }
        });
      }, false);
    });
  </script>
  <?php

  $file = get_option('file', $params['id']);
  if (!!$file) {
    $skills = json_decode($file, true);

    foreach ($skills as $skill) { ?>
      <div class="progress-header d-flex align-items-center">
        <h6>
          <?php print $skill['skill']; ?>
        </h6>
        <div class="ms-auto count"><?php print $skill['percent'] . "%"; ?></div>
      </div>
      <div class="progress initial-progress" data-percent="<?php print isset($skill['percent']) ? $skill['percent'] : 50; ?>%">
        <div class="progress-bar count-bar bg-<?php print $skill['style'] ?>" style="width: <?php print $skill['percent'] . "%"; ?>" aria-valuenow="<?php print $skill['percent']; ?>" aria-valuemin="0" aria-valuemax="100">
          <div class="count"><?php print $skill['percent'] . "%"; ?></div>
        </div>
      </div>
  <?php }
  } else {
    print lnotif('Click to insert skills');
  }
  ?>
</div>

My SCSS:

/* Skills */
.progress {
  border-radius: var(--ui-border-radius);
  .progress-bar {
    @include transition(width);
    transition-duration: 1s;
    &.bg-,
    &.bg-primary {
      background-color: rgba(var(--primary-color), 1);
    }
    &.bg-secondary {
      background-color: rgba(var(--secondary-color), 1);
    }
    &.bg-tertiary {
      background-color: rgba(var(--tertiary-color), 1);
    }
    &.bg-dark {
      background-color: $bgcolor-black;
    }
    &.bg-light {
      background-color: $bgcolor-light;
    }
  }
  &.initial-progress .progress-bar {
    width: 0% !important;
  }
}
.progress-header > * {
  line-height: 1.2;
  margin-bottom: 0.5rem;
}

@peter-mw
Copy link
Member

Here are also other examples https://www.bestjquery.com/lab/progress-bar/

@RogerAntonio
Copy link
Author

Here are also other examples https://www.bestjquery.com/lab/progress-bar/

We could implement those if the module were updated to allow for skin changes (for the entire module, not per progress bar)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants