Generic.tsx 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*
  2. Copyright (C) 2017 Cloudbase Solutions SRL
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU Affero General Public License as
  5. published by the Free Software Foundation, either version 3 of the
  6. License, or (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU Affero General Public License for more details.
  11. You should have received a copy of the GNU Affero General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. import React from 'react'
  15. import styled from 'styled-components'
  16. import { ThemePalette, ThemeProps } from '@src/components/Theme'
  17. import generic64Image from './generic-64.svg'
  18. import generic128Image from './generic-128.svg'
  19. import generic128DisabledImage from './generic-128-disabled.svg'
  20. const Wrapper = styled.div<any>`
  21. text-align: center;
  22. max-height: 100%;
  23. overflow: hidden;
  24. display: flex;
  25. justify-content: center;
  26. align-items: center;
  27. letter-spacing: -1px;
  28. `
  29. const Logo = styled.div<any>`
  30. ${(props: any) => ThemeProps.exactWidth(`${props.width}px`)}
  31. ${(props: any) => ThemeProps.exactHeight(`${props.height}px`)}
  32. background: url(${(props: any) => props.image}) center no-repeat;
  33. `
  34. type Props = {
  35. name: string,
  36. size: { w: number, h: number },
  37. disabled: boolean | null | undefined,
  38. white: boolean | null | undefined,
  39. }
  40. class Generic extends React.Component<Props> {
  41. render32Generic(white: boolean | null | undefined) {
  42. return (
  43. <Wrapper style={{
  44. fontSize: '14px',
  45. color: white ? 'white' : ThemePalette.grayscale[4],
  46. }}
  47. >
  48. {this.props.name}
  49. </Wrapper>
  50. )
  51. }
  52. render42Generic() {
  53. return (
  54. <Wrapper style={{
  55. fontSize: '18px',
  56. color: ThemePalette.grayscale[4],
  57. }}
  58. >
  59. {this.props.name}
  60. </Wrapper>
  61. )
  62. }
  63. render64Generic() {
  64. return (
  65. <Wrapper style={{
  66. fontSize: '22px',
  67. color: ThemePalette.black,
  68. textAlign: 'left',
  69. }}
  70. >
  71. <Logo width={49} height={43} image={generic64Image} style={{ marginRight: '9px' }} />
  72. {this.props.name}
  73. </Wrapper>
  74. )
  75. }
  76. render128Generic(disabled: boolean | null | undefined) {
  77. return (
  78. <Wrapper style={{
  79. fontSize: '22px',
  80. color: disabled ? ThemePalette.grayscale[3] : ThemePalette.black,
  81. textAlign: 'left',
  82. flexDirection: 'column',
  83. }}
  84. >
  85. <Logo
  86. width={80}
  87. height={70}
  88. image={disabled ? generic128DisabledImage : generic128Image}
  89. style={{ marginBottom: '4px' }}
  90. />
  91. {this.props.name}
  92. </Wrapper>
  93. )
  94. }
  95. render() {
  96. switch (this.props.size.h) {
  97. case 32:
  98. return this.render32Generic(this.props.white)
  99. case 42:
  100. return this.render42Generic()
  101. case 64:
  102. return this.render64Generic()
  103. case 128:
  104. return this.render128Generic(this.props.disabled)
  105. default:
  106. return null
  107. }
  108. }
  109. }
  110. export default Generic