Posted in vue
2375
12:51 am, August 31, 2022
 

Random User Profile Loading Script in vue

uses the random user ui here to generate profile boxes using vue js 

original script here:

https://codepen.io/l-i-lc/pen/WNxNwvd?editors=1010 

 

HTML

<div id="app">
   <el-row :gutter="20" v-if="users.length > 0" >
    <el-col :span="8" v-for="(user, index) in users" :key="user.id">
      <el-card :body-style="{ padding: '0px' }">
        <img :src="user.picture.large" class="image">
        <div style="padding: 14px;">
          <span>{{user.name.title}}. {{user.name.first}} {{user.name.last}}</span>
          <div class="bottom clearfix">
            <time class="time">{{ user.email }}</time>
          </div>
        </div>
      </el-card>
    </el-col>
  </el-row>
  
  <el-row v-else :gutter="20" class="wrapper">
        <el-col :span="8" v-for="(o, index) in 3" :key="o">
      <el-card :body-style="{ padding: '0px' }" class="wrapper-cell">
        <div class="no-image"></div>
        <div>
          <div class="text bottom clearfix">
            <div class="text-line"></div>
            <div class="text-line"></div>
          </div>
        </div>
      </el-card>
    </el-col>
  </el-row>
  
</div>

CSS

@import url("//unpkg.com/element-ui@2.13.0/lib/theme-chalk/index.css");
.el-card {
  margin-bottom: 1rem;
}

.el-card {
  margin-bottom: 1rem;
}

.time {
  font-size: 13px;
  color: #999;
}

.bottom {
  margin-top: 13px;
  line-height: 12px;
}

.button {
  padding: 0;
  float: right;
}

.image {
  width: 100%;
  display: block;
}

.clearfix:before,
.clearfix:after {
  display: table;
  content: "";
}

.clearfix:after {
  clear: both;
}

/* loading like facebook */
.wrapper {
  background: #fff;
}

@keyframes placeHolderShimmer {
  0% {
    background-position: -468px 0;
  }
  100% {
    background-position: 468px 0;
  }
}
.animated-background, .text-line, .no-image {
  animation-duration: 1.25s;
  animation-fill-mode: forwards;
  animation-iteration-count: infinite;
  animation-name: placeHolderShimmer;
  animation-timing-function: linear;
  background: #F6F6F6;
  background: linear-gradient(to right, #F6F6F6 8%, #F0F0F0 18%, #F6F6F6 33%);
  background-size: 800px 104px;
  height: 96px;
  position: relative;
}

.no-image {
  width: 100%;
}

.text-line {
  height: 10px;
  width: 230px;
  margin: 4px 0;
}

Scripts

<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.11/vue.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/element-ui/2.13.2/index.js"></script>

Javascript

new Vue({
  el: '#app',
  
  data() {
    return {
      users: []
    }
  },
  
  methods: {
    async fetchUsers() {
      const res = await fetch('https://randomuser.me/api/?results=10')
      const data = await res.json()
      this.users = data.results;
       }
  },
  
  mounted() {
    this.fetchUsers()
  }
})
{{user.name.title}}. {{user.name.first}} {{user.name.last}}

View Statistics
This Week
403
This Month
1561
This Year
6985

No Items Found.

Add Comment
Type in a Nick Name here
 
Search Code
Search Code by entering your search text above.
Welcome

This is my test area for webdev. I keep a collection of code here, mostly for my reference. Also if i find a good link, i usually add it here and then forget about it. more...

You could also follow me on twitter. I have a couple of youtube channels if you want to see some video related content. RuneScape 3, Minecraft and also a coding channel here Web Dev.

If you found something useful or like my work, you can buy me a coffee here. Mmm Coffee. ☕

❤️👩‍💻🎮

🪦 2000 - 16 Oct 2022 - Boots
Random Quote

The important thing is not to stop questioning. Curiosity has its own reason for existence. One cannot help but be in awe when he contemplates the mysteries of eternity, of life, of the marvelous structure of reality. It is enough if one tries merely to comprehend a little of this mystery each day. Never lose a holy curiosity.


Albert Einstein
Random CSS Property

grid-row-end

The grid-row-end CSS property specifies a grid item's end position within the grid row by contributing a line, a span, or nothing (automatic) to its grid placement, thereby specifying the inline-end edge of its grid area.
grid-row-end css reference