common.jsx 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. // @flow
  2. // Copyright 2017 The go-ethereum Authors
  3. // This file is part of the go-ethereum library.
  4. //
  5. // The go-ethereum library is free software: you can redistribute it and/or modify
  6. // it under the terms of the GNU Lesser General Public License as published by
  7. // the Free Software Foundation, either version 3 of the License, or
  8. // (at your option) any later version.
  9. //
  10. // The go-ethereum library is distributed in the hope that it will be useful,
  11. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. // GNU Lesser General Public License for more details.
  14. //
  15. // You should have received a copy of the GNU Lesser General Public License
  16. // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
  17. import {faHome, faLink, faGlobeEurope, faTachometerAlt, faList} from '@fortawesome/free-solid-svg-icons';
  18. import {faCreditCard} from '@fortawesome/free-regular-svg-icons';
  19. type ProvidedMenuProp = {|title: string, icon: string|};
  20. const menuSkeletons: Array<{|id: string, menu: ProvidedMenuProp|}> = [
  21. {
  22. id: 'home',
  23. menu: {
  24. title: 'Home',
  25. icon: faHome,
  26. },
  27. }, {
  28. id: 'chain',
  29. menu: {
  30. title: 'Chain',
  31. icon: faLink,
  32. },
  33. }, {
  34. id: 'txpool',
  35. menu: {
  36. title: 'TxPool',
  37. icon: faCreditCard,
  38. },
  39. }, {
  40. id: 'network',
  41. menu: {
  42. title: 'Network',
  43. icon: faGlobeEurope,
  44. },
  45. }, {
  46. id: 'system',
  47. menu: {
  48. title: 'System',
  49. icon: faTachometerAlt,
  50. },
  51. }, {
  52. id: 'logs',
  53. menu: {
  54. title: 'Logs',
  55. icon: faList,
  56. },
  57. },
  58. ];
  59. export type MenuProp = {|...ProvidedMenuProp, id: string|};
  60. // The sidebar menu and the main content are rendered based on these elements.
  61. // Using the id is circumstantial in some cases, so it is better to insert it also as a value.
  62. // This way the mistyping is prevented.
  63. export const MENU: Map<string, {...MenuProp}> = new Map(menuSkeletons.map(({id, menu}) => ([id, {id, ...menu}])));
  64. export const DURATION = 200;
  65. export const chartStrokeWidth = 0.2;
  66. export const styles = {
  67. light: {
  68. color: 'rgba(255, 255, 255, 0.54)',
  69. },
  70. };
  71. // unit contains the units for the bytePlotter.
  72. export const unit = ['', 'Ki', 'Mi', 'Gi', 'Ti', 'Pi', 'Ei', 'Zi', 'Yi'];
  73. // simplifyBytes returns the simplified version of the given value followed by the unit.
  74. export const simplifyBytes = (x: number) => {
  75. let i = 0;
  76. for (; x > 1024 && i < 8; i++) {
  77. x /= 1024;
  78. }
  79. return x.toFixed(2).toString().concat(' ', unit[i], 'B');
  80. };
  81. // hues contains predefined colors for gradient stop colors.
  82. export const hues = ['#00FF00', '#FFFF00', '#FF7F00', '#FF0000'];
  83. export const hueScale = [0, 2048, 102400, 2097152];