[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">...< ...
随机推荐
- Linux06 文件的打包和压缩(gzip/gunzip、tar、bzip2)
一.gzip/gunzip 这是用于压缩和解压单个文件的工具,且使用方法比较简单 gzip 文件名 gunzip 文件名 二.tar(用的比较多) 不仅可以用于打包文件,还可以将整个目录中的全部文 ...
- API总结
1. 什么是Webservice WebService就是一个应用程序向外界暴露出一个能通过Web进行调用的API,也就是说能用编程的方法通过 Web 来调用这个应用程序.我们把调用这个WebServ ...
- Ubuntu遇到apt-get update报错:"E: Could not get lock /var/lib/apt/lists/lock"
sudo apt-get update报错:"E: Could not get lock /var/lib/apt/lists/lock" 出现此问题的原因可能是有另外一个程序在运 ...
- 作业调度框架Quartz.NET | 大专栏
原文:作业调度框架Quartz.NET | 大专栏 作业调度框架Quartz.NET 发表于 2019-09-28 | 分类于 前端 | 没有评论 前言 任务调度系统并不是完美的,它会出现任务执行 ...
- 解决COM组件在WPF设计器中命名空间不存在XXX的问题(附带如何在WPF中使用APlayer引擎)
总结起来就是:设计器的版本要跟外部引用的库版本一致,否则XAML设计器就会显示不出来. 例如你的程序是X64的,但是引用的COM组件是32位的,就会显示不出来.这里的建议是:编译一个32位的COM中间 ...
- (六) Docker 部署 Redis 高可用集群 (sentinel 哨兵模式)
参考并感谢 官方文档 https://hub.docker.com/_/redis GitHub https://github.com/antirez/redis happyJared https:/ ...
- cefsharp System.IO.FileNotFoundException: 未能加载文件或程序集“CefSharp.Core.dll”或它的某一个依赖项。
解决办法 安装vc++ 2015 Redistributable 64位系统安装x64 如果还报错先装x64版本再装x86版本 https://files.cnblogs.com/files/xuej ...
- 1 集群状态、增删改查、全量替换、强制创建、设置单个index的分片数副本数
检查集群健康状态,可以看集群颜色.(黄色:primary shard都正常,replica不正常) GET /_cat/health?v 列出集群所有index GET /_cat/indices?v ...
- 中兴软开C++面经(一站式西安)- 2019秋招
大概是9.6发短信邀请面试,但是6号有三个面试+一个在线笔试,就打算先去平安产险,看中途能不能再面个云从,中兴后面再面.然而,平安等了差不多4个小时才面完,期间云从面试官打来电话,只能说抱歉.中兴本来 ...
- Ceph集群部署(基于Luminous版)
环境 两个节点:ceph0.ceph1 ceph0: mon.a.mds.mgr.osd.0.osd.1 ceph1: mon.b.osd.2.osd.3 操作系统:ubuntu14.04 网络配置: ...