[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">...< ...
随机推荐
- 使用命令进行Apache Kafka操作
1.目标 我们可以在Kafka集群上执行几个Apache Kafka Operations .因此,在本文中,我们将详细讨论所有Apache Kafka操作.它还包括有助于实现这些Kafka操作的命令 ...
- 一个长耗时SQL在TiDB和Mysql上的耗时测试
之前看到的TiDB和MySql的性能对比都是大量短耗时请求下的压测,单机情况下TiDB和MySql的确有些差距,不过笔者最近碰到的场景更多是sql要扫描的行数不小的情况下单sql比较耗时的问题,所以自 ...
- css之多行居中
需求: 单行到多行文字居中. <div> <p>应该为数组中的每个子代分配一个唯一的键.表格dataSource和中的值columns应遵循此规则.默认情况下</p> ...
- [CF436D]Pudding Monsters
题目大意:有一个长度为$2\times 10^5$的板,有$n(n\leqslant 10^5)$个格子$a_1,\dots,a_n$有布丁怪兽,一开始连续的怪兽算一个怪兽,有$m(m\leqslan ...
- 常用的MySQL命令
1.新建数据库: create database person; 2.使用数据库 use person: 3.创建一个表格 create table student ( id int(10) not ...
- 分享-SpringCloud微服务架构图
1: 为大家分享一张SpringCloud微服务通用架构图 标题 此图仅供参考: 需要原图的同学请移步 >>>>>>>>> 这里 如有不合理的地 ...
- 【openshift】在Openshift上通过yaml部署应用
在Openshift上通过yaml部署应用 1.通过直接执行yaml 通过如下命令直接执行 oc create -f nginx.yml nginx.yml apiVersion: v1 items: ...
- 聊聊GIS中的坐标系|再版
本文约6500字,建议阅读时间15分钟. 作者:博客园/B站/知乎/csdn/小专栏 @秋意正寒 版权:转载请告知,并在转载文上附上转载声明与原文链接(https://www.cnblogs.com/ ...
- day35-python之协程
1.协程 # import time # import queue # # def consumer(name): # # print("--->ready to eat baozi. ...
- AndroidStudio中Run按钮是灰色的解决方法
在model下拉框中选择app.如果下拉框中没有app,(没有工程名),那么请先去设置: Android Studio 3.3.0 File->sync project with gradles ...