@startlibs/components 1.0.4 → 1.1.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.
- package/lib/BasicBulletList.mjs +9 -0
- package/lib/BasicBulletList.mjs.map +1 -0
- package/lib/Button.mjs +95 -0
- package/lib/Button.mjs.map +1 -0
- package/lib/ContextMenu.mjs +452 -0
- package/lib/ContextMenu.mjs.map +1 -0
- package/lib/Dialog.mjs +232 -0
- package/lib/Dialog.mjs.map +1 -0
- package/lib/Draggable.mjs +880 -0
- package/lib/Draggable.mjs.map +1 -0
- package/lib/ErrorBoundary.mjs +108 -0
- package/lib/ErrorBoundary.mjs.map +1 -0
- package/lib/FillLastLineResizer.mjs +238 -0
- package/lib/FillLastLineResizer.mjs.map +1 -0
- package/lib/Flip.mjs +604 -0
- package/lib/Flip.mjs.map +1 -0
- package/lib/FlipList.mjs +186 -0
- package/lib/FlipList.mjs.map +1 -0
- package/lib/FormatDate.mjs +25 -0
- package/lib/FormatDate.mjs.map +1 -0
- package/lib/Icon.mjs +50 -0
- package/lib/Icon.mjs.map +1 -0
- package/lib/Image.mjs +41 -0
- package/lib/Image.mjs.map +1 -0
- package/lib/Link.mjs +116 -0
- package/lib/Link.mjs.map +1 -0
- package/lib/Loading.mjs +10 -0
- package/lib/Loading.mjs.map +1 -0
- package/lib/LoadingDiv.mjs +83 -0
- package/lib/LoadingDiv.mjs.map +1 -0
- package/lib/Notifications.mjs +63 -0
- package/lib/Notifications.mjs.map +1 -0
- package/lib/PageLoader.mjs +42 -0
- package/lib/PageLoader.mjs.map +1 -0
- package/lib/PersistentNotifications.mjs +130 -0
- package/lib/PersistentNotifications.mjs.map +1 -0
- package/lib/Popup.mjs +49 -0
- package/lib/Popup.mjs.map +1 -0
- package/lib/SplitColumnsContainer.mjs +43 -0
- package/lib/SplitColumnsContainer.mjs.map +1 -0
- package/lib/SwitchDiv.mjs +61 -0
- package/lib/SwitchDiv.mjs.map +1 -0
- package/lib/TextButton.mjs +41 -0
- package/lib/TextButton.mjs.map +1 -0
- package/lib/ToastNotifications.mjs +215 -0
- package/lib/ToastNotifications.mjs.map +1 -0
- package/lib/Tooltip.mjs +160 -0
- package/lib/Tooltip.mjs.map +1 -0
- package/lib/TransitionDiv.mjs +56 -0
- package/lib/TransitionDiv.mjs.map +1 -0
- package/lib/WarningDialog.mjs +84 -0
- package/lib/WarningDialog.mjs.map +1 -0
- package/lib/alt/buttons/OnClickLoadingButton.mjs +36 -0
- package/lib/alt/buttons/OnClickLoadingButton.mjs.map +1 -0
- package/lib/alt/dialogs/DialogWithImageHeader.mjs +14 -0
- package/lib/alt/dialogs/DialogWithImageHeader.mjs.map +1 -0
- package/lib/alt/dialogs/DialogWithSidebar.mjs +106 -0
- package/lib/alt/dialogs/DialogWithSidebar.mjs.map +1 -0
- package/lib/alt/dialogs/MobileBubbleDialog.mjs +49 -0
- package/lib/alt/dialogs/MobileBubbleDialog.mjs.map +1 -0
- package/lib/containers/DialogContainer.mjs +413 -0
- package/lib/containers/DialogContainer.mjs.map +1 -0
- package/lib/containers/Reposition.mjs +35 -0
- package/lib/containers/Reposition.mjs.map +1 -0
- package/lib/containers/usePositioning.mjs +294 -0
- package/lib/containers/usePositioning.mjs.map +1 -0
- package/lib/index.cjs +5000 -0
- package/lib/index.cjs.map +1 -0
- package/lib/index.mjs +37 -0
- package/lib/index.mjs.map +1 -0
- package/lib/useDialogWithToggle.mjs +18 -0
- package/lib/useDialogWithToggle.mjs.map +1 -0
- package/lib/willUseIsSticky.mjs +123 -0
- package/lib/willUseIsSticky.mjs.map +1 -0
- package/package.json +47 -30
- package/src/BasicBulletList.jsx +21 -0
- package/src/Button.jsx +288 -0
- package/src/ContextMenu.jsx +621 -0
- package/src/Dialog.jsx +413 -0
- package/src/Draggable.jsx +801 -0
- package/src/ErrorBoundary.jsx +75 -0
- package/src/FillLastLineResizer.jsx +226 -0
- package/src/Flip.jsx +560 -0
- package/src/FlipList.jsx +136 -0
- package/src/FormatDate.jsx +9 -0
- package/src/Icon.jsx +49 -0
- package/src/Image.jsx +23 -0
- package/src/Link.jsx +68 -0
- package/src/Loading.jsx +29 -0
- package/src/LoadingDiv.jsx +75 -0
- package/src/Notifications.jsx +89 -0
- package/src/PageLoader.jsx +48 -0
- package/src/PersistentNotifications.jsx +182 -0
- package/src/Popup.jsx +49 -0
- package/src/SplitColumnsContainer.jsx +63 -0
- package/src/SwitchDiv.jsx +30 -0
- package/src/TextButton.jsx +34 -0
- package/src/ToastNotifications.jsx +298 -0
- package/src/Tooltip.jsx +158 -0
- package/src/TransitionDiv.jsx +34 -0
- package/src/WarningDialog.jsx +70 -0
- package/src/alt/buttons/OnClickLoadingButton.jsx +16 -0
- package/src/alt/dialogs/DialogWithImageHeader.jsx +42 -0
- package/src/alt/dialogs/DialogWithSidebar.jsx +135 -0
- package/src/alt/dialogs/MobileBubbleDialog.jsx +56 -0
- package/src/containers/DialogContainer.jsx +423 -0
- package/src/containers/Reposition.jsx +24 -0
- package/src/containers/usePositioning.jsx +305 -0
- package/src/index.js +35 -0
- package/src/useDialogWithToggle.jsx +12 -0
- package/src/willUseIsSticky.jsx +113 -0
- package/.babelrc +0 -27
- package/lib/index.js +0 -5429
- package/rollup.config.js +0 -52
- package/yarn-error.log +0 -3724
package/lib/index.mjs
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export { Icon } from './Icon.mjs';
|
|
2
|
+
export { Loading } from './Loading.mjs';
|
|
3
|
+
export { Button, DropdownIcon } from './Button.mjs';
|
|
4
|
+
export { OnClickLoadingButton } from './alt/buttons/OnClickLoadingButton.mjs';
|
|
5
|
+
export { TextButton } from './TextButton.mjs';
|
|
6
|
+
export { LoadingDiv } from './LoadingDiv.mjs';
|
|
7
|
+
export { CloseIcon, ConfirmDialog, DefaultConfirmDialog, Dialog, DialogContent, DialogContentWrapper, DialogError, DialogErrorContent, DialogFooter, DialogIcon, DialogTitle, FooterAuxiliaryContainer } from './Dialog.mjs';
|
|
8
|
+
export { useDialog, useDialogWithToggle } from './useDialogWithToggle.mjs';
|
|
9
|
+
export { DefaultWarningDialog, WarningDialog, WarningDialogIcon, WarningDialogTitle, setWarningDialog, useWarningDialog } from './WarningDialog.mjs';
|
|
10
|
+
export { Notifications, setNotification, useNotification, useNotificationRef, willSetNotification } from './Notifications.mjs';
|
|
11
|
+
export { ToastNotifications, createToastNotification, useToastNotificationToggle, useToastNotifications, willShowToastNotification } from './ToastNotifications.mjs';
|
|
12
|
+
export { PersistentNotification, PersistentNotificationActions, PersistentNotificationCloseIcon, PersistentNotificationContent, PersistentNotificationIcon, PersistentNotifications, hidePersistentNotifications, openPersistentNotification, useIsHiddenPersistentNotifications } from './PersistentNotifications.mjs';
|
|
13
|
+
export { DefaultArrow, addPositioningBound, usePositioning } from './containers/usePositioning.mjs';
|
|
14
|
+
export { Reposition } from './containers/Reposition.mjs';
|
|
15
|
+
export { AnimatedModal, DialogContainer, Modal, ModalContainer, dialogFadeInDown, dialogModalIn, dialogModalOut, getDialogLayersSize, isFakeScrolled, preventDialogPop, removeWindowScroll, useDialogLayers, waitForPop } from './containers/DialogContainer.mjs';
|
|
16
|
+
export { DraggableContainer, DraggableItem, DroppableContainer } from './Draggable.mjs';
|
|
17
|
+
export { Popup } from './Popup.mjs';
|
|
18
|
+
export { Tooltip } from './Tooltip.mjs';
|
|
19
|
+
export { SplitColumnsContainer, fixDoubledLastMarginBottom } from './SplitColumnsContainer.mjs';
|
|
20
|
+
export { ContextListMenu, ContextMenu, ContextMenuComponent, Li, ListHeading, ListItem, ListMenu, ListSeparator, SimpleLi, StickyContainer, contextMenuLayersQuantity } from './ContextMenu.mjs';
|
|
21
|
+
export { ErrorBoundary } from './ErrorBoundary.mjs';
|
|
22
|
+
export { LoadingBar, PageLoader, SuspenseLoadingBar } from './PageLoader.mjs';
|
|
23
|
+
export { FillLastLineResizer } from './FillLastLineResizer.mjs';
|
|
24
|
+
export { defaultAnimationMaker, formatAnimation, getClientRectAnimation, morph, toPosition, useFlip, useFlipAnimation, useFlipEnter, useFlipLeave, willUseFlip, willUseFlipSwitch } from './Flip.mjs';
|
|
25
|
+
export { FlipList } from './FlipList.mjs';
|
|
26
|
+
export { AnimationBlockContainer, TransitionDiv } from './TransitionDiv.mjs';
|
|
27
|
+
export { SwitchDiv } from './SwitchDiv.mjs';
|
|
28
|
+
export { willUseIsSticky } from './willUseIsSticky.mjs';
|
|
29
|
+
export { FormatDate } from './FormatDate.mjs';
|
|
30
|
+
export { Image } from './Image.mjs';
|
|
31
|
+
export { DialogWithImageHeader } from './alt/dialogs/DialogWithImageHeader.mjs';
|
|
32
|
+
export { DialogTabMenu, DialogWithSidebar, DialogWithSidebarPresentation, MENU_TAB, SideMenu } from './alt/dialogs/DialogWithSidebar.mjs';
|
|
33
|
+
export { MobileBubbleDialog } from './alt/dialogs/MobileBubbleDialog.mjs';
|
|
34
|
+
export { HistoryLink, Link, Navigate, Route, Router, Routes, useAbsoluteLocation, useAbsolutePath, useLocation, useNavigate, useParams, useSearchParams } from './Link.mjs';
|
|
35
|
+
export { BasicBulletList } from './BasicBulletList.mjs';
|
|
36
|
+
export { useBrowserLocation } from 'wouter/use-browser-location';
|
|
37
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { useToggle, useFill } from '@startlibs/core';
|
|
2
|
+
|
|
3
|
+
const useDialog = function (dialog) {
|
|
4
|
+
let args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
5
|
+
let toggleCallback = arguments.length > 2 ? arguments[2] : undefined;
|
|
6
|
+
const toggle = useToggle(false, toggleCallback);
|
|
7
|
+
useFill("Dialog", toggle.isOpen !== false && dialog(toggle.close), [toggle.isOpen, ...args]);
|
|
8
|
+
return toggle.open;
|
|
9
|
+
};
|
|
10
|
+
const useDialogWithToggle = function (dialog) {
|
|
11
|
+
let args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
12
|
+
const toggle = useToggle();
|
|
13
|
+
useFill("Dialog", toggle.isOpen !== false && dialog(toggle), [toggle.isOpen, ...args]);
|
|
14
|
+
return toggle;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export { useDialog, useDialogWithToggle };
|
|
18
|
+
//# sourceMappingURL=useDialogWithToggle.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDialogWithToggle.mjs","sources":["../src/useDialogWithToggle.jsx"],"sourcesContent":["import {useToggle,useFill} from '@startlibs/core'\n\nexport const useDialog = (dialog, args = [], toggleCallback) => {\n const toggle = useToggle(false,toggleCallback)\n useFill(\"Dialog\", toggle.isOpen !== false && dialog(toggle.close), [toggle.isOpen, ...args])\n return toggle.open\n}\nexport const useDialogWithToggle = (dialog, args = []) => {\n const toggle = useToggle()\n useFill(\"Dialog\", toggle.isOpen !== false && dialog(toggle), [toggle.isOpen, ...args])\n return toggle\n}"],"names":["useDialog","dialog","args","arguments","length","undefined","toggleCallback","toggle","useToggle","useFill","isOpen","close","open","useDialogWithToggle"],"mappings":";;MAEaA,SAAS,GAAG,UAACC,MAAM,EAAgC;AAAA,EAAA,IAA9BC,IAAI,GAAAC,SAAA,CAAAC,MAAA,GAAA,CAAA,IAAAD,SAAA,CAAA,CAAA,CAAA,KAAAE,SAAA,GAAAF,SAAA,CAAA,CAAA,CAAA,GAAG,EAAE,CAAA;EAAA,IAAEG,cAAc,GAAAH,SAAA,CAAAC,MAAA,GAAAD,CAAAA,GAAAA,SAAA,MAAAE,SAAA,CAAA;AACzD,EAAA,MAAME,MAAM,GAAGC,SAAS,CAAC,KAAK,EAACF,cAAc,CAAC,CAAA;EAC9CG,OAAO,CAAC,QAAQ,EAAEF,MAAM,CAACG,MAAM,KAAK,KAAK,IAAIT,MAAM,CAACM,MAAM,CAACI,KAAK,CAAC,EAAE,CAACJ,MAAM,CAACG,MAAM,EAAE,GAAGR,IAAI,CAAC,CAAC,CAAA;EAC5F,OAAOK,MAAM,CAACK,IAAI,CAAA;AACpB,EAAC;MACYC,mBAAmB,GAAG,UAACZ,MAAM,EAAgB;AAAA,EAAA,IAAdC,IAAI,GAAAC,SAAA,CAAAC,MAAA,GAAA,CAAA,IAAAD,SAAA,CAAA,CAAA,CAAA,KAAAE,SAAA,GAAAF,SAAA,CAAA,CAAA,CAAA,GAAG,EAAE,CAAA;AACnD,EAAA,MAAMI,MAAM,GAAGC,SAAS,EAAE,CAAA;EAC1BC,OAAO,CAAC,QAAQ,EAAEF,MAAM,CAACG,MAAM,KAAK,KAAK,IAAIT,MAAM,CAACM,MAAM,CAAC,EAAE,CAACA,MAAM,CAACG,MAAM,EAAE,GAAGR,IAAI,CAAC,CAAC,CAAA;AACtF,EAAA,OAAOK,MAAM,CAAA;AACf;;;;"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
|
+
import _without from 'lodash/fp/without';
|
|
3
|
+
import _identity from 'lodash/fp/identity';
|
|
4
|
+
import React, { useState, useEffect } from 'react';
|
|
5
|
+
import { willUseSharedCallback, willUseSharedState, useEnsureRef } from '@startlibs/core';
|
|
6
|
+
import styled from 'styled-components';
|
|
7
|
+
import { callIfFunction } from '@startlibs/utils';
|
|
8
|
+
|
|
9
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
10
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
11
|
+
const TOP_TRIGGER = (posInfo, refInfo) => {
|
|
12
|
+
// Started sticking.
|
|
13
|
+
if (posInfo.bottom < refInfo.top) {
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
// Stopped sticking.
|
|
17
|
+
if (posInfo.bottom >= refInfo.top && posInfo.bottom < refInfo.bottom) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
const BOTTOM_TRIGGER = (posInfo, refInfo) => {
|
|
22
|
+
// Started sticking.
|
|
23
|
+
if (posInfo.top > refInfo.bottom) {
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
if (posInfo.top <= refInfo.bottom && posInfo.top > refInfo.top) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
const SentinelStyle = /*#__PURE__*/styled.div.withConfig({
|
|
31
|
+
displayName: "willUseIsSticky__SentinelStyle",
|
|
32
|
+
componentId: "sc-1nsyca-0"
|
|
33
|
+
})(["position:absolute;visibility:hidden;height:1px;width:1px;", ""], props => props.addCss);
|
|
34
|
+
const willUseIsSticky = function () {
|
|
35
|
+
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
36
|
+
const [useRegister, onChange] = willUseSharedCallback();
|
|
37
|
+
const [useSharedIsSticky,, setSharedIsSticky] = willUseSharedState();
|
|
38
|
+
const createObserver = root => window.IntersectionObserver ? new window.IntersectionObserver((records, observer) => {
|
|
39
|
+
for (const record of records) {
|
|
40
|
+
const targetInfo = record.boundingClientRect;
|
|
41
|
+
const rootBoundsInfo = record.rootBounds;
|
|
42
|
+
if (!rootBoundsInfo) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
onChange(targetInfo, rootBoundsInfo, record.target, record.isIntersecting);
|
|
46
|
+
}
|
|
47
|
+
}, _objectSpread({
|
|
48
|
+
root
|
|
49
|
+
}, options)) : {
|
|
50
|
+
observe: _identity,
|
|
51
|
+
unobserve: _identity
|
|
52
|
+
};
|
|
53
|
+
const observerMap = new Map();
|
|
54
|
+
const getObserver = function () {
|
|
55
|
+
let root = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
56
|
+
const result = observerMap.get(root);
|
|
57
|
+
if (result) {
|
|
58
|
+
return result;
|
|
59
|
+
}
|
|
60
|
+
const observer = createObserver(root);
|
|
61
|
+
observerMap.set(root, observer);
|
|
62
|
+
return observer;
|
|
63
|
+
};
|
|
64
|
+
let activeObserved = [];
|
|
65
|
+
const resetObservers = function () {
|
|
66
|
+
let root = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
67
|
+
const observer = getObserver(root);
|
|
68
|
+
activeObserved.forEach(observed => {
|
|
69
|
+
observer.unobserve(observed);
|
|
70
|
+
observer.observe(observed);
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
const WithIsSticky = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
74
|
+
let {
|
|
75
|
+
className,
|
|
76
|
+
id,
|
|
77
|
+
css,
|
|
78
|
+
children,
|
|
79
|
+
bottom,
|
|
80
|
+
root,
|
|
81
|
+
intersection,
|
|
82
|
+
onChange
|
|
83
|
+
} = _ref;
|
|
84
|
+
const ensuredRef = useEnsureRef(ref);
|
|
85
|
+
const [isSticky, setIsSticky] = useState(false);
|
|
86
|
+
useRegister((posInfo, refInfo, target, isIntersecting) => {
|
|
87
|
+
if (ensuredRef.current === target) {
|
|
88
|
+
const value = intersection ? isIntersecting : bottom ? BOTTOM_TRIGGER(posInfo, refInfo) : TOP_TRIGGER(posInfo, refInfo);
|
|
89
|
+
if (value !== undefined) {
|
|
90
|
+
setIsSticky(value);
|
|
91
|
+
callIfFunction(onChange, value);
|
|
92
|
+
if (!id) {
|
|
93
|
+
setSharedIsSticky(value);
|
|
94
|
+
} else if (value) {
|
|
95
|
+
setSharedIsSticky(id);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
useEffect(() => {
|
|
101
|
+
setIsSticky(false);
|
|
102
|
+
getObserver(callIfFunction(root)).observe(ensuredRef.current);
|
|
103
|
+
activeObserved = activeObserved.concat(ensuredRef.current);
|
|
104
|
+
return () => {
|
|
105
|
+
// observer.unobserve(ref.current)
|
|
106
|
+
activeObserved = _without([ensuredRef.current], activeObserved);
|
|
107
|
+
};
|
|
108
|
+
}, []);
|
|
109
|
+
const renderSentinel = function () {
|
|
110
|
+
let css = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
|
|
111
|
+
return /*#__PURE__*/React.createElement(SentinelStyle, {
|
|
112
|
+
addCss: css,
|
|
113
|
+
className: className,
|
|
114
|
+
ref: ensuredRef
|
|
115
|
+
});
|
|
116
|
+
};
|
|
117
|
+
return children ? children(renderSentinel, isSticky) : renderSentinel(css);
|
|
118
|
+
});
|
|
119
|
+
return [WithIsSticky, useSharedIsSticky, resetObservers];
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
export { willUseIsSticky };
|
|
123
|
+
//# sourceMappingURL=willUseIsSticky.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"willUseIsSticky.mjs","sources":["../src/willUseIsSticky.jsx"],"sourcesContent":["import React, {useEffect, useState} from 'react'\nimport {useEnsureRef, willUseSharedState, willUseSharedCallback} from '@startlibs/core'\nimport styled from 'styled-components'\nimport _ from 'lodash/fp'\nimport {callIfFunction} from '@startlibs/utils'\n\n\nconst TOP_TRIGGER = (posInfo,refInfo) => {\n // Started sticking.\n if (posInfo.bottom < refInfo.top) {\n return true\n }\n // Stopped sticking.\n if (posInfo.bottom >= refInfo.top &&\n posInfo.bottom < refInfo.bottom) {\n return false\n }\n}\nconst BOTTOM_TRIGGER = (posInfo,refInfo) => {\n // Started sticking.\n if (posInfo.top > refInfo.bottom) {\n return true\n }\n if (posInfo.top <= refInfo.bottom &&\n posInfo.top > refInfo.top) {\n return false\n }\n}\n\nconst SentinelStyle = styled.div`\n position:absolute;\n visibility: hidden;\n height:1px;\n width: 1px;\n ${props => props.addCss}\n`\n\nexport const willUseIsSticky = (options = {}) => {\n\n const [useRegister, onChange] = willUseSharedCallback()\n const [useSharedIsSticky,, setSharedIsSticky] = willUseSharedState()\n\n const createObserver = (root) => window.IntersectionObserver ? new window.IntersectionObserver((records, observer) => {\n for (const record of records) {\n const targetInfo = record.boundingClientRect\n const rootBoundsInfo = record.rootBounds\n if (!rootBoundsInfo) {\n return\n }\n onChange(targetInfo,rootBoundsInfo, record.target, record.isIntersecting)\n }\n },{root,...options}) : {observe:_.identity,unobserve:_.identity}\n\n const observerMap = new Map()\n const getObserver = (root = null) => {\n const result = observerMap.get(root)\n if (result) {\n return result\n }\n const observer = createObserver(root)\n observerMap.set(root,observer)\n return observer\n }\n \n let activeObserved = []\n const resetObservers = (root = null) => {\n const observer = getObserver(root)\n activeObserved.forEach((observed) => {\n observer.unobserve(observed)\n observer.observe(observed)\n })\n }\n\n const WithIsSticky = React.forwardRef(({className, id, css, children,bottom, root, intersection,onChange},ref) => {\n const ensuredRef = useEnsureRef(ref)\n const [isSticky,setIsSticky] = useState(false)\n\n useRegister((posInfo,refInfo,target, isIntersecting) => {\n if (ensuredRef.current === target) {\n const value = intersection ? isIntersecting : (bottom ? BOTTOM_TRIGGER(posInfo,refInfo) : TOP_TRIGGER(posInfo,refInfo))\n if (value!==undefined) {\n setIsSticky(value)\n callIfFunction(onChange,value)\n if (!id) {\n setSharedIsSticky(value)\n } else if (value) {\n setSharedIsSticky(id)\n }\n }\n }\n })\n\n useEffect(() => {\n setIsSticky(false)\n getObserver(callIfFunction(root)).observe(ensuredRef.current)\n activeObserved = activeObserved.concat(ensuredRef.current)\n return () => {\n // observer.unobserve(ref.current)\n activeObserved = _.without([ensuredRef.current],activeObserved)\n }\n },[])\n\n const renderSentinel = (css = \"\") => <SentinelStyle addCss={css} className={className} ref={ensuredRef} />\n\n return children\n ? children(renderSentinel,isSticky)\n : renderSentinel(css)\n\n })\n\n\n return [WithIsSticky, useSharedIsSticky, resetObservers]\n}"],"names":["TOP_TRIGGER","posInfo","refInfo","bottom","top","BOTTOM_TRIGGER","SentinelStyle","styled","div","withConfig","displayName","componentId","props","addCss","willUseIsSticky","options","arguments","length","undefined","useRegister","onChange","willUseSharedCallback","useSharedIsSticky","setSharedIsSticky","willUseSharedState","createObserver","root","window","IntersectionObserver","records","observer","record","targetInfo","boundingClientRect","rootBoundsInfo","rootBounds","target","isIntersecting","_objectSpread","observe","_identity","unobserve","observerMap","Map","getObserver","result","get","set","activeObserved","resetObservers","forEach","observed","WithIsSticky","React","forwardRef","_ref","ref","className","id","css","children","intersection","ensuredRef","useEnsureRef","isSticky","setIsSticky","useState","current","value","callIfFunction","useEffect","concat","_without","renderSentinel","createElement"],"mappings":";;;;;;;;;;AAOA,MAAMA,WAAW,GAAGA,CAACC,OAAO,EAACC,OAAO,KAAK;AACvC;AACA,EAAA,IAAID,OAAO,CAACE,MAAM,GAAGD,OAAO,CAACE,GAAG,EAAE;AAChC,IAAA,OAAO,IAAI,CAAA;AACb,GAAA;AACA;AACA,EAAA,IAAIH,OAAO,CAACE,MAAM,IAAID,OAAO,CAACE,GAAG,IAC/BH,OAAO,CAACE,MAAM,GAAGD,OAAO,CAACC,MAAM,EAAE;AACjC,IAAA,OAAO,KAAK,CAAA;AACd,GAAA;AACF,CAAC,CAAA;AACD,MAAME,cAAc,GAAGA,CAACJ,OAAO,EAACC,OAAO,KAAK;AAC1C;AACA,EAAA,IAAID,OAAO,CAACG,GAAG,GAAGF,OAAO,CAACC,MAAM,EAAE;AAChC,IAAA,OAAO,IAAI,CAAA;AACb,GAAA;AACA,EAAA,IAAIF,OAAO,CAACG,GAAG,IAAIF,OAAO,CAACC,MAAM,IACjCF,OAAO,CAACG,GAAG,GAAGF,OAAO,CAACE,GAAG,E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AACX;QACAnB,cAAc,GAAGwB,QAAA,CAAU,CAACV,UAAU,CAACK,OAAO,CAAC,EAACnB,cAAc,CAAC,CAAA;OAChE,CAAA;KACF,EAAC,EAAE,CAAC,CAAA;IAEL,MAAMyB,cAAc,GAAG,YAAA;AAAA,MAAA,IAACd,GAAG,GAAA3C,SAAA,CAAAC,MAAA,GAAA,CAAA,IAAAD,SAAA,CAAA,CAAA,CAAA,KAAAE,SAAA,GAAAF,SAAA,CAAA,CAAA,CAAA,GAAG,EAAE,CAAA;AAAA,MAAA,oBAAKqC,KAAA,CAAAqB,aAAA,CAACpE,aAAa,EAAA;AAACO,QAAAA,MAAM,EAAE8C,GAAI;AAACF,QAAAA,SAAS,EAAEA,SAAU;AAACD,QAAAA,GAAG,EAAEM,UAAAA;AAAW,OAAE,CAAC,CAAA;AAAA,KAAA,CAAA;AAE1G,IAAA,OAAOF,QAAQ,GACXA,QAAQ,CAACa,cAAc,EAACT,QAAQ,CAAC,GACjCS,cAAc,CAACd,GAAG,CAAC,CAAA;AAEzB,GAAC,CAAC,CAAA;AAGF,EAAA,OAAO,CAACP,YAAY,EAAE9B,iBAAiB,EAAE2B,cAAc,CAAC,CAAA;AAC1D;;;;"}
|
package/package.json
CHANGED
|
@@ -1,51 +1,57 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@startlibs/components",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "Startlibs Components",
|
|
5
|
-
"main": "lib/index.
|
|
5
|
+
"main": "lib/index.cjs",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"source": "./src/index.js",
|
|
9
|
+
"require": "./lib/index.cjs",
|
|
10
|
+
"import": "./lib/index.mjs",
|
|
11
|
+
"default": "./lib/index.mjs"
|
|
12
|
+
},
|
|
13
|
+
"./package.json": "./package.json",
|
|
14
|
+
"./*": {
|
|
15
|
+
"import": "./lib/*.mjs"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
6
18
|
"sideEffects": false,
|
|
7
|
-
"source":
|
|
19
|
+
"source": "./src/index.js",
|
|
8
20
|
"peerDependencies": {
|
|
9
|
-
"@
|
|
21
|
+
"@startlibs/core": "*",
|
|
10
22
|
"@startlibs/utils": "*",
|
|
11
|
-
"lodash": "
|
|
12
|
-
"
|
|
13
|
-
"react": "
|
|
14
|
-
"react-dom": "
|
|
15
|
-
"react-is": "
|
|
16
|
-
"styled-components": "
|
|
23
|
+
"lodash": "^4.17.21",
|
|
24
|
+
"polished": "^2.0.0 || ^3.0.0 || ^4.0.0",
|
|
25
|
+
"react": ">=16.8",
|
|
26
|
+
"react-dom": ">=16.8",
|
|
27
|
+
"react-is": "^16.13.1 || ^17.0.0 || ^18.0.0 || ^19.0.0",
|
|
28
|
+
"styled-components": ">=5",
|
|
17
29
|
"wouter": "*"
|
|
18
30
|
},
|
|
19
31
|
"devDependencies": {
|
|
20
32
|
"@babel/core": "^7.2.0",
|
|
21
|
-
"@babel/plugin-external-helpers": "^7.2.0",
|
|
22
|
-
"@babel/plugin-proposal-class-properties": "^7.2.1",
|
|
23
|
-
"@babel/plugin-proposal-export-namespace-from": "^7.2.0",
|
|
24
|
-
"@babel/plugin-proposal-json-strings": "^7.2.0",
|
|
25
|
-
"@babel/plugin-proposal-object-rest-spread": "^7.2.0",
|
|
26
|
-
"@babel/plugin-proposal-optional-chaining": "^7.11.0",
|
|
27
|
-
"@babel/plugin-proposal-throw-expressions": "^7.2.0",
|
|
28
|
-
"@babel/plugin-syntax-dynamic-import": "^7.2.0",
|
|
29
|
-
"@babel/plugin-syntax-import-meta": "^7.2.0",
|
|
30
33
|
"@babel/plugin-transform-runtime": "^7.2.0",
|
|
31
|
-
"@babel/plugin-transform-spread": "^7.2.0",
|
|
32
34
|
"@babel/preset-env": "^7.2.0",
|
|
33
35
|
"@babel/preset-flow": "^7.0.0",
|
|
34
36
|
"@babel/preset-react": "^7.0.0",
|
|
35
37
|
"babel-plugin-lodash": "^3.3.4",
|
|
36
38
|
"babel-plugin-macros": "^2.4.2",
|
|
37
39
|
"babel-plugin-styled-components": "^1.10.0",
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
40
|
+
"lodash": "^4.17.21",
|
|
41
|
+
"patch-package": "^8.0.1",
|
|
42
|
+
"polished": "^2.0.0 || ^3.0.0 || ^4.0.0",
|
|
43
|
+
"react-is": "^16.13.1 || ^17.0.0 || ^18.0.0 || ^19.0.0",
|
|
44
|
+
"rollup": "^2.79.2",
|
|
41
45
|
"rollup-plugin-auto-external": "^2.0.0",
|
|
42
46
|
"rollup-plugin-babel": "^4.0.3",
|
|
43
47
|
"rollup-plugin-commonjs": "^9.2.0",
|
|
44
|
-
"rollup-plugin-node-resolve": "^5.2.0"
|
|
48
|
+
"rollup-plugin-node-resolve": "^5.2.0",
|
|
49
|
+
"styled-components": "^5.3.11"
|
|
45
50
|
},
|
|
46
51
|
"scripts": {
|
|
47
52
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
48
|
-
"build": "rollup -c"
|
|
53
|
+
"build": "rollup -c",
|
|
54
|
+
"prepare": "patch-package"
|
|
49
55
|
},
|
|
50
56
|
"repository": {
|
|
51
57
|
"type": "git",
|
|
@@ -62,9 +68,20 @@
|
|
|
62
68
|
},
|
|
63
69
|
"homepage": "https://github.com/felipeko/startlibs#readme",
|
|
64
70
|
"dependencies": {
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
71
|
+
"@babel/runtime": "^7.20.0",
|
|
72
|
+
"mitt": "^1.1.2"
|
|
73
|
+
},
|
|
74
|
+
"files": [
|
|
75
|
+
"lib",
|
|
76
|
+
"src"
|
|
77
|
+
],
|
|
78
|
+
"module": "lib/index.mjs",
|
|
79
|
+
"browserslist": [
|
|
80
|
+
"chrome >= 61",
|
|
81
|
+
"edge >= 79",
|
|
82
|
+
"firefox >= 60",
|
|
83
|
+
"safari >= 11",
|
|
84
|
+
"ios_saf >= 11",
|
|
85
|
+
"samsung >= 8.2"
|
|
86
|
+
]
|
|
70
87
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import styled from 'styled-components'
|
|
2
|
+
|
|
3
|
+
export const BasicBulletList = styled.ul`
|
|
4
|
+
margin-bottom: 0;
|
|
5
|
+
font-size: 13px;
|
|
6
|
+
|
|
7
|
+
li {
|
|
8
|
+
margin-top: 4px;
|
|
9
|
+
padding-left: 1rem;
|
|
10
|
+
position: relative;
|
|
11
|
+
|
|
12
|
+
:before {
|
|
13
|
+
content: '•';
|
|
14
|
+
font-size: 17px;
|
|
15
|
+
line-height: 0;
|
|
16
|
+
position: absolute;
|
|
17
|
+
left: 0;
|
|
18
|
+
top: 7px;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
`
|
package/src/Button.jsx
ADDED
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
|
|
3
|
+
import {customTheme, getColor, media, styledExtend} from '@startlibs/utils'
|
|
4
|
+
import {darken, transparentize} from 'polished'
|
|
5
|
+
import styled, {css} from 'styled-components'
|
|
6
|
+
|
|
7
|
+
import {Icon} from './Icon'
|
|
8
|
+
import {Link} from './Link'
|
|
9
|
+
import {Loading} from './Loading'
|
|
10
|
+
|
|
11
|
+
export const DropdownIcon = styledExtend(Icon)`
|
|
12
|
+
position: absolute;
|
|
13
|
+
top: 51%;
|
|
14
|
+
transform: translateY(-50%);
|
|
15
|
+
right: 1rem;
|
|
16
|
+
font-size: 12px;
|
|
17
|
+
`
|
|
18
|
+
const LockIcon = styled(Icon)`
|
|
19
|
+
position:absolute;
|
|
20
|
+
bottom: 10px;
|
|
21
|
+
right: .75rem;
|
|
22
|
+
left: auto;
|
|
23
|
+
top: auto;
|
|
24
|
+
font-size: 18px;
|
|
25
|
+
`
|
|
26
|
+
|
|
27
|
+
const focus = css`
|
|
28
|
+
:after{
|
|
29
|
+
content: '';
|
|
30
|
+
pointer-events: none;
|
|
31
|
+
position: absolute;
|
|
32
|
+
top: -3px;
|
|
33
|
+
right: -3px;
|
|
34
|
+
left: -3px;
|
|
35
|
+
bottom: -3px;
|
|
36
|
+
border-radius: ${props => props.rounded ? '100px' : '11px'};
|
|
37
|
+
border: 2px solid rgba(0, 0, 0, 0.15);
|
|
38
|
+
}
|
|
39
|
+
`
|
|
40
|
+
|
|
41
|
+
export const Button = styled(React.forwardRef(({
|
|
42
|
+
type = "button", locked, color, alpha, success, alert, warning, highlight, light, hover, white, icon, onlyIcon, small, withDropdown, onlyDropdown, outline, dashed, textOnly, isLoading, isLoadingIcon, dark,
|
|
43
|
+
innerAs: Wrapper = 'button', className, children, rounded, tabIndex = 1, focused, noFocus,
|
|
44
|
+
colorSet, concealed, concealedModule, buttonRef, ...props
|
|
45
|
+
},ref) =>
|
|
46
|
+
<Wrapper ref={ref || buttonRef} tabIndex={tabIndex} className={className + ' styled-button' + ((color || success || alert || warning || highlight || dark || hover || outline || dashed || textOnly || white || alpha || props.lightAlert || props.lightWarning) ? ' styled-button-colored' : '')} type={Wrapper === 'button' ? type : ''} {...props}>
|
|
47
|
+
{icon && <Icon icon={icon} aria-hidden="true"/>}
|
|
48
|
+
{isLoadingIcon && <Loading white={!light && !outline && !dashed && !white} size={small ? '10' : '18'} borderWidth={small ? '2' : '3'}/>}
|
|
49
|
+
{(withDropdown || onlyDropdown) && !locked && <DropdownIcon icon='arrow-down' aria-hidden="true"/>}
|
|
50
|
+
{locked && <LockIcon icon="lock" aria-hidden="true"/>}
|
|
51
|
+
{children}
|
|
52
|
+
{isLoading && <Loading white={!light && !outline && !dashed && !white} absolute size={small && '16'} borderWidth={small && '3'} />}
|
|
53
|
+
</Wrapper>))`
|
|
54
|
+
vertical-align: top;
|
|
55
|
+
border: 0;
|
|
56
|
+
font-size: 13px;
|
|
57
|
+
border-radius: ${props => props.rounded ? '100px' : '8px'};
|
|
58
|
+
background: ${getColor};
|
|
59
|
+
color: white;
|
|
60
|
+
min-width: 8rem;
|
|
61
|
+
font-weight: 600;
|
|
62
|
+
display: inline-block;
|
|
63
|
+
// line-height: 16px;
|
|
64
|
+
text-align: center;
|
|
65
|
+
padding: 10px 1.25rem;
|
|
66
|
+
outline: none;
|
|
67
|
+
cursor: pointer;
|
|
68
|
+
position: relative;
|
|
69
|
+
text-decoration: none;
|
|
70
|
+
user-select: none;
|
|
71
|
+
flex-shrink: 0;
|
|
72
|
+
:hover {
|
|
73
|
+
background: ${props => darken(0.05, getColor(props, true))};
|
|
74
|
+
}
|
|
75
|
+
:active {
|
|
76
|
+
background: ${props => darken(0.08, getColor(props, true))};
|
|
77
|
+
}
|
|
78
|
+
${props => props.nowrap && `
|
|
79
|
+
white-space: nowrap;
|
|
80
|
+
`}
|
|
81
|
+
${props => !props.noFocus && !props.isLoading && css`
|
|
82
|
+
:focus {
|
|
83
|
+
${focus}
|
|
84
|
+
}
|
|
85
|
+
${props => props.focused && focus}
|
|
86
|
+
`}
|
|
87
|
+
& + & {
|
|
88
|
+
margin-left: 1rem;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
${props => props.hasErrors && css`
|
|
92
|
+
:after {
|
|
93
|
+
content: '';
|
|
94
|
+
pointer-events: none;
|
|
95
|
+
position: absolute;
|
|
96
|
+
top: -4px;
|
|
97
|
+
right: -4px;
|
|
98
|
+
left: -4px;
|
|
99
|
+
bottom: -4px;
|
|
100
|
+
border-radius: ${props => props.rounded ? '100px' : '11px'};
|
|
101
|
+
border: 3px solid ${props => transparentize(0.7, getColor("alert")(props))};
|
|
102
|
+
}
|
|
103
|
+
`}
|
|
104
|
+
${props => props.icon && css`
|
|
105
|
+
display: inline-flex;
|
|
106
|
+
align-items: center;
|
|
107
|
+
justify-content: center;
|
|
108
|
+
min-width: 3rem;
|
|
109
|
+
min-height: 3rem;
|
|
110
|
+
${Icon} {
|
|
111
|
+
font-size: 23px;
|
|
112
|
+
margin-left: -4px;
|
|
113
|
+
margin-right: 8px;
|
|
114
|
+
pointer-events: none;
|
|
115
|
+
line-height: 0;
|
|
116
|
+
}
|
|
117
|
+
`}
|
|
118
|
+
${props => props.onlyIcon && css`
|
|
119
|
+
padding: 0;
|
|
120
|
+
${Icon} {
|
|
121
|
+
margin: 0;
|
|
122
|
+
}
|
|
123
|
+
`}
|
|
124
|
+
${props => props.small && css`
|
|
125
|
+
font-size: 13px;
|
|
126
|
+
padding: 3px 1rem;
|
|
127
|
+
min-width: 2rem;
|
|
128
|
+
min-height: 2rem;
|
|
129
|
+
font-weight: 550;
|
|
130
|
+
${props.icon && css`
|
|
131
|
+
${Icon} {
|
|
132
|
+
font-size: 18px;
|
|
133
|
+
margin-left: -5px;
|
|
134
|
+
margin-right: 5px;
|
|
135
|
+
line-height: 0.9;
|
|
136
|
+
}
|
|
137
|
+
`}
|
|
138
|
+
${props.onlyIcon && css`
|
|
139
|
+
padding: 0;
|
|
140
|
+
${Icon} {
|
|
141
|
+
margin: 0;
|
|
142
|
+
}
|
|
143
|
+
`}
|
|
144
|
+
`}
|
|
145
|
+
${props => props.big && css`
|
|
146
|
+
font-size: 14px;
|
|
147
|
+
padding: 13px 1.75rem;
|
|
148
|
+
min-height: 42px;
|
|
149
|
+
`}
|
|
150
|
+
${props => props.withDropdown && css`
|
|
151
|
+
padding-right: 2.25rem;
|
|
152
|
+
text-align: left;
|
|
153
|
+
`}
|
|
154
|
+
${props => props.onlyDropdown && css`
|
|
155
|
+
${DropdownIcon} {
|
|
156
|
+
right: 50%;
|
|
157
|
+
transform: translate(50%,-50%);
|
|
158
|
+
}
|
|
159
|
+
`}
|
|
160
|
+
${props => props.light && css`
|
|
161
|
+
background: ${getColor('bluishGray')};
|
|
162
|
+
color: ${getColor('gray90')};
|
|
163
|
+
:hover {
|
|
164
|
+
background: ${props => darken(0.05, getColor('bluishGray')(props))};
|
|
165
|
+
}
|
|
166
|
+
:active {
|
|
167
|
+
background: ${props => darken(0.08, getColor('bluishGray')(props))};
|
|
168
|
+
}
|
|
169
|
+
`}
|
|
170
|
+
${props => props.lightAlert && css`
|
|
171
|
+
background: ${props => transparentize(0.86, getColor("alert")(props))};
|
|
172
|
+
color: ${getColor('alert')};
|
|
173
|
+
:hover {
|
|
174
|
+
background: ${props => transparentize(0.83, getColor("alert")(props))};
|
|
175
|
+
}
|
|
176
|
+
:active {
|
|
177
|
+
background: ${props => transparentize(0.80, getColor("alert")(props))};
|
|
178
|
+
}
|
|
179
|
+
`}
|
|
180
|
+
${props => props.lightWarning && css`
|
|
181
|
+
background: ${props => transparentize(0.84, darken(0.05, getColor('warning')(props)))};
|
|
182
|
+
color: ${props => darken(0.05, getColor('warning')(props))};
|
|
183
|
+
:hover {
|
|
184
|
+
background: ${props => transparentize(0.78, darken(0.05, getColor('warning')(props)))};
|
|
185
|
+
}
|
|
186
|
+
:active {
|
|
187
|
+
background: ${props => transparentize(0.76, darken(0.05, getColor('warning')(props)))};
|
|
188
|
+
}
|
|
189
|
+
`}
|
|
190
|
+
${props => (props.outline || props.dashed || props.textOnly) && css`
|
|
191
|
+
color: ${props.white ? 'white' : props.highlight ? getColor('main') : 'rgba(0,0,0,0.6)'};
|
|
192
|
+
background: none;
|
|
193
|
+
${Icon}, ${DropdownIcon} {
|
|
194
|
+
color: ${props.white ? 'white' : props.highlight ? getColor('main') : 'rgba(0,0,0,0.5)'};
|
|
195
|
+
}
|
|
196
|
+
:before {
|
|
197
|
+
content: '';
|
|
198
|
+
border: 1px ${props.outline ? 'solid' : props.dashed ? 'dashed' : ''} ${props.white ? 'white' : props.highlight ? getColor('main') : 'rgba(0,0,0,0.35)'};
|
|
199
|
+
position: absolute;
|
|
200
|
+
top: 0;
|
|
201
|
+
right: 0;
|
|
202
|
+
bottom: 0;
|
|
203
|
+
left: 0;
|
|
204
|
+
border-radius: ${props.rounded ? '100px' : '8px'};
|
|
205
|
+
pointer-events: none;
|
|
206
|
+
}
|
|
207
|
+
:hover {
|
|
208
|
+
background-color: rgba(0,0,0,0.05);
|
|
209
|
+
}
|
|
210
|
+
:active {
|
|
211
|
+
background-color: rgba(0,0,0,0.08);
|
|
212
|
+
}
|
|
213
|
+
:focus {
|
|
214
|
+
:before {
|
|
215
|
+
box-shadow: 0 0 0 2px rgba(0,0,0,0.1);
|
|
216
|
+
${props.textOnly && 'content: none;'}
|
|
217
|
+
}
|
|
218
|
+
:after {
|
|
219
|
+
content: none;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
`}
|
|
223
|
+
${props => props.alpha && css`
|
|
224
|
+
background: rgba(0,0,0,0.45);
|
|
225
|
+
:hover {
|
|
226
|
+
background: rgba(0,0,0,0.50);
|
|
227
|
+
}
|
|
228
|
+
:active {
|
|
229
|
+
background: rgba(0,0,0,0.55);
|
|
230
|
+
}
|
|
231
|
+
`}
|
|
232
|
+
${props => props.white && !props.outline && !props.dashed && css`
|
|
233
|
+
color: ${getColor('main')};
|
|
234
|
+
background: #FFFFFF;
|
|
235
|
+
:hover {
|
|
236
|
+
background: ${darken(0.05, '#FFFFFF')};
|
|
237
|
+
}
|
|
238
|
+
:active {
|
|
239
|
+
background: ${darken(0.08, '#FFFFFF')};
|
|
240
|
+
}
|
|
241
|
+
`}
|
|
242
|
+
${props => props.isLoading && css`
|
|
243
|
+
color: transparent !important;
|
|
244
|
+
pointer-events: none;
|
|
245
|
+
${Icon} {
|
|
246
|
+
visibility: hidden;
|
|
247
|
+
}
|
|
248
|
+
`}
|
|
249
|
+
${props => props.isLoadingIcon && css`
|
|
250
|
+
pointer-events: none;
|
|
251
|
+
${Icon} {
|
|
252
|
+
visibility: hidden;
|
|
253
|
+
}
|
|
254
|
+
${Loading} {
|
|
255
|
+
left: 10px;
|
|
256
|
+
position: absolute;
|
|
257
|
+
}
|
|
258
|
+
`}
|
|
259
|
+
${media.mobile`
|
|
260
|
+
${props => !props.small && !props.onlyIcon && css`
|
|
261
|
+
padding: 13px 1.5rem;
|
|
262
|
+
font-size: 14px;
|
|
263
|
+
`}
|
|
264
|
+
${props => !props.small && props.onlyIcon && css`
|
|
265
|
+
min-width: 3.5rem;
|
|
266
|
+
min-height: 3.5rem;
|
|
267
|
+
`}
|
|
268
|
+
${props => props.withDropdown && css`
|
|
269
|
+
padding-right: 2.5rem;
|
|
270
|
+
${DropdownIcon} {
|
|
271
|
+
right: 14px;
|
|
272
|
+
}
|
|
273
|
+
`}
|
|
274
|
+
`}
|
|
275
|
+
${media.max(359)`
|
|
276
|
+
${props => !props.small && !props.onlyIcon && !props.onlyDropdown && css`
|
|
277
|
+
min-width: 0;
|
|
278
|
+
`}
|
|
279
|
+
`}
|
|
280
|
+
${props => props.fullwidth && `
|
|
281
|
+
width: 100%;
|
|
282
|
+
`}
|
|
283
|
+
${customTheme("Button")}
|
|
284
|
+
`
|
|
285
|
+
|
|
286
|
+
Button.a = (props) => <Button {...props} className={props.className} innerAs="a"/>
|
|
287
|
+
Button.Link = (props) => <Button {...props} className={props.className} innerAs={Link}/>
|
|
288
|
+
export default Button
|