Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions snippets/javascript/color-manipulation/rgb-to-hex-color.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ tags: color,conversion
function rgbToHex(r, g, b) {
const toHex = (n) => {
const hex = n.toString(16);
return hex.length === 1 ? '0' + hex : hex;
return hex.length === 1 ? "0" + hex : hex;
};
return '#' + toHex(r) + toHex(g) + toHex(b);

return "#" + toHex(r) + toHex(g) + toHex(b);
}

// Usage:
Expand Down
26 changes: 25 additions & 1 deletion src/components/SnippetModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const SnippetModal: React.FC<Props> = ({
{snippet.description}
</p>
<p>
Contributed by{" "}
Created by{" "}
<a
href={`https://github.com/${snippet.author}`}
target="_blank"
Expand All @@ -78,6 +78,30 @@ const SnippetModal: React.FC<Props> = ({
@{snippet.author}
</a>
</p>
{(snippet.contributors ?? []).length > 0 && (
<div className="contributors">
<span>Contributors: </span>
{snippet.contributors
?.slice(0, 3)
.map((contributor, index, slicedArray) => (
<>
<a
key={contributor}
href={`https://github.com/${contributor}`}
target="_blank"
rel="noopener noreferrer"
className="styled-link"
>
@{contributor}
</a>
{index < slicedArray.length - 1 && ", "}
</>
))}
{(snippet.contributors?.length ?? 0) > 3 && (
<span> & {snippet.contributors!.length - 3} more</span>
)}
</div>
)}
<ul role="list" className="modal__tags">
{snippet.tags.map((tag) => (
<li key={tag} className="modal__tag">
Expand Down
Loading