Posted in vue
999
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
334
This Month
1081
This Year
5610

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
Nothing, to my way of thinking, is a better proof of a well ordered mind than a man's ability to stop just where he is and pass some time in his own company.
Seneca
Random CSS Property

mask-image

The mask-image CSS property sets the image that is used as mask layer for an element. By default this means the alpha channel of the mask image will be multiplied with the alpha channel of the element. This can be controlled with the mask-mode property.
mask-image css reference