|
| 1 | +/* eslint-disable react/jsx-no-bind */ |
1 | 2 | /* eslint-disable react/no-multi-comp */
|
2 | 3 | import React from 'react'
|
3 | 4 | import PropTypes from 'prop-types'
|
4 | 5 | import config from 'config:sanity'
|
5 |
| -import BrandLogo from 'part:@sanity/base/brand-logo?' |
6 |
| -import styles from './styles/LoginDialogContent.css' |
| 6 | +import {Button, Stack, Heading, Inline, Flex, Text, Box, Card} from '@sanity/ui' |
| 7 | +import styled from 'styled-components' |
| 8 | +import {BrandLogo} from './legacyParts' |
| 9 | +import {getProviderLogo} from './util/getProviderLogo' |
7 | 10 |
|
8 |
| -const projectName = (config.project && config.project.name) || '' |
9 |
| - |
10 |
| -/* eslint-disable max-len */ |
11 |
| -const GithubLogo = () => ( |
12 |
| - <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 438.55 438.55"> |
13 |
| - <path d="M409.13 114.57a218.32 218.32 0 0 0-79.8-79.8Q278.94 5.36 219.27 5.36T109.21 34.77a218.29 218.29 0 0 0-79.8 79.8Q0 165 0 224.63q0 71.67 41.83 128.91t108.06 79.23q7.71 1.43 11.42-2a11.17 11.17 0 0 0 3.69-8.57q0-.86-.14-15.42t-.14-25.41l-6.57 1.14a83.77 83.77 0 0 1-15.85 1 120.73 120.73 0 0 1-19.84-2 44.34 44.34 0 0 1-19.11-8.51 36.23 36.23 0 0 1-12.56-17.6l-2.86-6.57a71.34 71.34 0 0 0-9-14.56q-6.14-8-12.42-10.85l-2-1.43a21 21 0 0 1-3.71-3.43 15.66 15.66 0 0 1-2.57-4q-.86-2 1.43-3.29C61.2 310.42 64 310 68 310l5.71.85q5.71 1.14 14.13 6.85a46.08 46.08 0 0 1 13.85 14.84q6.57 11.71 15.85 17.85t18.7 6.14a81.19 81.19 0 0 0 16.27-1.42 56.78 56.78 0 0 0 12.85-4.29q2.57-19.14 14-29.41a195.49 195.49 0 0 1-29.36-5.13 116.52 116.52 0 0 1-26.83-11.14 76.86 76.86 0 0 1-23-19.13q-9.14-11.42-15-30t-5.8-42.81q0-34.55 22.56-58.82-10.57-26 2-58.24 8.28-2.57 24.55 3.85t23.84 11q7.57 4.56 12.13 7.71a206.2 206.2 0 0 1 109.64 0l10.85-6.85a153.65 153.65 0 0 1 26.26-12.56q15.13-5.71 23.13-3.14 12.84 32.26 2.28 58.24 22.55 24.27 22.56 58.82 0 24.27-5.85 43t-15.12 30a79.82 79.82 0 0 1-23.13 19 116.74 116.74 0 0 1-26.84 11.14 195.29 195.29 0 0 1-29.23 5.07q14.8 12.84 14.81 40.58v60.2a11.37 11.37 0 0 0 3.57 8.56q3.57 3.42 11.28 2 66.24-22 108.07-79.23t41.83-128.91q-.03-59.62-29.43-110.05z" /> |
14 |
| - </svg> |
15 |
| -) |
16 |
| - |
17 |
| -const GoogleLogo = () => ( |
18 |
| - <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48"> |
19 |
| - <path |
20 |
| - d="M11 24a13 13 0 0 1 .66-4.08l-7.4-5.66a22.18 22.18 0 0 0 0 19.49l7.4-5.67A13 13 0 0 1 11 24z" |
21 |
| - fill="#fbbc05" |
22 |
| - /> |
23 |
| - <path |
24 |
| - d="M24 11a12.72 12.72 0 0 1 8.1 2.9l6.4-6.4a22 22 0 0 0-34.24 6.75l7.4 5.66A13 13 0 0 1 24 11z" |
25 |
| - fill="#ea4335" |
26 |
| - /> |
27 |
| - <path |
28 |
| - d="M24 37a13 13 0 0 1-12.34-8.92l-7.4 5.66A21.93 21.93 0 0 0 24 46a21 21 0 0 0 14.33-5.48l-7-5.44A13.59 13.59 0 0 1 24 37zm-12.35-8.93l-7.4 5.67 7.4-5.66z" |
29 |
| - fill="#34a853" |
30 |
| - /> |
31 |
| - <path |
32 |
| - d="M44.5 20H24v8.5h11.8a9.91 9.91 0 0 1-4.49 6.58l7 5.44C42.37 36.76 45 31.17 45 24a18.25 18.25 0 0 0-.5-4z" |
33 |
| - fill="#4285f4" |
34 |
| - /> |
35 |
| - </svg> |
36 |
| -) |
37 |
| - |
38 |
| -const QuestionmarkLogo = () => ( |
39 |
| - <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 112 112"> |
40 |
| - <path d="M0 0h112v112H0z" /> |
41 |
| - <circle cx="56" cy="56" r="56" fill="#AFBACA" /> |
42 |
| - <path d="M22 24h68v68H22z" /> |
43 |
| - <path d="M27.667 35.333h56.667v45.333H27.667z" /> |
44 |
| - <path |
45 |
| - fill="#fff" |
46 |
| - d="M84.333 41c0-3.117-2.55-5.667-5.666-5.667H33.333c-3.116 0-5.666 2.55-5.666 5.667v34c0 3.117 2.55 5.667 5.666 5.667h45.334c3.116 0 5.666-2.55 5.666-5.667V41zm-5.666 0L56 55.167 33.333 41h45.334zm0 34H33.333V46.667L56 60.833l22.667-14.166V75z" |
47 |
| - /> |
48 |
| - </svg> |
49 |
| -) |
50 |
| -/* eslint-enable max-len */ |
| 11 | +const ProviderLogoWrapper = styled(Box)` |
| 12 | + svg, |
| 13 | + img { |
| 14 | + border-radius: 50%; |
| 15 | + height: 1.25em; |
| 16 | + width: 1.25em; |
| 17 | + } |
| 18 | +` |
51 | 19 |
|
52 |
| -function getProviderLogo(provider) { |
53 |
| - switch (provider.name) { |
54 |
| - case 'google': |
55 |
| - return GoogleLogo |
56 |
| - case 'github': |
57 |
| - return GithubLogo |
58 |
| - default: |
59 |
| - return function CustomLogo() { |
60 |
| - return provider.logo ? ( |
61 |
| - <img src={provider.logo} alt={`Logo for ${provider.name}`} /> |
62 |
| - ) : ( |
63 |
| - <QuestionmarkLogo /> |
64 |
| - ) |
65 |
| - } |
| 20 | +const BrandLogoWrapper = styled(Box)` |
| 21 | + svg { |
| 22 | + display: block; |
| 23 | + height: 2rem; |
| 24 | + width: auto; |
| 25 | + margin: 0 auto; |
66 | 26 | }
|
67 |
| -} |
| 27 | +` |
| 28 | + |
| 29 | +const projectName = (config.project && config.project.name) || '' |
68 | 30 |
|
69 | 31 | // eslint-disable-next-line react/require-optimization
|
70 | 32 | export default class LoginDialogContent extends React.Component {
|
@@ -96,61 +58,62 @@ export default class LoginDialogContent extends React.Component {
|
96 | 58 | render() {
|
97 | 59 | const {title, description, providers, SanityLogo} = this.props
|
98 | 60 | return (
|
99 |
| - <div className={styles.root}> |
100 |
| - <div className={styles.inner}> |
101 |
| - {SanityLogo && ( |
102 |
| - <div className={styles.sanityLogo}> |
103 |
| - <SanityLogo /> |
104 |
| - </div> |
| 61 | + <Box paddingX={4} paddingY={5}> |
| 62 | + <Stack space={5}> |
| 63 | + {BrandLogo && projectName && ( |
| 64 | + <BrandLogoWrapper> |
| 65 | + <BrandLogo projectName={projectName} /> |
| 66 | + </BrandLogoWrapper> |
105 | 67 | )}
|
| 68 | + <Stack space={4}> |
| 69 | + {!BrandLogo && projectName && ( |
| 70 | + <Heading align="center" as="h2" size={3}> |
| 71 | + {projectName} |
| 72 | + </Heading> |
| 73 | + )} |
| 74 | + {title && ( |
| 75 | + <Text align="center" weight="semibold"> |
| 76 | + {title} |
| 77 | + </Text> |
| 78 | + )} |
| 79 | + {description && ( |
| 80 | + <Text size={1} muted align="center"> |
| 81 | + {description} |
| 82 | + </Text> |
| 83 | + )} |
| 84 | + </Stack> |
106 | 85 |
|
107 |
| - <div className={styles.card}> |
108 |
| - <div className={styles.cardHeader}> |
109 |
| - <h1 className={styles.cardTitle}>Sign in</h1> |
110 |
| - </div> |
111 |
| - |
112 |
| - <div className={styles.cardContent}> |
113 |
| - <div className={styles.branding}> |
114 |
| - <h1 className={BrandLogo ? styles.projectNameHidden : styles.projectName}> |
115 |
| - {projectName} |
116 |
| - </h1> |
117 |
| - {BrandLogo && ( |
118 |
| - <div className={styles.brandLogoContainer}> |
119 |
| - <BrandLogo projectName={projectName} /> |
120 |
| - </div> |
121 |
| - )} |
122 |
| - </div> |
123 |
| - |
124 |
| - <div> |
125 |
| - <h2 className={styles.title}>{title}</h2> |
126 |
| - {description && <div className={styles.description}>{description}</div>} |
127 |
| - </div> |
128 |
| - |
129 |
| - <ul className={styles.providers}> |
130 |
| - {providers.map((provider) => { |
131 |
| - const ProviderLogo = getProviderLogo(provider) |
132 |
| - const onLoginClick = this.handleLoginButtonClicked.bind(this, provider) |
133 |
| - return ( |
134 |
| - <li key={provider.name} className={styles.provider}> |
135 |
| - {/* eslint-disable-next-line react/jsx-no-bind */} |
136 |
| - <button |
137 |
| - type="button" |
138 |
| - onClick={onLoginClick} |
139 |
| - className={styles.providerButton} |
140 |
| - > |
141 |
| - <span className={styles.providerLogo}> |
| 86 | + <Stack space={2} as="ul"> |
| 87 | + {providers?.map((provider) => { |
| 88 | + const ProviderLogo = getProviderLogo(provider) |
| 89 | + const onLoginClick = this.handleLoginButtonClicked.bind(this, provider) |
| 90 | + return ( |
| 91 | + <Card key={provider?.name} radius={2} border as="li"> |
| 92 | + <Button mode="bleed" paddingY={4} onClick={onLoginClick} style={{width: '100%'}}> |
| 93 | + <Flex justify="center"> |
| 94 | + <Inline space={2}> |
| 95 | + <ProviderLogoWrapper> |
142 | 96 | <ProviderLogo />
|
143 |
| - </span> |
144 |
| - <span className={styles.providerName}>{provider.title}</span> |
145 |
| - </button> |
146 |
| - </li> |
147 |
| - ) |
148 |
| - })} |
149 |
| - </ul> |
150 |
| - </div> |
151 |
| - </div> |
152 |
| - </div> |
153 |
| - </div> |
| 97 | + </ProviderLogoWrapper> |
| 98 | + <Box> |
| 99 | + <Text>{provider?.title}</Text> |
| 100 | + </Box> |
| 101 | + </Inline> |
| 102 | + </Flex> |
| 103 | + </Button> |
| 104 | + </Card> |
| 105 | + ) |
| 106 | + })} |
| 107 | + </Stack> |
| 108 | + {SanityLogo && ( |
| 109 | + <Flex justify="center" marginTop={2}> |
| 110 | + <Text> |
| 111 | + <SanityLogo /> |
| 112 | + </Text> |
| 113 | + </Flex> |
| 114 | + )} |
| 115 | + </Stack> |
| 116 | + </Box> |
154 | 117 | )
|
155 | 118 | }
|
156 | 119 | }
|
2 commit comments
vercel[bot] commentedon Jul 9, 2021
Successfully deployed to the following URLs:
perf-studio – ./
perf-studio-git-next.sanity.build
perf-studio.sanity.build
vercel[bot] commentedon Jul 9, 2021
Successfully deployed to the following URLs:
test-studio – ./
test-studio.sanity.build
test-studio-git-next.sanity.build