Skip to content

Commit

Permalink
Added Octicons to Copilot Landing page (#53122)
Browse files Browse the repository at this point in the history
Co-authored-by: Hector Alfaro <[email protected]>
  • Loading branch information
Saturn226 and hectorsector authored Nov 15, 2024
1 parent 50e3085 commit 6530203
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 17 deletions.
61 changes: 45 additions & 16 deletions src/landings/components/CookBookArticleCard.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,37 @@
import { Label, LabelGroup, Link } from '@primer/react'
import { BugIcon } from '@primer/octicons-react'
import {
BugIcon,
LightBulbIcon,
CodeIcon,
GearIcon,
RocketIcon,
BeakerIcon,
CopilotIcon,
HubotIcon,
LogIcon,
TerminalIcon,
BookIcon,
} from '@primer/octicons-react'

const Icons = {
bug: BugIcon,
lightbulb: LightBulbIcon,
code: CodeIcon,
gear: GearIcon,
rocket: RocketIcon,
beaker: BeakerIcon,
copilot: CopilotIcon,
hubot: HubotIcon,
log: LogIcon,
terminal: TerminalIcon,
book: BookIcon,
}

type IconType = keyof typeof Icons

type Props = {
title?: string
icon?: string
icon?: IconType
url?: string
description?: string
tags?: string[]
Expand All @@ -17,18 +45,7 @@ const defaultProps = {
description:
'Man bun letterpress put a bird on it la croix offal, meh grailed hot chicken kombucha gochujang messenger bag fit before they sold out lyft.',
tags: ['Tag Example', 'Tag Example'],
icon: 'bugicon',
}

function setIcon(icon: string) {
switch (icon) {
case 'bugicon':
return <BugIcon size={48} className="mr-4 bgColor-accent-muted p-3 circle fgColor-accent" />
case 'none':
return null
default:
return null
}
icon: 'book',
}

function setImage(image: string) {
Expand All @@ -51,21 +68,33 @@ function setImage(image: string) {
const spotlightClasses = 'd-flex flex-column align-items-center'
export const CookBookArticleCard = ({
title = defaultProps.title,
icon = defaultProps.icon,
icon = defaultProps.icon as IconType,
tags = defaultProps.tags,
description = defaultProps.description,
image = '',
url,
spotlight = false,
}: Props) => {
const setIcon = (icon: keyof typeof Icons) => {
return Icons[icon] || CopilotIcon
}

const IconComponent = setIcon(icon as keyof typeof Icons)
return (
<div className="m-2">
<div
style={{ minHeight: 200 }}
className={spotlight ? spotlightClasses : 'd-flex pb-3 border-bottom'}
>
{spotlight ? setImage(image) : null}
{spotlight ? setIcon('none') : setIcon(icon)}
{spotlight
? null
: IconComponent && (
<IconComponent
size={48}
className="mr-4 bgColor-accent-muted p-3 circle fgColor-accent"
/>
)}
<div>
<Link href={url}>
<h3 className="h4">{title}</h3>
Expand Down
13 changes: 12 additions & 1 deletion src/landings/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,18 @@ export type BaseTocItem = {
}

export type ChildTocItem = BaseTocItem & {
octicon?: string
octicon?:
| 'code'
| 'log'
| 'terminal'
| 'bug'
| 'lightbulb'
| 'gear'
| 'rocket'
| 'beaker'
| 'copilot'
| 'hubot'
| 'book'
category?: string[]
complexity?: string[]
industry?: string[]
Expand Down

0 comments on commit 6530203

Please sign in to comment.