-
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.
feat: initial social login buttons implementation
- Loading branch information
1 parent
9e1b8da
commit 0dd1204
Showing
7 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
.socialButtonContainer { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
width: fit-content; | ||
height: fit-content; | ||
} | ||
|
||
.socialButtonContainer:hover { | ||
transform: scale(1.05); | ||
cursor: pointer; | ||
} | ||
|
||
.socialButtonContainer:active { | ||
transform: scale(0.95); | ||
} |
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,30 @@ | ||
import { useEffect, useState } from 'react'; | ||
|
||
import styles from './SocialButton.module.scss'; | ||
|
||
export type SocialButtonVariant = 'facebook' | 'google' | 'twitter'; | ||
|
||
interface SocialButtonProps { | ||
variant: SocialButtonVariant; | ||
onClick: () => void; | ||
} | ||
|
||
const SocialButton = ({ variant, onClick }: SocialButtonProps) => { | ||
const [icon, setIcon] = useState<string | null>(null); | ||
|
||
useEffect(() => { | ||
const getIcon = async () => { | ||
const iconSvg = await (import(`../../assets/icons/${variant}.svg`) as Promise<{ default: string }>); | ||
setIcon(iconSvg.default); | ||
}; | ||
getIcon(); | ||
}, [variant]); | ||
|
||
return ( | ||
<div onClick={onClick} className={styles.socialButtonContainer}> | ||
<img src={icon ?? ''} alt={`${variant} icon`} /> | ||
</div> | ||
); | ||
}; | ||
|
||
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: row; | ||
justify-content: center; | ||
align-items: center; | ||
width: 100%; | ||
padding: 1rem; | ||
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,24 @@ | ||
import SocialButton, { SocialButtonVariant } from '../SocialButton/SocialButton'; | ||
|
||
import styles from './SocialButtonsList.module.scss'; | ||
|
||
type SocialButtonsListProps = { | ||
buttonProps: { | ||
[key in SocialButtonVariant]: { | ||
onClick: () => void; | ||
}; | ||
}; | ||
}; | ||
|
||
const SocialButtonsList = ({ buttonProps }: SocialButtonsListProps) => { | ||
const variants: SocialButtonVariant[] = ['facebook', 'google', 'twitter']; | ||
return ( | ||
<div className={styles.socialButtonsListContainer}> | ||
{variants.map((variant) => ( | ||
<SocialButton key={variant} variant={variant} onClick={buttonProps[variant].onClick} /> | ||
))} | ||
</div> | ||
); | ||
}; | ||
|
||
export default SocialButtonsList; |