@propellerads/header 4.5.0 → 5.1.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.
@@ -1 +0,0 @@
1
- import n,{useRef as e,useState as r,useEffect as t}from"react";import o from"prop-types";import i,{css as a,ThemeContext as u}from"styled-components";import{fontNormal as l,spacing as c,smallDevices as d,fontSmall as p,borderRadius as m,gray70 as s,white as f,gray50 as h,gray80 as g,black as v,gray95 as b,actionColor as y}from"@propellerads/stylevariables";import x from"@propellerads/currency";import C from"dayjs";import w from"dayjs/plugin/utc";import{showTooltip as k,TOOLTIP_POSITION as E,hideTooltip as H}from"@propellerads/smart-tooltip";function I(n,e,r){return e in n?Object.defineProperty(n,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):n[e]=r,n}function O(n,e){var r=Object.keys(n);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(n);e&&(t=t.filter((function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.push.apply(r,t)}return r}function j(n,e){return e||(e=n.slice(0)),Object.freeze(Object.defineProperties(n,{raw:{value:Object.freeze(e)}}))}function B(n,e){return function(n){if(Array.isArray(n))return n}(n)||function(n,e){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(n)))return;var r=[],t=!0,o=!1,i=void 0;try{for(var a,u=n[Symbol.iterator]();!(t=(a=u.next()).done)&&(r.push(a.value),!e||r.length!==e);t=!0);}catch(n){o=!0,i=n}finally{try{t||null==u.return||u.return()}finally{if(o)throw i}}return r}(n,e)||function(n,e){if(!n)return;if("string"==typeof n)return S(n,e);var r=Object.prototype.toString.call(n).slice(8,-1);"Object"===r&&n.constructor&&(r=n.constructor.name);if("Map"===r||"Set"===r)return Array.from(n);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return S(n,e)}(n,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function S(n,e){(null==e||e>n.length)&&(e=n.length);for(var r=0,t=new Array(e);r<e;r++)t[r]=n[r];return t}function P(){var n=j(["\n z-index: 99;\n padding: ","px;\n position: fixed;\n left: 0 !important;\n top: 56px;\n right: 0 !important;\n \n ",";\n\n @media (min-width: ","px) {\n width: initial;\n position: absolute;\n top: 100%;\n left: initial !important;\n }\n"]);return P=function(){return n},n}function D(){var n=j(["\n margin-left: ","px;\n"]);return D=function(){return n},n}function R(){var n=j(["\n background: transparent;\n border: 0;\n margin: 0;\n outline: none;\n font-size: ","px;\n display: flex;\n align-items: center;\n padding: 0 ","px;\n height: 100%;\n cursor: pointer;\n color: ",";\n \n &:hover {\n color: ",";\n\n & > svg{\n fill: ",";\n }\n }\n"]);return R=function(){return n},n}function T(){var n=j(["\n position: relative;\n display: flex;\n height: 100%;\n align-items: center;\n"]);return T=function(){return n},n}var q=i.div(T()),z=i.button(R(),l,4*c,(function(n){return n.theme.header.menuItemColor}),(function(n){return n.theme.header.menuItemColorHover}),(function(n){return n.theme.header.menuItemColorHover})),A=i.div(D(),c),L=i.div(P(),c,(function(n){return n.isRightDropdown&&"\n left: ".concat(n.isRightDropdown?"initial":0,";\n right: ").concat(n.isRightDropdown?0:"initial",";\n ")}),d);var M=function(o){var i=o.id,a=o.children,u=o.isRightDropdown,l=o.icon,c=o.title,d=o.onClick,p=o.component,m=e(),s=B(r(!1),2),f=s[0],h=s[1],g=c&&n.createElement(A,null,c);return function(n,e){t((function(){var r=function(r){n.current&&!n.current.contains(r.target)&&e(r)};return document.addEventListener("mousedown",r),document.addEventListener("touchstart",r),function(){document.removeEventListener("mousedown",r),document.removeEventListener("touchstart",r)}}),[n,e])}(m,(function(){return h(!1)})),n.createElement(q,{id:i,ref:m},n.createElement(z,{type:"button",onClick:function(){d&&"function"==typeof d?d():h(!f)}},l&&l,g,p&&p,a&&f&&n.createElement(L,{isRightDropdown:u,onClick:function(){return h(!1)}},a)))};function U(){var n=j(["\n position: absolute;\n left: 0;\n bottom: 0;\n right: 0;\n height: ",";\n background-color: ",";\n"]);return U=function(){return n},n}function $(){var n=j(["\n position: relative;\n flex: 0 0 7px;\n border: solid transparent;\n border-width: 0 1px;\n opacity: 0.3;\n\n &:hover {\n opacity: 1;\n "," {\n opacity: 1;\n }\n }\n"]);return $=function(){return n},n}function F(){var n=j(["\n opacity: 0;\n position: absolute;\n top: calc(-100% - 2px);\n left: 0;\n display: block;\n padding: 0 3px;\n font-size: ","px;\n line-height: 16px;\n border-radius: ","px;\n white-space: nowrap;\n pointer-events: none;\n color: ",";\n background-color: ",";\n"]);return F=function(){return n},n}function G(){var n=j(["\n margin-right: 8px;\n position: relative;\n display: flex;\n align-items: stretch;\n width: 49px;\n flex: 0 0 49px;\n height: 16px;\n cursor: default;\n\n @media (max-width: ","px) {\n display: none;\n }\n"]);return G=function(){return n},n}function J(){var n=j(["\n margin: 0 ","px;\n line-height: 1.14;\n letter-spacing: 0.3px;\n font-size: ","px;\n display: flex;\n font-weight: bold;\n color: ",";\n"]);return J=function(){return n},n}function K(){var n=j(["\n display: inline-flex;\n align-items: center;\n padding: ","px 0;\n z-index: 1;\n color: ",";\n background-color: ",";\n"]);return K=function(){return n},n}M.propTypes={id:o.string,children:o.node,onClick:o.func,component:o.element,icon:o.node,title:o.string,isRightDropdown:o.bool},M.defaultProps={id:void 0,children:void 0,onClick:void 0,component:void 0,title:void 0,icon:void 0,isRightDropdown:!1};var N=i.div(K(),2*c,(function(n){return n.theme.balance.textColor}),(function(n){return n.theme.header.backgroundColor})),Q=i.div(J(),2*c,l,(function(n){return n.theme.balance.textColor})),V=i.div(G(),d),W=i.span(F(),p,m,(function(n){return n.theme.balance.chartColor}),(function(n){return n.theme.balance.chartBackgroundColor})),X=i.div($(),W),Y=i.div(U(),(function(n){return n.percentage>1?"".concat(n.percentage,"%"):"1px"}),(function(n){return n.theme.balance.dailyEarnedColor})),Z=function(e){var r=e.day,t=r.date,o=r.value,i=r.percentage;return n.createElement(X,null,n.createElement(Y,{percentage:i}),n.createElement(W,null,t," ","-"," ",n.createElement(x,{value:o})))};Z.propTypes={day:o.shape({date:o.node,value:o.node,percentage:o.node}).isRequired};var _=function(e){var r=e.balance,t=e.dailyEarned,o=Boolean(t.length);return n.createElement(N,null,n.createElement(Q,null,n.createElement(x,{value:r,decimalPosition:2})),o&&n.createElement(V,null,t.map((function(e,r){var t=r;return n.createElement(Z,{key:t,day:e})}))))};function nn(){var n=j(["\n display: flex;\n padding: 0 ","px;\n cursor: default;\n color: ",";\n"]);return nn=function(){return n},n}_.propTypes={balance:o.number.isRequired,dailyEarned:o.arrayOf(o.shape({date:o.string.isRequired,value:o.number.isRequired,percentage:o.number.isRequired}))},_.defaultProps={dailyEarned:[]};var en=i.div(nn(),4*c,(function(n){return n.theme.header.menuItemColor}));function rn(){return C.utc().subtract(5,"hour")}C.extend(w);var tn=function(o){var i=o.tooltipContent,a=B(r(rn()),2),u=a[0],l=a[1],c=e();return c.current=function(){l(rn())},t((function(){var n=setInterval((function(){c.current()}),1e3);return function(){return clearInterval(n)}}),[]),n.createElement(en,{onMouseEnter:function(n){k(n.target,i(u),E.BOTTOM)},onMouseLeave:H},"".concat(u.format("HH:mm")," EST"))};function on(){var n=j(["\n width: 1px;\n height: 20px;\n background-color: ",";\n"]);return on=function(){return n},n}tn.propTypes={tooltipContent:o.func},tn.defaultProps={tooltipContent:function(n){return"System time: ".concat(n.format("HH:mm DD.MM")," (EST)")}};var an=i.div(on(),(function(n){return n.theme.header.dividerColor}));function un(){var n=j(["\n border-radius: ","px;\n box-shadow: 0 2px 8px 0 rgba(0, 0, 0, 0.1);\n padding: ","px 0;\n width: 100%;\n background-color: ",";\n \n @media (min-width: ","px) {\n width: auto;\n min-width: 150px;\n }\n"]);return un=function(){return n},n}var ln=i.div(un(),m,2*c,(function(n){return n.theme.header.menuItemBackgroundColor}),d),cn=function(e){var r=e.id,t=e.children;return n.createElement(ln,{id:r},t)};function dn(){var n=j(["\n height: 48px;\n padding: 0 16px;\n position: relative;\n display: flex;\n align-items: center;\n cursor: pointer;\n text-align: left;\n background-color: ",";\n color: ",";\n \n &:hover {\n background-color: ",";\n color: ",";\n }\n\n & > * {\n border: 0;\n margin: 0;\n color: inherit !important;\n position: absolute;\n left: 0;\n top: 0;\n right: 0;\n bottom: 0;\n width: 100%;\n display: flex;\n align-items: center;\n padding: 0 ","px;\n outline: none;\n font-size: inherit;\n background: transparent;\n transition: color 200ms ease-out;\n text-decoration: none;\n }\n"]);return dn=function(){return n},n}cn.propTypes={children:o.node.isRequired,id:o.string},cn.defaultProps={id:void 0};var pn=i.div(dn(),(function(n){return n.theme.header.menuItemBackgroundColor}),(function(n){return n.theme.header.menuItemColor}),(function(n){return n.theme.header.menuItemBackgroundColorHover}),(function(n){return n.theme.header.menuItemColorHover}),4*c),mn=function(e){var r=e.item;return n.createElement(pn,null,r)};mn.propTypes={item:o.shape({})},mn.defaultProps={item:{}};var sn=function(e){return e.items.map((function(e,r){return n.createElement(mn,{key:r,idx:r,item:e})}))};function fn(){var n=j(["\n display: flex;\n align-items: center;\n height: 100%;\n"]);return fn=function(){return n},n}function hn(){var n=j(["\n display: flex;\n align-items: center;\n"]);return hn=function(){return n},n}function gn(){var n=j(["\n ",",\n "]);return gn=function(){return n},n}function vn(){var n=j(["\n display: flex;\n height: 56px;\n align-items: center;\n justify-content: space-between;\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n z-index: 2001;\n background-color: ",";\n box-shadow: ",";\n\n ","\n"]);return vn=function(){return n},n}sn.propTypes={items:o.arrayOf(o.shape({}))},sn.defaultProps={items:[]};var bn=function(n){return function(n){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?O(Object(r),!0).forEach((function(e){I(n,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(r)):O(Object(r)).forEach((function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(r,e))}))}return n}({},n)},yn=i.div(vn(),(function(n){return n.theme.header.backgroundColor}),(function(n){return n.theme.header.boxShadow}),(function(n){return Boolean(Object.values(n.customHeaderStyle).length)&&a(gn(),bn(n.customHeaderStyle))})),xn=i.div(hn()),Cn=i.div(fn()),wn={dark:{name:"dark",header:{backgroundColor:"hsl(228, 16.9%, 17.5%)",color:s,colorHover:f,boxShadow:"0 2px 8px 0 hsla(0, 0%, 0%, 0.1)",dividerColor:h,menuItemColor:s,menuItemColorHover:f,menuItemBackgroundColor:"hsl(228, 16.9%, 17.5%)",menuItemBackgroundColorHover:"hsla(0, 0%, 0%, 0.3)"},balance:{borderColor:g,textColor:f,dailyEarnedColor:f,chartColor:v,chartBackgroundColor:f}},light:{name:"light",header:{backgroundColor:f,color:s,colorHover:v,boxShadow:"0 2px 8px 0 hsla(0, 0%, 0%, 0.1)",dividerColor:b,menuItemColor:s,menuItemColorHover:v,menuItemBackgroundColor:f,menuItemBackgroundColorHover:b},balance:{borderColor:g,textColor:y,dailyEarnedColor:y,chartColor:f,chartBackgroundColor:v}},transparent:{name:"transparent",header:{backgroundColor:"none",color:s,colorHover:v,dividerColor:h,menuItemColor:s,menuItemColorHover:f,menuItemBackgroundColor:"hsl(228, 16.9%, 17.5%)",menuItemBackgroundColorHover:"hsla(0, 0%, 0%, 0.3)"},balance:{borderColor:g,textColor:y,dailyEarnedColor:y,chartColor:f,chartBackgroundColor:v}}},kn=o.shape({name:o.string,header:o.shape({backgroundColor:o.string,color:o.string,colorHover:o.string,boxShadow:o.string,dividerColor:o.string,menuItemColor:o.string,menuItemColorHover:o.string,menuItemBackgroundColor:o.string,menuItemBackgroundColorHover:o.string}),balance:o.shape({borderColor:o.string,textColor:o.string,dailyEarnedColor:o.string,chartColor:o.string,chartBackgroundColor:o.string})}),En=function(e){var r=e.theme,t=e.children;return n.createElement(u.Provider,{value:r},t)};En.propTypes={children:o.node.isRequired,theme:kn},En.defaultProps={theme:wn.light};var Hn=wn,In=function(e){var r=e.logo,t=e.customHeaderStyle,o=e.sidebarButton,i=e.children,a=e.theme,u=e.id;return n.createElement(En,{theme:a},n.createElement(yn,{id:u,customHeaderStyle:t},n.createElement(xn,null,o,r),n.createElement(Cn,null,i)))};In.propTypes={logo:o.element.isRequired,customHeaderStyle:o.object,sidebarButton:o.element,children:o.node.isRequired,theme:kn,id:o.string},In.defaultProps={customHeaderStyle:{},sidebarButton:null,theme:Hn.light,id:"header-container"},In.HeaderItem=M,In.HeaderBalance=_,In.HeaderTime=tn,In.HeaderDivider=function(){return n.createElement(an,null)},In.HeaderDropdown=cn,In.HeaderDropdownList=sn;export default In;export{Hn as themes};
@@ -1,70 +0,0 @@
1
- import {
2
- actionColor, black, gray50, gray70, gray80, gray95, white,
3
- } from '@propellerads/stylevariables';
4
-
5
- const themes = {
6
- dark: {
7
- name: 'dark',
8
- header: {
9
- backgroundColor: 'hsl(228, 16.9%, 17.5%)',
10
- color: gray70,
11
- colorHover: white,
12
- boxShadow: '0 2px 8px 0 hsla(0, 0%, 0%, 0.1)',
13
- dividerColor: gray50,
14
- menuItemColor: gray70,
15
- menuItemColorHover: white,
16
- menuItemBackgroundColor: 'hsl(228, 16.9%, 17.5%)',
17
- menuItemBackgroundColorHover: 'hsla(0, 0%, 0%, 0.3)',
18
- },
19
- balance: {
20
- borderColor: gray80,
21
- textColor: white,
22
- dailyEarnedColor: white,
23
- chartColor: black,
24
- chartBackgroundColor: white,
25
- },
26
- },
27
- light: {
28
- name: 'light',
29
- header: {
30
- backgroundColor: white,
31
- color: gray70,
32
- colorHover: black,
33
- boxShadow: '0 2px 8px 0 hsla(0, 0%, 0%, 0.1)',
34
- dividerColor: gray95,
35
- menuItemColor: gray70,
36
- menuItemColorHover: black,
37
- menuItemBackgroundColor: white,
38
- menuItemBackgroundColorHover: gray95,
39
- },
40
- balance: {
41
- borderColor: gray80,
42
- textColor: actionColor,
43
- dailyEarnedColor: actionColor,
44
- chartColor: white,
45
- chartBackgroundColor: black,
46
- },
47
- },
48
- transparent: {
49
- name: 'transparent',
50
- header: {
51
- backgroundColor: 'none',
52
- color: gray70,
53
- colorHover: black,
54
- dividerColor: gray50,
55
- menuItemColor: gray70,
56
- menuItemColorHover: white,
57
- menuItemBackgroundColor: 'hsl(228, 16.9%, 17.5%)',
58
- menuItemBackgroundColorHover: 'hsla(0, 0%, 0%, 0.3)',
59
- },
60
- balance: {
61
- borderColor: gray80,
62
- textColor: actionColor,
63
- dailyEarnedColor: actionColor,
64
- chartColor: white,
65
- chartBackgroundColor: black,
66
- },
67
- },
68
- };
69
-
70
- export default themes;