[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">...< ...
随机推荐
- Prometheus入门到放弃(7)之redis_exporter部署
redis监控,prometheus需要使用redis_exporter客户端. 这里我们采用docker方式部署,既可以部署在redis所在服务器,也可以部署在其他机器: docker镜像地址:ht ...
- Redis Cluster集群重启出现的问题
Redis Cluster集群重启出现的问题 由于机器故障导致redis集群停止,再次重启集群出现如下错误:Redis Cluster集群重启出现的问题:[ERR] Node 192.168.3.1: ...
- python with方法
在实际的编码过程中,有时有一些任务,需要事先做一些设置,事后做一些清理,这时就需要python with出场了,with能够对这样的需求进行一个比较优雅的处理,最常用的例子就是对访问文件的处理. 一般 ...
- mysql中sum与if,case when 结合使用
1.sum与if结合使用 如图:数据表中,count_money 字段可为正,可为负.为正表示收入,负表示支出. 统计总收入,总支出. select sum(if(count_money > 0 ...
- yii2 发送邮件 yii\swiftmailer\Mailer
Yii2 中发送邮件 yii\swiftmailer\Mailer 'mailer' => [ 'class' => 'yii\swiftmailer\Mailer', 'viewPath ...
- oralce数据表空间满了
--切换至oralce用户 su - oracle--执行sqlplus / as sysdba --查询表空间使用情况SELECT Upper(F.TABLESPACE_NAME) "表空 ...
- C#使用共享内存与C++进行数据交互
现在做桌面的不多了.前端太流行了,大家都去搞前端了. 需求如下: 上层UI使用C#开发,数据采集模块使用C++开发.数据采集模块采集到的数据比较大,上层需要接收这一块数据并显示 进程间通信的方式有多种 ...
- Spring中ApplicationContextAware的作用
ApplicationContextAware 通过它Spring容器会自动把上下文环境对象调用ApplicationContextAware接口中的setApplicationContext方法. ...
- 记redis一次Could not get a resource from the pool 异常的解决过程
最近有个项目中的redis每天都会报 "Could not get a resource from the pool"的错误,而这套代码在另一地方部署又没有问题.一直找不到错误原因 ...
- ASP.NET Core 过滤器中使用依赖注入
如何给过滤器ActionFilterAttribute也用上构造函数注入呢? 一般自定义的过滤器直接用特性方式标识就能使用 [ContentFilter] 因为构造函数在使用的时候要求传参,然后我们可 ...