zalog / placeholder-loading

Simple and flexible, css only, content placeholder loading animation. https://zalog.github.io/placeholder-loading/
MIT License
1.48k stars 149 forks source link

feat: adds no wrap demo, refactors Y margins #22

Closed MickL closed 3 years ago

MickL commented 3 years ago

LE:

Fixes #20

zalog commented 3 years ago

Hi @MickL, thanks again for your time! :)

If it's ok with you, let's make some changes please:

Nice touch about pointer-events.

DKhalil commented 3 years ago
  • revert modification from cols. Please let's try to keep grid output as low as possible for now. If this is requested by our community again, we can reconsider it then :)

Just to add my 2 cents, but I'd really like to see more column options as well! But you could consider adding a configuration setting like in bootstrap, if you don't want to unnecessarily bloat up the final css file:

https://github.com/twbs/bootstrap/blob/e79c8f3489527d7f5eef2bb3cf14856f26c49871/scss/_variables.scss#L332-L334 https://github.com/twbs/bootstrap/blob/e79c8f3489527d7f5eef2bb3cf14856f26c49871/scss/mixins/_grid.scss#L61

zalog commented 3 years ago

"But you could consider adding a configuration setting like in bootstrap" - wooow love it! :)

If you have time for this, please feel free to make a new PR, if not thanks for the idea, we'll do this.

MickL commented 3 years ago

Hey guys, will check tomorrow. Just so you know you can directly commit to this PR of you want.

Btw im not super happy that it seema to be required to have an extra col before row and col's

zalog commented 3 years ago

"it seema to be required to have an extra col before row and col's" - hmm, I don't think so. Or I don't get it, could you give an example please?

MickL commented 3 years ago

I mean that this works:

<div class="ph-item">
        <div class="ph-col-12">
          <div class="ph-row">
            <div class="ph-col-2 empty"></div>
            <div class="ph-col-8"></div>
            <div class="ph-col-2 empty"></div>
          </div>
        </div>
      </div>
</div>

But this does not:

<div class="ph-item">
          <div class="ph-row">
            <div class="ph-col-2 empty"></div>
            <div class="ph-col-8"></div>
            <div class="ph-col-2 empty"></div>
          </div>
      </div>
</div>

Or:

          <div class="ph-row">
            <div class="ph-col-2 empty"></div>
            <div class="ph-col-8"></div>
            <div class="ph-col-2 empty"></div>
          </div>
      </div>

-> There is always an extra ph-col required to wrap which is unnecessary.

zalog commented 3 years ago

Hi @MickL any news about code review, do you need some help?

About the wrapper. This PR resets the wrapper that still exists in our markup, so your solution includes it. I think removing wrapper would be breaking change, so it would be better to keep that in a separated new PR.

What do you think?

MickL commented 3 years ago

I didnt had time yet. Guess I will end up rewrite all this code for my project. I dont like that I need so many unnecessary wrappers. And I dont want to refactor all your code, I dont think that you will like it.

You can make changes to this PR directly so feel free to contribute and fix the things mentioned above.

zalog commented 3 years ago

Ok @MickL. Thank you very much for your time, contribution and ideas. Sure, I'll get back here in a few days with some changes and I hope you'll like it. Keep in touch. Have a great day.

MickL commented 3 years ago

Hey, so as I said I ended up writing my own placeholders. But I want to give you what I have learned and what would be useful in your library:

MickL commented 3 years ago

Here is my final code

$ph-bg:                       white;
$ph-color:                    $gray-300;
$ph-image-height:             120px;
$ph-height:                   18px;
$ph-height-small:             15px;
$ph-height-h1:                80px;
$ph-height-h2:                58px;
$ph-height-h3:                44px;
$ph-height-h4:                25px;
$ph-grid-columns:             12;
$ph-gutter-width:             $grid-gutter-width/4;
$ph-animation-duration:       .8s;

div[class^="ph-col"],
.ph-image,
.ph-round {
  background-color: $ph-color;
}

.ph-row {
  display:       flex;
  margin-bottom: $ph-gutter-width;

  &.center {
    justify-content: center;
  }

  &.right {
    justify-content: flex-end;
  }
}

.ph-image {
  height: $ph-image-height;
  width:  100%;
}

.ph-round {
  border-radius: 50%;
  width:         $ph-image-height;
  height:        $ph-image-height;
}

div[class^="ph-col"] {
  &.empty {
    background-color: transparent;
  }

  &.small {
    height: $ph-height-small;
  }

  &.h1 {
    height: $ph-height-h1;
  }

  &.h2 {
    height: $ph-height-h2;
  }

  &.h3 {
    height: $ph-height-h3;
  }

  &.h4 {
    height: $ph-height-h4;
  }
}

@each $breakpoint in map-keys($grid-breakpoints) {
  $infix: breakpoint-infix($breakpoint, $grid-breakpoints);

  @include media-breakpoint-up($breakpoint, $grid-breakpoints) {
    @if $grid-row-columns > 0 {
      @for $i from 1 through $ph-grid-columns {
        .ph-col#{$infix}-#{$i} {
          background-color: $ph-color;
          flex:             0 0 auto;
          width:            percentage($i / $ph-grid-columns);
          height:           $ph-height;
        }
      }
    }
  }
}
zalog commented 3 years ago

Wow! Thank you! I think you did a great job :) I'll keep you up2date with what we'll decide here.

zalog commented 3 years ago

Hi @MickL!

Please take a look, I think we are done.

Changes:

Regarding on this type of animation... Sorry, is tightly coupled with background. So if we need to use a transparent background we have to remove it. In the near feature I plan to add a second animation, some simple loading circle :)

I think this is the best we can get with no breaking changes :) What do you think?

Again, thanks a lot for your time and precious contributions.

LE: please take a look at this PR #25. I think we should enable ltr support also for no wrapped version. Do you have any suggestion on where to move direction css prop?

zalog commented 3 years ago

Hi @MickL,

what do you think? Do you have any feedback or suggestions here :)

zalog commented 3 years ago

Hi guys. I updated the PR description accordingly with the latest commits :)

DKhalil commented 3 years ago

@zalog how are you feeling about the inclusion of the column generation code that @MickL integrated? That way everyone can just configure the amount of columns they'd like to have

MickL commented 3 years ago

Cols AND breakpoints are important imo

zalog commented 3 years ago

Sure, that's a great idea. Actually I love it :), but we try to keep PR's small and close them fast. So, @MickL you can open a new branch/PR, or I'll do that and mention you there. How that's sounds for you guys?

MickL commented 3 years ago

I agree to keep PRs small. I will not have the time but I posted my code above that you can copy from. @DKhalil I would open another issue for dynamic cols and breakpoints.

zalog commented 3 years ago

Tnks @MickL

Ok, we'll merge this, and I'll keep you guys posted in a future PR.