Posted in vue
9342
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
152
This Month
1460
This Year
3970

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...

Subscribe to weekly updates about things i have added to the site or thought interesting during the last week.

You could also follow me on twitter or not... does anyone even use twitter anymore?

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
In this case my anchor this week becomes driving almost 2hrs outside of Atlanta to one of my favorite hard core gyms in the world.. MetroFlex aka The Dungeon. The gym owners turn the heat way up so it becomes a fun sweat box and the gym members just watch from afar and leave me alone. I happily drive myself long distances to find MY ANCHOR. Our anchor allows us to have balance, focus and be as productive as possible. And if you're in the middle of a heavy set and your headphones start to fall off your head, like mine did here.. well.. f*ck the headphones. Let em break and fall. You can always get a new pair, but the iron ain't ever gonna lift itself.
Unknown
Random CSS Property

@keyframes

The @keyframes CSS at-rule controls the intermediate steps in a CSS animation sequence by defining styles for keyframes (or waypoints) along the animation sequence. This gives more control over the intermediate steps of the animation sequence than transitions.
@keyframes css reference