Skip to content

Commit

Permalink
feat(www): Add Community Plugin Badge (#21847)
Browse files Browse the repository at this point in the history
* Add Community Plugin Badge

* Add Community Icon for plugins search body
  • Loading branch information
akshitkrnagpal committed Apr 6, 2020
1 parent 4e1dc8a commit 9b635cb
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 36 deletions.
71 changes: 42 additions & 29 deletions www/src/components/package-readme.js
Expand Up @@ -10,10 +10,51 @@ import MarkdownPageFooter from "./markdown-page-footer"
import FooterLinks from "./shared/footer-links"
import { GoMarkGithub as GithubIcon } from "react-icons/go"
import GatsbyIcon from "./gatsby-monogram"
import { FaUsers as CommunityIcon } from "react-icons/fa"

const GatsbyPluginBadge = ({ isOfficial }) => {
const Icon = isOfficial ? GatsbyIcon : CommunityIcon
const title = isOfficial
? "Official Gatsby Plugin"
: "Community Gatsby Plugin"
const text = isOfficial ? `Official Plugin` : `Community Plugin`

return (
<div
sx={{
variant: `links.muted`,
mr: 8,
"&&": {
border: 0,
color: `textMuted`,
display: `flex`,
fontWeight: `body`,
},
"&&:hover": {
color: `textMuted`,
},
}}
>
<span
sx={{
display: `inline-block`,
mr: 2,
}}
title={title}
>
<Icon />
</span>
{text}
</div>
)
}

const PackageReadMe = props => {
const { page, packageName, excerpt, html, githubUrl, timeToRead } = props
const metaExcerpt = excerpt || `Plugin information for ${packageName}`
const isOfficial =
githubUrl.indexOf(`https://github.com/gatsbyjs/gatsby`) === 0 &&
packageName[0] !== `@`

return (
<React.Fragment>
Expand Down Expand Up @@ -45,35 +86,7 @@ const PackageReadMe = props => {
justifyContent: `space-between`,
}}
>
{githubUrl.indexOf(`https://github.com/gatsbyjs/gatsby`) === 0 &&
packageName[0] !== `@` && (
<div
sx={{
variant: `links.muted`,
mr: 8,
"&&": {
border: 0,
color: `textMuted`,
display: `flex`,
fontWeight: `body`,
},
"&&:hover": {
color: `textMuted`,
},
}}
>
<span
sx={{
display: `inline-block`,
mr: 2,
}}
title={`Official Gatsby Plugin`}
>
<GatsbyIcon />
</span>
Official Plugin
</div>
)}
<GatsbyPluginBadge isOfficial={isOfficial} />
<a
sx={{ variant: `links.muted` }}
href={githubUrl}
Expand Down
19 changes: 12 additions & 7 deletions www/src/components/plugin-searchbar-body.js
Expand Up @@ -25,6 +25,7 @@ import { visuallyHidden } from "../utils/styles"
import { Global, css } from "@emotion/core"
import removeMD from "remove-markdown"
import SkipNavLink from "./skip-nav-link"
import { FaUsers as CommunityIcon } from "react-icons/fa"

// This is for the urlSync
const updateAfter = 700
Expand Down Expand Up @@ -407,13 +408,17 @@ const Result = ({ hit, pathname, query }) => {
}}
>
{hit.repository &&
hit.name[0] !== `@` &&
hit.repository.url.indexOf(`https://github.com/gatsbyjs/gatsby`) ===
0 && (
<span sx={{ mr: 1 }} alt={`Official Gatsby Plugin`}>
<GatsbyIcon />
</span>
)}
hit.name[0] !== `@` &&
hit.repository.url.indexOf(`https://github.com/gatsbyjs/gatsby`) ===
0 ? (
<span sx={{ mr: 1 }} alt={`Official Gatsby Plugin`}>
<GatsbyIcon />
</span>
) : (
<span sx={{ mr: 1 }} alt={`Community Gatsby Plugin`}>
<CommunityIcon />
</span>
)}
<span
css={{
width: `5em`,
Expand Down

0 comments on commit 9b635cb

Please sign in to comment.