[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">...< ...
随机推荐
- Kafka性能调优 - Kafka优化的方法
今天,我们将讨论Kafka Performance Tuning.在本文“Kafka性能调优”中,我们将描述在设置集群配置时需要注意的配置.此外,我们将讨论Tuning Kafka Producers ...
- python基础 — 数据组合
a = [1, 2, 3] b = [4, 5, 6] c = [7, 8, 9] for x, y, z in (a, b, c): print(x, y, x) print(type(zip(a, ...
- 解决python中的Non-UTF-8 code starting with ‘\xbs4’ in file错误
出现错误如下图: 主要原因为编辑python脚本使用的编辑器编码有问题.我使用的编辑器是notepad++,由于没有做Python语言编辑配置,默认使用的是ANSI编码(右下角位置有编码格式),如下: ...
- golang程序因未知错误崩溃时如何记录异常
开发服务器程序时如果未经过充分测试, 服务稳定运行一段时间后会突然崩溃退出.一般是因为程序中出现了某个未捕获的异常. 这类问题属于偶现的,且需要服务器运行一段时间之后才会出现,难以定位有问题的代码段. ...
- Numpy学习笔记(上篇)
目录 Numpy学习笔记(上篇) 一.Jupyter Notebook的基本使用 二.Jpuyter Notebook的魔法命令 1.%run 2.%timeit & %%timeit 3.% ...
- TweenLite参数用法中文介绍
TweenLite是一个缓动的类包,功能强大,并且易于使用,为了更多的(E文欠佳的.初学的)朋友了解它,使用它,特此翻译了一下TweenLite类文档中的说明文件,主要是对参数的说明,希望对大家有用. ...
- Locust性能测试_百度案例
一.安装: 1.Locust在PyPI上可用,可以通过pip或easy_install安装:pip install locustio 2.查看Locust可用选项:loc ...
- Centos7 在线安装开发环境 jdk1.8+mysql+tomcat
写在最前 刚刚开始接触Linux,并折腾着在服务器上部署自己的项目,当然作为一个后端开发人员,必不可少的东西肯定是 JDK Mysql Tomcat容器 每天记录一天,每天进步一点点~~ 1.更新系统 ...
- Disruptor与Netty实现百万级(十)
实体对象: import java.io.Serializable; public class TranslatorData implements Serializable { private sta ...
- JS函数的三种方式
函数,一段能够自动完成某些功能的代码块,函数的出现,既解决了重复使用重一功能的需求,又可以避免代码的臃肿性. 使用函数有两个要求:必须调用后才可以执行;函数名不要和关键字以及系统函数相同; 函数主要有 ...