-
Notifications
You must be signed in to change notification settings - Fork 821
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Emotion] Converted EuiBeacon (#5814)
* Convert EuiBeacon to emotion * Adding CL * Adding `keyframes` * adding animation only for prefers reduce motion no preference * Adding `shouldRenderCustomStyles` * Better styles for when reduce motion is turned on * Addressing PR review * Adding new snapshots * Adding comment * change euiCanAnimate to a constant * Removing `renderWithStyles()` test * Updating CL * Updating CL Co-authored-by: Greg Thompson <thompson.glowe@gmail.com>
- Loading branch information
1 parent
f21dcab
commit 3c427b1
Showing
12 changed files
with
140 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { keyframes, css } from '@emotion/react'; | ||
import { euiPaletteColorBlind } from '../../services'; | ||
import { euiCanAnimate } from '../../global_styling/variables/_animations'; | ||
|
||
const visColors = euiPaletteColorBlind(); | ||
|
||
const euiBeaconPulseLarge = keyframes` | ||
0% { | ||
transform: scale(.1); | ||
opacity: 1; | ||
} | ||
70% { | ||
transform: scale(3); | ||
opacity: 0; | ||
} | ||
100% { | ||
opacity: 0; | ||
} | ||
`; | ||
|
||
const euiBeaconPulseSmall = keyframes` | ||
0% { | ||
transform: scale(.1); | ||
opacity: 1; | ||
} | ||
70% { | ||
transform: scale(2); | ||
opacity: 0; | ||
} | ||
100% { | ||
opacity: 0; | ||
} | ||
`; | ||
|
||
export const euiBeaconStyles = () => ({ | ||
// Base | ||
euiBeacon: css` | ||
position: relative; | ||
background-color: ${visColors[0]}; | ||
border-radius: 50%; | ||
&:before, | ||
&:after { | ||
position: absolute; | ||
content: ''; | ||
height: 100%; | ||
width: 100%; | ||
inset-inline-start: 0; | ||
inset-block-start: 0; | ||
background-color: transparent; | ||
border-radius: 50%; | ||
box-shadow: 0 0 1px 1px ${visColors[0]}; | ||
} | ||
// Without the animation, we only display one ring around the circle | ||
// If the animation is allowed the transform and opacity are overriden | ||
&:before { | ||
transform: scale(1.6); | ||
opacity: 0.4; | ||
} | ||
&:after { | ||
opacity: 0; | ||
} | ||
${euiCanAnimate} { | ||
&:before { | ||
animation: ${euiBeaconPulseLarge} 2.5s infinite ease-out; | ||
} | ||
&:after { | ||
animation: ${euiBeaconPulseSmall} 2.5s infinite ease-out 0.25s; | ||
} | ||
} | ||
`, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
**CSS-in-JS conversions** | ||
|
||
- Converted `EuiBeacon` to Emotion | ||
- Changed `euiCanAnimate` to a constant |