[React] Create an Animate Content Placeholder for Loading State in React
We will create animated Content Placeholder as React component just like Facebook has when you load the page.
Key points:
1. For each elements on the DOM, you might need to create a placeholder components for that.
2. Different size prop is important
3. CSS animation
.placeholder {
position: relative;
overflow: hidden;
}
.placeholder:before {
content: " ";
position: absolute;
top:;
right:;
bottom:;
left:;
background: linear-gradient(
to right,
rgba(255, 255, 255, 0) 0%,
rgba(255, 255, 255, 0.35) 8%,
rgba(255, 255, 255, 0) 16%
);
animation: scanner 0.9s linear infinite;
z-index:;
}
@keyframes scanner {
0% {
transform: translateX(-20%);
}
100% {
transform: translateX(170%);
}
}
.placeholder__headline {
height: 22px;
background-color: var(--placeholder-color);
margin-bottom: 20px;
}
.placeholder__text {
height: 16px;
background-color: var(--placeholder-color);
margin-bottom: 8px;
}
.placeholder__image {
border-radius: 50%;
background-color: var(--placeholder-color);
height: 100px;
}
.placeholder__text--small {
width: 25%;
}
.placeholder__text--medium {
width: 50%;
}
.placeholder__text--large {
width: 75%;
}
.placeholder__text--block {
width: 100%;
}
Placeholder.jxs:
import React from "react";
import cx from "classnames"; export default function Placeholder({ children, className }) {
return <div className={cx(className, "placeholder")}>{children}</div>;
}
import React from "react";
export default function Image() {
return <div className="placeholder__image" />;
}
[React] Create an Animate Content Placeholder for Loading State in React的更多相关文章
- [React] Use CSS Transitions to Avoid a Flash of Loading State
Based on research at Facebook, we know that if a user sees a flash of loading state, they perceive t ...
- React Js之组件(Component)与state
React Js组件: 组件(Component)是为了更好的维护我们的应用,可以在不影响其他的组件的情况下更新或者更改组件. state:是标记数据的来源,我们使state比较简单和单一,如果我们有 ...
- 《React Native 精解与实战》书籍连载「React Native 源码学习方法及其他资源」
此系列文章将整合我的 React 视频教程与 React Native 书籍中的精华部分,给大家介绍 React Native 源码学习方法及其他资源. 最后的章节给大家介绍 React Native ...
- 《React Native 精解与实战》书籍连载「React Native 底层原理」
此文是我的出版书籍<React Native 精解与实战>连载分享,此书由机械工业出版社出版,书中详解了 React Native 框架底层原理.React Native 组件布局.组件与 ...
- 《React Native 精解与实战》书籍连载「React 与 React Native 简介」
此文是我的出版书籍<React Native 精解与实战>连载分享,此书由机械工业出版社出版,书中详解了 React Native 框架底层原理.React Native 组件布局.组件与 ...
- React子组件怎么改变父组件的state
React子组件怎么改变父组件的state 1.父组件 class Father extends React.Component { construtor(props){ super(props); ...
- [Svelte 3] Use await block to wait for a promise and handle loading state in Svelte 3
Most web applications have to deal with asynchronous data at some point. Svelte 3 apps are no differ ...
- React virtual DOM explained in simple English/简单语言解释React的虚拟DOM
初学React,其中一个很重要的概念是虚拟DOM,看了一篇文章,顺带翻译一下. If you are using React or learning React, you must have hear ...
- CSS3效果:animate实现点点点loading动画效果(一)
实现如图所示的点点点loading效果: 一:CSS3 animation实现代码 html代码: 提交订单中<span class="ani_dot">...< ...
随机推荐
- yzoj2424 小迟的数字 题解
题意:如果一个数字用十进制表示,有大于等于1个1,或者大于等于2个2,或者大于等于3个3,或者大于等于4个4,或者大于等于5个5,或者大于等于6个6,或者大于等于7个7,或者大于等于8个8,或者大于等 ...
- Linux05 文件或目录的权限(ls、lsattr、chattr、chmod、chown、chgrp、file)
一.查看文件或目录的权限:ls -al 文件名/目录名 keshengtao@LAPTOP-F9AFU4OK:~$ ls -al total drwxr-xr-x keshengtao keshen ...
- 【NOIP2017】宝藏 题解(状压DP)
题目描述 参与考古挖掘的小明得到了一份藏宝图,藏宝图上标出了 nnn 个深埋在地下的宝藏屋, 也给出了这 nnn 个宝藏屋之间可供开发的m mm 条道路和它们的长度. 小明决心亲自前往挖掘所有宝藏屋中 ...
- redis网文
1.为什么说Redis是单线程的以及Redis为什么这么快!https://blog.csdn.net/chenyao1994/article/details/794913372.Redis上踩过的一 ...
- golang ---调用window api函数执行程序
package main import "syscall" import "unsafe" func main() { var hand uintptr = u ...
- Windows服务创建及发布
二.创建Windows Service 1.新建一个Windows Service,并将项目名称改为“MyWindowsService”,如下图所示: 2.在解决方案资源管理器内将Service1.c ...
- screen命令下,自启动设置
建立autostart.sh文件 #!/bin/bash screen_name=$"coffeetest:9100" screen -dmS $screen_name cmd=$ ...
- js中的call()、apply()、bind()
js中的一个核心概念就是对this的理解,关于this前面也有说过,不过在有些情况下,还是需要手动去改变this的指向,这里总结一下,js中关于this操作的三种方法 call() apply() b ...
- elasticsearch 7版本 基础操作
elasticsearch 7版本 基础操作 首先我们浏览器http://localhost:5601/进入 kibana里的Console中输入 首先让我们在 Console 中输入: PUT t1 ...
- ubuntu-网络配置文件
vim /etc/NetworkManager/system-connections/Wired connectione 1