-
-
Notifications
You must be signed in to change notification settings - Fork 218
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
53 changed files
with
19,856 additions
and
22,476 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,20 @@ | ||
module.exports = { | ||
"stories": [ | ||
"../stories/**/*.stories.mdx", | ||
"../stories/**/*.stories.@(js|jsx|ts|tsx)" | ||
], | ||
"addons": [ | ||
stories: ["../stories/**/*.stories.mdx", "../stories/**/*.stories.@(js|jsx|ts|tsx)"], | ||
addons: [ | ||
"@storybook/addon-links", | ||
"@storybook/addon-essentials", | ||
"@storybook/addon-interactions", | ||
"@storybook/addon-a11y", | ||
"storybook-addon-next", | ||
{ | ||
// From stack-overflow answer: https://stackoverflow.com/a/68757745 | ||
name: '@storybook/addon-postcss', | ||
name: "@storybook/addon-styling", | ||
options: { | ||
cssLoaderOptions: { | ||
// When you have splitted your css over multiple files | ||
// and use @import('./other-styles.css') | ||
importLoaders: 1, | ||
}, | ||
postcssLoaderOptions: { | ||
// When using postCSS 8 | ||
implementation: require('postcss'), | ||
}, | ||
postCss: true, | ||
}, | ||
}, | ||
], | ||
"framework": "@storybook/react", | ||
"core": { | ||
"builder": "@storybook/builder-webpack5" | ||
} | ||
} | ||
framework: "@storybook/nextjs", | ||
options: {}, | ||
docs: { | ||
autodocs: true, | ||
}, | ||
}; |
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
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
79 changes: 79 additions & 0 deletions
79
components/atoms/TopContributorCard/top-contributor-card.tsx
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,79 @@ | ||
import React, { useEffect, useState } from "react"; | ||
|
||
import Link from "next/link"; | ||
import { useRouter } from "next/router"; | ||
import { getAvatarByUsername } from "lib/utils/github"; | ||
import useFollowUser from "lib/hooks/useFollowUser"; | ||
import useSupabaseAuth from "lib/hooks/useSupabaseAuth"; | ||
|
||
import Avatar from "../Avatar/avatar"; | ||
import Button from "../Button/button"; | ||
|
||
export interface TopContributorCardProps { | ||
login: string; | ||
} | ||
|
||
const TopContributorCard = ({ login }: TopContributorCardProps) => { | ||
const router = useRouter(); | ||
const currentPath = router.asPath; | ||
|
||
const { isError: notFollowing, follow, unFollow } = useFollowUser(login); | ||
const [host, setHost] = useState(""); | ||
const { sessionToken, signIn } = useSupabaseAuth(); | ||
|
||
const handleFollowContributor = async () => { | ||
try { | ||
if (notFollowing) { | ||
await follow(); | ||
return; | ||
} | ||
await unFollow(); | ||
} catch (error) { | ||
console.log(error); | ||
} | ||
}; | ||
|
||
useEffect(() => { | ||
if (typeof window !== "undefined") { | ||
setHost(window.location.origin as string); | ||
} | ||
}, []); | ||
|
||
return ( | ||
<div className="flex items-center justify-between w-full gap-4 bg-light-slate-1"> | ||
<Link href={`/user/${login}`}> | ||
<div className="flex items-center gap-2"> | ||
<Avatar isCircle size={35} avatarURL={getAvatarByUsername(login)} /> | ||
<p className="font-semibold text-light-slate-12">{login}</p> | ||
</div> | ||
</Link> | ||
{sessionToken && !notFollowing ? ( | ||
<Button | ||
onClick={() => | ||
sessionToken | ||
? handleFollowContributor() | ||
: signIn({ provider: "github", options: { redirectTo: `${host}/${currentPath}` } }) | ||
} | ||
className="!px-2 !py-1" | ||
variant="primary" | ||
> | ||
following | ||
</Button> | ||
) : ( | ||
<Button | ||
onClick={() => | ||
sessionToken | ||
? handleFollowContributor() | ||
: signIn({ provider: "github", options: { redirectTo: `${host}/${currentPath}` } }) | ||
} | ||
className="!px-2 !py-1 border-light-orange-7 text-light-orange-10" | ||
variant="text" | ||
> | ||
follow | ||
</Button> | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
export default TopContributorCard; |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.