@loomhq/lens 10.82.0 → 10.82.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  declare const ToastWrapper: import("@emotion/styled-base").StyledComponent<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, ToastWrapperProps, object>;
3
- declare const Toast: ({ children, isOpen, onCloseClick, zIndex, duration, ...props }: ToastProps & React.ComponentProps<typeof ToastWrapper>) => JSX.Element;
3
+ declare const Toast: ({ children, isOpen, onCloseClick, zIndex, duration, }: ToastProps & React.ComponentProps<typeof ToastWrapper>) => JSX.Element;
4
4
  declare type ToastProps = {
5
5
  children?: React.ReactNode;
6
6
  isOpen?: boolean;
@@ -1,64 +1,53 @@
1
- var __rest = (this && this.__rest) || function (s, e) {
2
- var t = {};
3
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
- t[p] = s[p];
5
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
- t[p[i]] = s[p[i]];
9
- }
10
- return t;
11
- };
12
1
  import React, { useEffect } from 'react';
13
- import { getColorValue, getRadius, getShadow, u } from '../../utilities';
2
+ import { getColorValue, getShadow, u } from '../../utilities';
14
3
  import IconButton from '../icon-button/icon-button';
15
4
  import { SvgClose } from '../icon/available-icons';
16
5
  import { keyframes } from '@emotion/core';
17
6
  import styled from '@emotion/styled';
18
7
  const toastDurations = { short: 3000, long: 8000 };
19
- const enter = keyframes `
20
- from {
8
+ const enter = toastDuration => keyframes `
9
+ 0% {
21
10
  opacity: 0;
22
- transform: translateY(${u(-8)});
11
+ transform: translate(-50%, ${u(8)});
23
12
  }
24
- 10% {
13
+ // (300 / toastDuration) * 100 evaluates to 10% for short. Longer durations will have the same speed of animation
14
+ ${(300 / toastDuration) * 100}% {
25
15
  opacity: 1;
26
- transform: translateY(0);
16
+ transform: translate(-50%, 0);
27
17
  }
28
- 90% {
18
+ // 100 - (300 / toastDuration) * 100 evaluates to 90% for short. Longer durations will have the same speed of animation
19
+ ${100 - (300 / toastDuration) * 100}% {
29
20
  opacity: 1;
30
21
  }
31
- to {
22
+ 100% {
32
23
  opacity: 0;
33
24
  }
34
25
  `;
35
26
  const ToastWrapper = styled.div `
27
+ animation: ${props => enter(props.toastDuration)}
28
+ ${props => props.toastDuration}ms forwards;
29
+ background-color: ${getColorValue('background')};
30
+ border-radius: 1.75rem; // Height of single line toast (56px) divided by 2 so one line toasts appear fully rounded
31
+ bottom: ${u(4)};
32
+ ${getShadow('large')};
33
+ color: ${getColorValue('body')};
36
34
  display: grid;
37
35
  grid-auto-flow: column;
38
36
  gap: var(--lns-space-small);
39
37
  justify-content: space-between;
40
- background-color: ${getColorValue('overlay')};
41
- color: ${getColorValue('body')};
42
- ${getShadow('large')};
43
- ${getRadius('large')};
44
- width: calc(100% - var(--lns-space-medium));
38
+ left: 50%;
45
39
  min-width: ${u(35)};
46
40
  max-width: ${u(50)};
47
- position: fixed;
48
- top: ${u(9)};
49
- right: var(--lns-space-small);
50
41
  padding: ${u(1.5)} var(--lns-space-medium) ${u(1.5)} var(--lns-space-large);
42
+ position: fixed;
43
+ transform: translateX(-50%);
44
+ width: calc(100% - var(--lns-space-medium));
51
45
  z-index: ${props => props.zIndex};
52
- animation: ${enter} ${props => props.toastDuration}ms forwards;
53
- @media (min-width: 800px) {
54
- right: var(--lns-space-medium);
55
- }
56
46
  `;
57
47
  const ChildrenSection = styled.div `
58
48
  align-self: center;
59
49
  `;
60
- const Toast = (_a) => {
61
- var { children, isOpen, onCloseClick, zIndex = 1100, duration = 'short' } = _a, props = __rest(_a, ["children", "isOpen", "onCloseClick", "zIndex", "duration"]);
50
+ const Toast = ({ children, isOpen, onCloseClick, zIndex = 1100, duration = 'short', }) => {
62
51
  const toastDuration = toastDurations[duration];
63
52
  useEffect(() => {
64
53
  const timer = setTimeout(() => {
@@ -68,7 +57,7 @@ const Toast = (_a) => {
68
57
  }, toastDuration);
69
58
  return () => clearTimeout(timer);
70
59
  }, [isOpen]);
71
- return (React.createElement(React.Fragment, null, isOpen && (React.createElement(ToastWrapper, Object.assign({ "data-lens-theme": "dark", onClick: e => e.stopPropagation(), zIndex: zIndex, isOpen: isOpen, toastDuration: toastDuration }, props),
60
+ return (React.createElement(React.Fragment, null, isOpen && (React.createElement(ToastWrapper, { "data-lens-theme": "dark", onClick: e => e.stopPropagation(), zIndex: zIndex, isOpen: isOpen, toastDuration: toastDuration },
72
61
  React.createElement(ChildrenSection, { "aria-live": "polite" }, children),
73
62
  onCloseClick && (React.createElement(IconButton, { altText: "Close", icon: React.createElement(SvgClose, null), onClick: onCloseClick }))))));
74
63
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loomhq/lens",
3
- "version": "10.82.0",
3
+ "version": "10.82.1",
4
4
  "scripts": {
5
5
  "dev": "next",
6
6
  "build:next": "next build",