mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Add hotbar cell animations
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
512639df5e
commit
ba54108860
@ -5,6 +5,7 @@
|
|||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
user-select: none;
|
user-select: none;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
transition: none;
|
||||||
|
|
||||||
div.MuiAvatar-colorDefault {
|
div.MuiAvatar-colorDefault {
|
||||||
font-weight:500;
|
font-weight:500;
|
||||||
@ -12,13 +13,9 @@
|
|||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
}
|
}
|
||||||
|
|
||||||
&.interactive {
|
|
||||||
margin-left: -3px;
|
|
||||||
border: 3px solid var(--clusterMenuBackground);
|
|
||||||
}
|
|
||||||
|
|
||||||
&.active {
|
&.active {
|
||||||
box-shadow: 0 0 0 1px var(--clusterMenuBackground), 0px 0px 0 4px white;
|
box-shadow: 0 0 0px 3px #ffffff;
|
||||||
|
transition: all 0s 0.8s;
|
||||||
}
|
}
|
||||||
|
|
||||||
&.active, &.interactive:hover {
|
&.active, &.interactive:hover {
|
||||||
|
|||||||
@ -50,6 +50,7 @@
|
|||||||
background: var(--layoutBackground);
|
background: var(--layoutBackground);
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
transform: translateZ(0); // Remove flickering artifacts
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
.cellDeleteButton {
|
.cellDeleteButton {
|
||||||
@ -58,6 +59,19 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.animating {
|
||||||
|
&.empty {
|
||||||
|
animation: shake .6s cubic-bezier(.36,.07,.19,.97) both;
|
||||||
|
transform: translate3d(0, 0, 0);
|
||||||
|
backface-visibility: hidden;
|
||||||
|
perspective: 1000px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:not(.empty) {
|
||||||
|
animation: outline 0.8s cubic-bezier(0.19, 1, 0.22, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.cellDeleteButton {
|
.cellDeleteButton {
|
||||||
width: 2rem;
|
width: 2rem;
|
||||||
height: 2rem;
|
height: 2rem;
|
||||||
@ -148,3 +162,32 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@keyframes shake {
|
||||||
|
10%, 90% {
|
||||||
|
transform: translate3d(-1px, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
20%, 80% {
|
||||||
|
transform: translate3d(2px, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
30%, 50%, 70% {
|
||||||
|
transform: translate3d(-4px, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
40%, 60% {
|
||||||
|
transform: translate3d(4px, 0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Use theme-aware colors
|
||||||
|
@keyframes outline {
|
||||||
|
0% {
|
||||||
|
box-shadow: 0 0 0px 11px $clusterMenuBackground, 0 0 0px 15px #ffffff00;
|
||||||
|
}
|
||||||
|
|
||||||
|
100% {
|
||||||
|
box-shadow: 0 0 0px 0px $clusterMenuBackground, 0 0 0px 3px #ffffff;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,7 +1,7 @@
|
|||||||
import "./hotbar-menu.scss";
|
import "./hotbar-menu.scss";
|
||||||
import "./hotbar.commands";
|
import "./hotbar.commands";
|
||||||
|
|
||||||
import React, { ReactNode } from "react";
|
import React, { ReactNode, useState } from "react";
|
||||||
import { observer } from "mobx-react";
|
import { observer } from "mobx-react";
|
||||||
import { HotbarIcon } from "./hotbar-icon";
|
import { HotbarIcon } from "./hotbar-icon";
|
||||||
import { cssNames, IClassName } from "../../utils";
|
import { cssNames, IClassName } from "../../utils";
|
||||||
@ -58,7 +58,7 @@ export class HotbarMenu extends React.Component<Props> {
|
|||||||
const entity = this.getEntity(item);
|
const entity = this.getEntity(item);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<HotbarCell key={index}>
|
<HotbarCell key={index} index={index}>
|
||||||
{entity && (
|
{entity && (
|
||||||
<HotbarIcon
|
<HotbarIcon
|
||||||
key={index}
|
key={index}
|
||||||
@ -68,11 +68,6 @@ export class HotbarMenu extends React.Component<Props> {
|
|||||||
onClick={() => entity.onRun(catalogEntityRunContext)}
|
onClick={() => entity.onRun(catalogEntityRunContext)}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{!entity && (
|
|
||||||
<div className="cellDeleteButton" onClick={() => HotbarStore.getInstance().removeEmptyCell(index)}>
|
|
||||||
<Icon material="close" smallest/>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</HotbarCell>
|
</HotbarCell>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@ -118,10 +113,30 @@ export class HotbarMenu extends React.Component<Props> {
|
|||||||
|
|
||||||
interface HotbarCellProps {
|
interface HotbarCellProps {
|
||||||
children?: ReactNode;
|
children?: ReactNode;
|
||||||
|
index: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
function HotbarCell(props: HotbarCellProps) {
|
function HotbarCell(props: HotbarCellProps) {
|
||||||
|
const [animating, setAnimating] = useState(false);
|
||||||
|
const onAnimationEnd = () => { setAnimating(false); };
|
||||||
|
const onClick = () => { setAnimating(true); };
|
||||||
|
const onDeleteClick = (evt: Event | React.SyntheticEvent) => {
|
||||||
|
evt.stopPropagation();
|
||||||
|
HotbarStore.getInstance().removeEmptyCell(props.index);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="HotbarCell">{props.children}</div>
|
<div
|
||||||
|
className={cssNames("HotbarCell", { animating, empty: !props.children })}
|
||||||
|
onAnimationEnd={onAnimationEnd}
|
||||||
|
onClick={onClick}
|
||||||
|
>
|
||||||
|
{props.children}
|
||||||
|
{!props.children && (
|
||||||
|
<div className="cellDeleteButton" onClick={onDeleteClick}>
|
||||||
|
<Icon material="close" smallest/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user