-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #296 from jwplayer/social-buttons
Feat/social login buttons
- Loading branch information
Showing
14 changed files
with
190 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
@use 'src/styles/variables'; | ||
@use 'src/styles/theme'; | ||
|
||
.socialButtonContainer { | ||
position: relative; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
width: 100%; | ||
height: fit-content; | ||
padding: 0.5rem; | ||
color: variables.$gray-darker; | ||
text-decoration: none; | ||
background-color: variables.$white; | ||
border: 1px solid #979797; | ||
border-radius: 0.25rem; | ||
gap: 0.5rem; | ||
transition: background-color 0.1s ease-in-out; | ||
} | ||
|
||
.socialButtonContainer:hover { | ||
background-color: variables.$gray-lighter; | ||
cursor: pointer; | ||
} | ||
|
||
.socialButtonContainer:active { | ||
background-color: variables.$gray-light; | ||
} | ||
|
||
.socialButtonIconContainer { | ||
position: absolute; | ||
left: 0.5rem; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
width: 2.5rem; | ||
height: 100%; | ||
} | ||
|
||
.socialButtonIcon { | ||
width: 100%; | ||
height: 100%; | ||
} | ||
|
||
.socialButtonTextContainer { | ||
display: flex; | ||
flex-grow: 1; | ||
justify-content: center; | ||
align-items: center; | ||
height: 100%; | ||
padding: 0.5rem; | ||
font-weight: 600; | ||
font-size: 1.25rem; | ||
text-decoration: none; | ||
border-radius: 0.5rem; | ||
gap: 0.5rem; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { useEffect, useState } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
|
||
import styles from './SocialButton.module.scss'; | ||
|
||
export type SocialButtonVariant = 'facebook' | 'google' | 'twitter'; | ||
|
||
interface SocialButtonProps { | ||
variant: SocialButtonVariant; | ||
href: string; | ||
} | ||
|
||
const SocialButton = ({ variant, href }: SocialButtonProps) => { | ||
const [icon, setIcon] = useState<string | null>(null); | ||
|
||
const { t } = useTranslation('account'); | ||
|
||
useEffect(() => { | ||
const getIcon = async () => { | ||
const iconSvg = await (import(`../../assets/icons/${variant}.svg`) as Promise<{ default: string }>); | ||
setIcon(iconSvg.default); | ||
}; | ||
getIcon(); | ||
}, [variant]); | ||
|
||
return ( | ||
// t('login.facebook'); | ||
// t('login.google'); | ||
// t('login.twitter'); | ||
<a href={href} className={styles.socialButtonContainer} aria-label={t(`login.${variant}`)}> | ||
<div className={styles.socialButtonIconContainer}> | ||
<img className={styles.socialButtonIcon} src={icon ?? ''} alt={`${variant} icon`} /> | ||
</div> | ||
<span className={styles.socialButtonTextContainer}>{t(`login.${variant}`)}</span> | ||
</a> | ||
); | ||
}; | ||
|
||
export default SocialButton; |
9 changes: 9 additions & 0 deletions
9
src/components/SocialButtonsList/SocialButtonsList.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.socialButtonsListContainer { | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
width: 100%; | ||
padding: 1rem 0; | ||
gap: 1rem; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { useQuery } from 'react-query'; | ||
|
||
import SocialButton, { SocialButtonVariant } from '../SocialButton/SocialButton'; | ||
|
||
import styles from './SocialButtonsList.module.scss'; | ||
|
||
import { getSocialLoginUrls } from '#src/stores/AccountController'; | ||
|
||
const SocialButtonsList = () => { | ||
const urls = useQuery('socialUrls', getSocialLoginUrls); | ||
|
||
if (urls.error || !urls.data) { | ||
return null; | ||
} | ||
|
||
const formattedData = urls.data.reduce( | ||
(acc, url) => ({ | ||
...acc, | ||
...url, | ||
}), | ||
{} as { | ||
[key in SocialButtonVariant]: string; | ||
}, | ||
); | ||
|
||
return ( | ||
<div className={styles.socialButtonsListContainer}> | ||
{Object.entries(formattedData).map(([variant, url]) => ( | ||
<SocialButton key={variant} variant={variant as SocialButtonVariant} href={url} /> | ||
))} | ||
</div> | ||
); | ||
}; | ||
|
||
export default SocialButtonsList; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters