animations.tsx 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. import {keyframes, Theme} from '@emotion/react';
  2. export const growIn = keyframes`
  3. 0% {
  4. opacity: 0;
  5. transform: scale(0.75);
  6. }
  7. 100% {
  8. opacity: 1;
  9. transform: scale(1);
  10. }
  11. `;
  12. export const growDown = (height: string) => keyframes`
  13. 0% {
  14. height: 0;
  15. }
  16. 100% {
  17. height: ${height};
  18. }
  19. `;
  20. export const fadeIn = keyframes`
  21. 0% {
  22. opacity: 0;
  23. }
  24. 100% {
  25. opacity: 1;
  26. }
  27. `;
  28. export const fadeOut = keyframes`
  29. 0% {
  30. opacity: 1;
  31. }
  32. 100% {
  33. opacity: 0;
  34. }
  35. `;
  36. export const pulse = (size: number) => keyframes`
  37. 0% {
  38. transform: scale(1,1);
  39. }
  40. 50% {
  41. transform: scale(${size}, ${size});
  42. }
  43. 100% {
  44. transform: scale(1, 1);
  45. }
  46. `;
  47. export const expandOut = keyframes`
  48. 0% {
  49. transform: scale(1, 1);
  50. opacity: 1;
  51. }
  52. 100% {
  53. transform: scale(5, 5);
  54. opacity: 0;
  55. }
  56. `;
  57. export const slideInRight = keyframes`
  58. 0% {
  59. transform: translateX(20px);
  60. opacity: 0;
  61. }
  62. 100% {
  63. transform: translateX(0);
  64. opacity: 1;
  65. }
  66. `;
  67. export const slideInLeft = keyframes`
  68. 0% {
  69. transform: translateX(-20px);
  70. opacity: 0;
  71. }
  72. 100% {
  73. transform: translateX(0);
  74. opacity: 1;
  75. }
  76. `;
  77. export const slideInUp = keyframes`
  78. 0% {
  79. transform: translateY(10px);
  80. opacity: 0;
  81. }
  82. 100% {
  83. transform: translateY(0);
  84. opacity: 1;
  85. }
  86. `;
  87. export const highlight = (color: string) => keyframes`
  88. 0%,
  89. 100% {
  90. background: rgba(255, 255, 255, 0);
  91. }
  92. 25% {
  93. background: ${color};
  94. }
  95. `;
  96. // TODO(ts): priority should be pulled from `keyof typeof theme.alert`
  97. export const alertHighlight = (priority: string, theme: Theme) => keyframes`
  98. 0%,
  99. 100% {
  100. background: rgba(255, 255, 255, 0);
  101. border-color: transparent;
  102. }
  103. 25% {
  104. background: ${theme.alert[priority].backgroundLight};
  105. border-color: ${theme.alert[priority].border};
  106. }
  107. `;