@loomhq/lens 10.77.2 → 10.79.0
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.
- package/dist/colors.d.ts +1 -1
- package/dist/colors.js +3 -2
- package/dist/components/container/container.js +1 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/dist/components/notification-bar/notification-bar.d.ts +17 -0
- package/dist/components/notification-bar/notification-bar.js +107 -0
- package/dist/components/notification-bar/types.d.ts +1 -0
- package/dist/components/notification-bar/types.js +1 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/use-push-page-down.d.ts +6 -0
- package/dist/hooks/use-push-page-down.js +24 -0
- package/package.json +1 -1
package/dist/colors.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ declare type HslaColor = {
|
|
|
7
7
|
declare const BaseColors: readonly ["red", "blurpleLight", "blurpleMedium", "blurple", "blurpleDark", "offWhite", "blueLight", "blue", "blueDark", "orangeLight", "orange", "orangeDark", "tealLight", "teal", "tealDark", "yellowLight", "yellow", "yellowDark"];
|
|
8
8
|
declare const GreyColors: readonly ["grey8", "grey7", "grey6", "grey5", "grey4", "grey3", "grey2", "grey1", "white"];
|
|
9
9
|
declare const SharedColors: readonly ["focusRing", "record", "recordHover", "recordActive", "info", "success", "warning", "danger", "dangerHover", "dangerActive", "backdrop", "backdropDark", "disabledContent", "highlight"];
|
|
10
|
-
declare const SemanticColors: readonly ["primary", "primaryHover", "primaryActive", "body", "bodyDimmed", "background", "backgroundHover", "backgroundActive", "backgroundSecondary", "backgroundSecondary2", "overlay", "border", "disabledBackground", "formFieldBorder", "formFieldBackground", "buttonBorder", "upgrade", "upgradeHover", "upgradeActive", "tabBackground", "discoveryBackground", "discoveryLightBackground", "discoveryTitle", "discoveryHighlight"];
|
|
10
|
+
declare const SemanticColors: readonly ["primary", "primaryHover", "primaryActive", "body", "bodyDimmed", "background", "backgroundHover", "backgroundActive", "backgroundSecondary", "backgroundSecondary2", "overlay", "border", "disabledBackground", "formFieldBorder", "formFieldBackground", "buttonBorder", "upgrade", "upgradeHover", "upgradeActive", "tabBackground", "discoveryBackground", "discoveryLightBackground", "discoveryTitle", "discoveryHighlight", "internalAlert"];
|
|
11
11
|
declare type ThemesColorVariant = Record<typeof SharedColors[number] | typeof SemanticColors[number], HslaColor>;
|
|
12
12
|
declare type ThemesColors = {
|
|
13
13
|
light: ThemesColorVariant;
|
package/dist/colors.js
CHANGED
|
@@ -70,6 +70,7 @@ const SemanticColors = [
|
|
|
70
70
|
'discoveryLightBackground',
|
|
71
71
|
'discoveryTitle',
|
|
72
72
|
'discoveryHighlight',
|
|
73
|
+
'internalAlert',
|
|
73
74
|
];
|
|
74
75
|
const percent = (number, percentage) => Math.round((number * percentage) / 100);
|
|
75
76
|
export const darken = (color, percentage) => (Object.assign(Object.assign({}, color), { l: color.l - percent(color.l, percentage) }));
|
|
@@ -138,8 +139,8 @@ const themeSharedColors = {
|
|
|
138
139
|
};
|
|
139
140
|
// This object has a specific spread order for documentation purposes
|
|
140
141
|
export const themeColors = {
|
|
141
|
-
light: Object.assign(Object.assign({ primary: hslaBaseColors.blurple, primaryHover: darken(hslaBaseColors.blurple, hoverIncrease), primaryActive: darken(hslaBaseColors.blurple, activeIncrease), body: hslaGreys.grey8, bodyDimmed: hslaGreys.grey6, background: hslaGreys.white, backgroundHover: alpha(hslaGreys.grey7, 0.1), backgroundActive: alpha(hslaGreys.grey7, 0.3), backgroundSecondary: alpha(hslaGreys.grey7, 0.04), backgroundSecondary2: { h: 45, s: 34, l: 78, a: 0.2 }, overlay: hslaGreys.white, border: alpha(hslaGreys.grey6, borderAlpha) }, themeSharedColors), { disabledBackground: hslaGreys.grey2, formFieldBorder: hslaGreys.grey3, formFieldBackground: hslaGreys.white, buttonBorder: alpha(hslaGreys.grey6, buttonBorderAlpha), upgrade: { h: 206, s: 100, l: 93, a: 1 }, upgradeHover: darken({ h: 206, s: 100, l: 93, a: 1 }, 9), upgradeActive: darken({ h: 206, s: 100, l: 93, a: 1 }, 17), tabBackground: alpha(hslaGreys.grey6, tabBackgroundAlpha), discoveryBackground: { h: 206, s: 100, l: 93, a: 1 }, discoveryLightBackground: { h: 206, s: 100, l: 97, a: 1 }, discoveryTitle: hslaGreys.grey8, discoveryHighlight: { h: 206, s: 100, l: 77, a: 0.3 } }),
|
|
142
|
-
dark: Object.assign(Object.assign({ primary: { h: 242, s: 87, l: 73, a: 1 }, primaryHover: darken(hslaBaseColors.blurple, hoverIncrease), primaryActive: darken(hslaBaseColors.blurple, activeIncrease), body: hslaGreys.grey1, bodyDimmed: hslaGreys.grey5, background: hslaGreys.grey8, backgroundHover: alpha(hslaGreys.white, 0.1), backgroundActive: alpha(hslaGreys.white, 0.2), backgroundSecondary: alpha(hslaGreys.white, 0.04), backgroundSecondary2: { h: 45, s: 13, l: 44, a: 0.2 }, overlay: lighten(hslaGreys.grey8, 50), border: alpha(hslaGreys.grey4, borderAlpha) }, themeSharedColors), { disabledBackground: darken(hslaGreys.grey6, 50), formFieldBorder: hslaGreys.grey6, formFieldBackground: hslaGreys.grey8, buttonBorder: alpha(hslaGreys.white, buttonBorderAlpha), upgrade: { h: 206, s: 92, l: 81, a: 1 }, upgradeHover: darken({ h: 206, s: 92, l: 81, a: 1 }, 9), upgradeActive: darken({ h: 206, s: 92, l: 81, a: 1 }, 17), tabBackground: alpha(hslaGreys.white, tabBackgroundAlpha), discoveryBackground: { h: 206, s: 92, l: 81, a: 1 }, discoveryLightBackground: hslaGreys.grey8, discoveryTitle: hslaBaseColors.blue, discoveryHighlight: { h: 206, s: 100, l: 77, a: 0.3 } }),
|
|
142
|
+
light: Object.assign(Object.assign({ primary: hslaBaseColors.blurple, primaryHover: darken(hslaBaseColors.blurple, hoverIncrease), primaryActive: darken(hslaBaseColors.blurple, activeIncrease), body: hslaGreys.grey8, bodyDimmed: hslaGreys.grey6, background: hslaGreys.white, backgroundHover: alpha(hslaGreys.grey7, 0.1), backgroundActive: alpha(hslaGreys.grey7, 0.3), backgroundSecondary: alpha(hslaGreys.grey7, 0.04), backgroundSecondary2: { h: 45, s: 34, l: 78, a: 0.2 }, overlay: hslaGreys.white, border: alpha(hslaGreys.grey6, borderAlpha) }, themeSharedColors), { disabledBackground: hslaGreys.grey2, formFieldBorder: hslaGreys.grey3, formFieldBackground: hslaGreys.white, buttonBorder: alpha(hslaGreys.grey6, buttonBorderAlpha), upgrade: { h: 206, s: 100, l: 93, a: 1 }, upgradeHover: darken({ h: 206, s: 100, l: 93, a: 1 }, 9), upgradeActive: darken({ h: 206, s: 100, l: 93, a: 1 }, 17), tabBackground: alpha(hslaGreys.grey6, tabBackgroundAlpha), discoveryBackground: { h: 206, s: 100, l: 93, a: 1 }, discoveryLightBackground: { h: 206, s: 100, l: 97, a: 1 }, discoveryTitle: hslaGreys.grey8, discoveryHighlight: { h: 206, s: 100, l: 77, a: 0.3 }, internalAlert: { h: 134, s: 29, l: 36, a: 1 } }),
|
|
143
|
+
dark: Object.assign(Object.assign({ primary: { h: 242, s: 87, l: 73, a: 1 }, primaryHover: darken(hslaBaseColors.blurple, hoverIncrease), primaryActive: darken(hslaBaseColors.blurple, activeIncrease), body: hslaGreys.grey1, bodyDimmed: hslaGreys.grey5, background: hslaGreys.grey8, backgroundHover: alpha(hslaGreys.white, 0.1), backgroundActive: alpha(hslaGreys.white, 0.2), backgroundSecondary: alpha(hslaGreys.white, 0.04), backgroundSecondary2: { h: 45, s: 13, l: 44, a: 0.2 }, overlay: lighten(hslaGreys.grey8, 50), border: alpha(hslaGreys.grey4, borderAlpha) }, themeSharedColors), { disabledBackground: darken(hslaGreys.grey6, 50), formFieldBorder: hslaGreys.grey6, formFieldBackground: hslaGreys.grey8, buttonBorder: alpha(hslaGreys.white, buttonBorderAlpha), upgrade: { h: 206, s: 92, l: 81, a: 1 }, upgradeHover: darken({ h: 206, s: 92, l: 81, a: 1 }, 9), upgradeActive: darken({ h: 206, s: 92, l: 81, a: 1 }, 17), tabBackground: alpha(hslaGreys.white, tabBackgroundAlpha), discoveryBackground: { h: 206, s: 92, l: 81, a: 1 }, discoveryLightBackground: hslaGreys.grey8, discoveryTitle: hslaBaseColors.blue, discoveryHighlight: { h: 206, s: 100, l: 77, a: 0.3 }, internalAlert: { h: 132, s: 32, l: 67, a: 1 } }),
|
|
143
144
|
};
|
|
144
145
|
export const hslaColors = Object.assign(Object.assign({}, hslaBaseColors), hslaGreys);
|
|
145
146
|
export const colorsNames = [
|
|
@@ -17,6 +17,7 @@ export { default as Link } from "./link/link";
|
|
|
17
17
|
export { default as Textarea } from "./textarea/textarea";
|
|
18
18
|
export { default as Dropdown } from "./dropdown/dropdown";
|
|
19
19
|
export { default as FormField } from "./form-field/form-field";
|
|
20
|
+
export { default as NotificationBar } from "./notification-bar/notification-bar";
|
|
20
21
|
export { default as Toast } from "./toast/toast";
|
|
21
22
|
export { default as Switch } from "./switch/switch";
|
|
22
23
|
export { default as Logo } from "./logo/logo";
|
package/dist/components/index.js
CHANGED
|
@@ -23,6 +23,7 @@ export { default as Link } from './link/link';
|
|
|
23
23
|
export { default as Textarea } from './textarea/textarea';
|
|
24
24
|
export { default as Dropdown } from './dropdown/dropdown';
|
|
25
25
|
export { default as FormField } from './form-field/form-field';
|
|
26
|
+
export { default as NotificationBar } from './notification-bar/notification-bar';
|
|
26
27
|
export { default as Toast } from './toast/toast';
|
|
27
28
|
export { default as Tooltip } from './tooltip/tooltip';
|
|
28
29
|
export { TooltipBox } from './tooltip/tooltip';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SeverityLevels } from './types';
|
|
3
|
+
declare const NotificationBarOuterWrapper: import("@emotion/styled-base").StyledComponent<React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>, NotificationBarWrapperProps, object>;
|
|
4
|
+
declare const NotificationBar: ({ children, onCloseClick, isOpen, severity, ...props }: NotificationBarProps & React.ComponentProps<typeof NotificationBarOuterWrapper>) => JSX.Element;
|
|
5
|
+
declare type NotificationBarProps = {
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
isOpen?: boolean;
|
|
8
|
+
onCloseClick: () => void;
|
|
9
|
+
severity: SeverityLevels;
|
|
10
|
+
};
|
|
11
|
+
declare type NotificationBarWrapperProps = {
|
|
12
|
+
children?: React.ReactNode;
|
|
13
|
+
isOpen?: boolean;
|
|
14
|
+
severity: SeverityLevels;
|
|
15
|
+
button: React.ReactNode;
|
|
16
|
+
};
|
|
17
|
+
export default NotificationBar;
|
|
@@ -0,0 +1,107 @@
|
|
|
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
|
+
import React, { useEffect } from 'react';
|
|
13
|
+
import styled from '@emotion/styled';
|
|
14
|
+
import { SvgClose, SvgAlertTriangle, SvgInfo, SvgWarningAlert, } from '../icon/available-icons';
|
|
15
|
+
import Align from '../align/align';
|
|
16
|
+
import Arrange from '../arrange/arrange';
|
|
17
|
+
import Container from '../container/container';
|
|
18
|
+
import Icon from '../icon/icon';
|
|
19
|
+
import IconButton from '../icon-button/icon-button';
|
|
20
|
+
import { usePushPageDown } from '../../hooks';
|
|
21
|
+
const severityStyles = {
|
|
22
|
+
info: {
|
|
23
|
+
bgColor: 'var(--lns-color-blurple)',
|
|
24
|
+
icon: React.createElement(SvgInfo, null),
|
|
25
|
+
color: 'var(--lns-color-white)',
|
|
26
|
+
fontFamily: 'inherit',
|
|
27
|
+
},
|
|
28
|
+
warning: {
|
|
29
|
+
bgColor: 'var(--lns-color-warning)',
|
|
30
|
+
icon: React.createElement(SvgWarningAlert, null),
|
|
31
|
+
color: 'var(--lns-color-grey8)',
|
|
32
|
+
fontFamily: 'inherit',
|
|
33
|
+
},
|
|
34
|
+
error: {
|
|
35
|
+
bgColor: 'var(--lns-color-danger)',
|
|
36
|
+
icon: React.createElement(SvgAlertTriangle, null),
|
|
37
|
+
color: 'var(--lns-color-white)',
|
|
38
|
+
fontFamily: 'inherit',
|
|
39
|
+
},
|
|
40
|
+
internal: {
|
|
41
|
+
icon: React.createElement("span", { role: "img" }, "\uD83D\uDD14"),
|
|
42
|
+
color: 'var(--lns-color-teal)',
|
|
43
|
+
bgColor: 'var(--lns-color-grey8)',
|
|
44
|
+
fontFamily: 'Roboto Mono, Lucida Mono, monospace',
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
const DURATION = 350;
|
|
48
|
+
const NotificationBarOuterWrapper = styled.aside `
|
|
49
|
+
display: grid;
|
|
50
|
+
align-content: center;
|
|
51
|
+
${props => `background-color: ${severityStyles[props.severity].bgColor}`};
|
|
52
|
+
${props => `font-family: ${severityStyles[props.severity].fontFamily}`};
|
|
53
|
+
|
|
54
|
+
${props => `color: ${severityStyles[props.severity].color}`};
|
|
55
|
+
position: fixed;
|
|
56
|
+
padding: var(--lns-space-medium) 0;
|
|
57
|
+
top: 0;
|
|
58
|
+
left: 0;
|
|
59
|
+
transition: ${DURATION}ms box-shadow, ${DURATION}ms transform;
|
|
60
|
+
width: 100vw;
|
|
61
|
+
z-index: 1100;
|
|
62
|
+
opacity: ${props => (props.isOpen ? '1' : '0')};
|
|
63
|
+
transform: ${props => props.isOpen ? 'translateY(0px)' : 'translateY(-100%)'};
|
|
64
|
+
`;
|
|
65
|
+
const NotificationBarInnerWrapper = styled.div `
|
|
66
|
+
--responsive-padding: var(--lns-space-small);
|
|
67
|
+
margin: 0 auto;
|
|
68
|
+
max-width: 1600px;
|
|
69
|
+
padding-left: var(--responsive-padding);
|
|
70
|
+
padding-right: var(--responsive-padding);
|
|
71
|
+
width: calc(100% - (2 * var(--responsive-padding)));
|
|
72
|
+
@media (min-width: 800px) {
|
|
73
|
+
--responsive-padding: var(--lns-space-medium);
|
|
74
|
+
}
|
|
75
|
+
`;
|
|
76
|
+
const NotificationBar = (_a) => {
|
|
77
|
+
var _b, _c, _d;
|
|
78
|
+
var { children, onCloseClick, isOpen, severity = 'info' } = _a, props = __rest(_a, ["children", "onCloseClick", "isOpen", "severity"]);
|
|
79
|
+
useEffect(() => {
|
|
80
|
+
if (!isOpen) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const keyListener = (e) => {
|
|
84
|
+
if (e.key === 'Escape') {
|
|
85
|
+
e.preventDefault();
|
|
86
|
+
onCloseClick();
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
window.addEventListener('keydown', keyListener);
|
|
90
|
+
return () => {
|
|
91
|
+
window.removeEventListener('keydown', keyListener);
|
|
92
|
+
};
|
|
93
|
+
}, [isOpen, onCloseClick]);
|
|
94
|
+
usePushPageDown(isOpen);
|
|
95
|
+
return isOpen ? (React.createElement(NotificationBarOuterWrapper, Object.assign({ isOpen: isOpen, severity: severity }, props),
|
|
96
|
+
React.createElement(NotificationBarInnerWrapper, null,
|
|
97
|
+
React.createElement(Arrange, { alignItems: { default: 'start', small: 'center' }, justifyContent: "space-between", columns: ['1fr auto'] },
|
|
98
|
+
React.createElement(Container, { paddingY: { default: 'xsmall', xsmall: 0 }, width: "100%" },
|
|
99
|
+
React.createElement(Arrange, { autoFlow: "column", gap: "small", justifyContent: "center" },
|
|
100
|
+
((_b = severityStyles[severity]) === null || _b === void 0 ? void 0 : _b.icon) ? (React.createElement(Align, { alignment: "topLeft" },
|
|
101
|
+
React.createElement(Icon, { icon: severityStyles[severity].icon, color: (_c = severityStyles[severity].color) !== null && _c !== void 0 ? _c : 'var(--lns-color-white)' }))) : null,
|
|
102
|
+
' ',
|
|
103
|
+
children),
|
|
104
|
+
props.button),
|
|
105
|
+
React.createElement(IconButton, { iconColor: (_d = severityStyles[severity].color) !== null && _d !== void 0 ? _d : 'var(--lns-color-white)', tabIndex: 0, altText: "Close", icon: React.createElement(SvgClose, null), onClick: onCloseClick }))))) : null;
|
|
106
|
+
};
|
|
107
|
+
export default NotificationBar;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare type SeverityLevels = 'warning' | 'info' | 'error' | 'internal';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -2,3 +2,4 @@ export { default as useMedia } from "./use-media.js";
|
|
|
2
2
|
export { default as useOnClickOutside } from "./use-on-click-outside.js";
|
|
3
3
|
export { default as useFocusedElement } from "./use-focused-element";
|
|
4
4
|
export { default as usePreventScroll } from "./use-prevent-scroll";
|
|
5
|
+
export { default as usePushPageDown } from "./use-push-page-down";
|
package/dist/hooks/index.js
CHANGED
|
@@ -2,3 +2,4 @@ export { default as useMedia } from './use-media.js';
|
|
|
2
2
|
export { default as useOnClickOutside } from './use-on-click-outside.js';
|
|
3
3
|
export { default as useFocusedElement } from './use-focused-element';
|
|
4
4
|
export { default as usePreventScroll } from './use-prevent-scroll';
|
|
5
|
+
export { default as usePushPageDown } from './use-push-page-down';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { useLayoutEffect } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Usage:
|
|
4
|
+
* usePreventScroll(<boolean-condition>);
|
|
5
|
+
**/
|
|
6
|
+
function usePushPageDown(enabled) {
|
|
7
|
+
const safeDocument = document;
|
|
8
|
+
useLayoutEffect(() => {
|
|
9
|
+
const html = safeDocument === null || safeDocument === void 0 ? void 0 : safeDocument.documentElement;
|
|
10
|
+
const body = safeDocument === null || safeDocument === void 0 ? void 0 : safeDocument.body;
|
|
11
|
+
if (safeDocument == undefined || !html || !body) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
if (enabled) {
|
|
15
|
+
body.style.setProperty('padding-top', '3.25rem');
|
|
16
|
+
body.style.setProperty('transition', 'padding-top 350ms');
|
|
17
|
+
/* [1] */
|
|
18
|
+
}
|
|
19
|
+
return () => {
|
|
20
|
+
body.style.removeProperty('padding-top');
|
|
21
|
+
};
|
|
22
|
+
}, [safeDocument, enabled]);
|
|
23
|
+
}
|
|
24
|
+
export default usePushPageDown;
|