-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
"Request an update" badge component (#6)
- Loading branch information
1 parent
f72e455
commit 0c754de
Showing
4 changed files
with
265 additions
and
37 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import React from 'react'; | ||
import BrowserOnly from '@docusaurus/BrowserOnly'; | ||
import styles from './styles.module.css'; | ||
|
||
export const HeaderBadges = ({ commaDelimitedContributors, lastVerifiedDateString, lastVerifiedVersionString }) => { | ||
let githubUsernames = { | ||
Mick: "mick-prysm", | ||
Raul: "rauljordan", | ||
Terence: "terencechain", | ||
James: "james-prysm", | ||
Kasey: "kasey", | ||
Potuz: "potuz", | ||
Nishant: "nisdas" | ||
} | ||
|
||
let buildAuthorBadge = function (authorNickname) { | ||
if (authorNickname != "Clarin") { | ||
return ( | ||
<a class="header-badge" href={`https://github.com/${githubUsernames[authorNickname]}`}> | ||
<span class="badge-avatar" style={{ backgroundImage: "url('https://avatars.githubusercontent.com/" + githubUsernames[authorNickname] + "')" }}></span> | ||
<span class="badge-label">{authorNickname}</span> | ||
</a> | ||
) | ||
} else { | ||
return ( | ||
<a class="header-badge" href='https://www.linkedin.com/in/clarin-dy-239b5616a/'> | ||
<span class="badge-avatar" style={{ backgroundImage: "url('https://i.imgur.com/vhht8qs.jpg')" }}></span> | ||
<span class="badge-label">{authorNickname}</span> | ||
</a> | ||
) | ||
} | ||
} | ||
|
||
let buildLastVerifiedBadge = function (dateString) { | ||
if (dateString != null) { | ||
return ( | ||
<a class="header-badge"> | ||
<span class="badge-avatar emoji-avatar">✔️</span> | ||
<span class="badge-label">Last verified on <strong>{dateString}</strong></span> | ||
</a> | ||
) | ||
} | ||
} | ||
|
||
return ( | ||
<BrowserOnly> | ||
{() => | ||
<div class="header-badges"> | ||
{(commaDelimitedContributors != null ? commaDelimitedContributors.split(',').map(buildAuthorBadge) : null)} | ||
{buildLastVerifiedBadge(lastVerifiedDateString, lastVerifiedVersionString)} | ||
<a class="header-badge" href={`https://github.com/CoolChainCo/docs/issues/new?title=Docs update request: ${new URL(window.location.href).pathname}&body=Source: ${window.location.href}%0A%0ARequest: (how can we help?)`}> | ||
<span class="badge-avatar emoji-avatar">✏️</span> | ||
<span class="badge-label">Request an update</span> | ||
</a> | ||
</div> | ||
} | ||
</BrowserOnly> | ||
); | ||
}; |
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,18 @@ | ||
import React from 'react'; | ||
import Content from '@theme-original/DocItem/Content'; | ||
import { HeaderBadges } from '@site/src/components/HeaderBadges'; | ||
|
||
|
||
export default function ContentWrapper(props) { | ||
return ( | ||
<> | ||
<HeaderBadges /> | ||
<Content {...props} /> | ||
</> | ||
); | ||
} | ||
|
||
// This file was generated via `yarn swizzle @docusaurus/theme-classic DocItem/Content` - I selected `wrap` when prompted and then imported & injected the `HeaderBadges` widget. Lines :3 and :9 are the only additions I made. | ||
// docs -> https://docusaurus.io/docs/next/swizzling#wrapping | ||
// other docs -> https://docusaurus.io/docs/next/markdown-features/react#mdx-component-scope | ||
// note that the "other docs" recommend wrapping `@theme/MDXComponents` but this is no longer possible as of docusaurus v2. |