index.jsx 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. // @flow
  15. import React from 'react'
  16. import styled, { css } from 'styled-components'
  17. import StyleProps from '../../styleUtils/StyleProps'
  18. import Palette from '../../styleUtils/Palette'
  19. import { loginButtons } from '../../../config'
  20. import googleLogo from './images/google-logo.svg'
  21. import microsoftLogo from './images/microsoft-logo.svg'
  22. import facebookLogo from './images/facebook-logo.svg'
  23. import githubLogo from './images/github-logo.svg'
  24. const Wrapper = styled.div`
  25. display: flex;
  26. flex-wrap: wrap;
  27. width: ${loginButtons.length > 2 ? '420px' : '210px'};
  28. margin-left: -16px;
  29. margin-top: 16px;
  30. `
  31. const buttonStyle = (id, isLogo) => {
  32. switch (id) {
  33. case 'google':
  34. return isLogo ?
  35. css`background-image: url('${googleLogo}');`
  36. : css`
  37. color: ${Palette.grayscale[4]};
  38. border-color: ${Palette.grayscale[2]};
  39. background-color: white;
  40. `
  41. case 'microsoft':
  42. return isLogo ?
  43. css`background-image: url('${microsoftLogo}');`
  44. : css`
  45. border-color: #0078D7;
  46. background-color: #0078D7;
  47. `
  48. case 'facebook':
  49. return isLogo ?
  50. css`
  51. height: 27px;
  52. background-image: url('${facebookLogo}');
  53. margin-top: 8px;
  54. `
  55. : css`
  56. border-color: #2553B4;
  57. background-color: #2553B4;
  58. `
  59. case 'github':
  60. return isLogo ?
  61. css`background-image: url('${githubLogo}');`
  62. : css`
  63. border-color: ${Palette.grayscale[4]};
  64. background-color: ${Palette.grayscale[4]};
  65. `
  66. default:
  67. return ''
  68. }
  69. }
  70. const Button = styled.div`
  71. width: ${StyleProps.inputSizes.large.width - 2}px;
  72. height: ${StyleProps.inputSizes.large.height - 2}px;
  73. display: flex;
  74. align-items: center;
  75. border: 1px solid;
  76. border-radius: ${StyleProps.borderRadius};
  77. color: white;
  78. cursor: pointer;
  79. margin-left: 16px;
  80. margin-bottom: 16px;
  81. ${props => buttonStyle(props.id)}
  82. `
  83. const Logo = styled.div`
  84. width: 17px;
  85. height: 17px;
  86. background-repeat: no-repeat;
  87. margin: 0 8px 0 8px;
  88. ${props => buttonStyle(props.id, true)}
  89. `
  90. const LoginOptions = () => {
  91. if (loginButtons.length === 0) {
  92. return null
  93. }
  94. return (
  95. <Wrapper>{loginButtons.map((button) => {
  96. return (
  97. <Button key={button.id} id={button.id}>
  98. <Logo id={button.id} />Sign in with {button.name}
  99. </Button>
  100. )
  101. })}</Wrapper>
  102. )
  103. }
  104. export default LoginOptions