Skip to content

Commit

Permalink
Merge pull request #4 from ar-io/ps-ExternalIcon
Browse files Browse the repository at this point in the history
refactor: standardize icon types and add external link indicators
  • Loading branch information
Bobinstein authored Dec 18, 2024
2 parents cf6c94a + 46e2856 commit bec78c6
Show file tree
Hide file tree
Showing 37 changed files with 230 additions and 48 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-highlight-words": "^0.20.0",
"rehype-external-links": "^3.0.0",
"remark": "^15.0.1",
"remark-gfm": "^4.0.0",
"remark-mdx": "^3.0.0",
Expand Down
14 changes: 1 addition & 13 deletions src/components/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
import Link from 'next/link'
import clsx from 'clsx'

function ArrowIcon(props: React.ComponentPropsWithoutRef<'svg'>) {
return (
<svg viewBox="0 0 20 20" fill="none" aria-hidden="true" {...props}>
<path
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
d="m11.5 6.5 3 3.5m0 0-3 3.5m3-3.5h-9"
/>
</svg>
)
}
import { ArrowIcon } from '@/components/icons/ArrowIcon'

const variantStyles = {
primary:
Expand Down
30 changes: 30 additions & 0 deletions src/components/ExternalLink.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import Link from 'next/link'
import { SquareArrowOutUpRight } from 'lucide-react'
import clsx from 'clsx'

function ExternalLink({
href,
children,
className
}: {
href: string
children: React.ReactNode
className?: string
}) {
return (
<Link
href={href}
target="_blank"
rel="noopener noreferrer"
className={clsx(
"inline-flex items-center gap-1 group",
className
)}
>
{children}
<SquareArrowOutUpRight className="w-4 h-4 transition-colors group-hover:text-zinc-900 dark:group-hover:text-white" />
</Link>
)
}

export default ExternalLink
8 changes: 7 additions & 1 deletion src/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { forwardRef } from 'react'
import Link from 'next/link'
import clsx from 'clsx'
import { motion, useScroll, useTransform } from 'framer-motion'
import { SquareArrowOutUpRight } from 'lucide-react'

import { Button } from '@/components/Button'
import { Logo } from '@/components/Logo'
Expand All @@ -22,14 +23,19 @@ function TopLevelNavItem({
children: React.ReactNode,
target?: string
}) {
const isExternal = href.startsWith('http')

return (
<li>
<Link
href={href}
target={target}
className="text-sm leading-5 text-zinc-600 transition hover:text-zinc-900 dark:text-zinc-400 dark:hover:text-white"
className="inline-flex items-center gap-1 text-sm leading-5 text-zinc-600 transition hover:text-zinc-900 dark:text-zinc-400 dark:hover:text-white"
>
{children}
{isExternal && (
<SquareArrowOutUpRight className="h-2.5 w-2.5 transition-colors group-hover:text-zinc-900 dark:group-hover:text-white" />
)}
</Link>
</li>
)
Expand Down
3 changes: 2 additions & 1 deletion src/components/Heading.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
import { useEffect, useRef } from 'react'
import Link from 'next/link'
import { useInView } from 'framer-motion'
import { LucideProps } from 'lucide-react'

import { useSectionStore } from '@/components/SectionProvider'
import { Tag } from '@/components/Tag'
import { remToPx } from '@/lib/remToPx'

function AnchorIcon(props: React.ComponentPropsWithoutRef<'svg'>) {
function AnchorIcon(props: LucideProps) {
return (
<svg
viewBox="0 0 20 20"
Expand Down
14 changes: 14 additions & 0 deletions src/components/icons/ArrowIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { LucideProps } from 'lucide-react'

export function ArrowIcon(props: LucideProps) {
return (
<svg viewBox="0 0 20 20" fill="none" aria-hidden="true" {...props}>
<path
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
d="m11.5 6.5 3 3.5m0 0-3 3.5m3-3.5h-9"
/>
</svg>
)
}
4 changes: 3 additions & 1 deletion src/components/icons/BellIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export function BellIcon(props: React.ComponentPropsWithoutRef<'svg'>) {
import { LucideProps } from 'lucide-react'

export function BellIcon(props: LucideProps) {
return (
<svg viewBox="0 0 20 20" aria-hidden="true" {...props}>
<path
Expand Down
4 changes: 3 additions & 1 deletion src/components/icons/BoltIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export function BoltIcon(props: React.ComponentPropsWithoutRef<'svg'>) {
import { LucideProps } from 'lucide-react'

export function BoltIcon(props: LucideProps) {
return (
<svg viewBox="0 0 20 20" aria-hidden="true" {...props}>
<path
Expand Down
4 changes: 3 additions & 1 deletion src/components/icons/BookIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export function BookIcon(props: React.ComponentPropsWithoutRef<'svg'>) {
import { LucideProps } from "lucide-react";

export function BookIcon(props: LucideProps) {
return (
<svg viewBox="0 0 20 20" aria-hidden="true" {...props}>
<path
Expand Down
4 changes: 3 additions & 1 deletion src/components/icons/CalendarIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export function CalendarIcon(props: React.ComponentPropsWithoutRef<'svg'>) {
import { LucideProps } from "lucide-react";

export function CalendarIcon(props: LucideProps) {
return (
<svg viewBox="0 0 20 20" aria-hidden="true" {...props}>
<path
Expand Down
4 changes: 3 additions & 1 deletion src/components/icons/CartIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export function CartIcon(props: React.ComponentPropsWithoutRef<'svg'>) {
import { LucideProps } from 'lucide-react'

export function CartIcon(props: LucideProps) {
return (
<svg viewBox="0 0 20 20" aria-hidden="true" {...props}>
<path
Expand Down
4 changes: 3 additions & 1 deletion src/components/icons/ChatBubbleIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export function ChatBubbleIcon(props: React.ComponentPropsWithoutRef<'svg'>) {
import { LucideProps } from 'lucide-react'

export function ChatBubbleIcon(props: LucideProps) {
return (
<svg viewBox="0 0 20 20" aria-hidden="true" {...props}>
<path
Expand Down
4 changes: 3 additions & 1 deletion src/components/icons/CheckIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export function CheckIcon(props: React.ComponentPropsWithoutRef<'svg'>) {
import { LucideProps } from "lucide-react";

export function CheckIcon(props: LucideProps) {
return (
<svg viewBox="0 0 20 20" aria-hidden="true" {...props}>
<path
Expand Down
4 changes: 3 additions & 1 deletion src/components/icons/ChevronRightLeftIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { LucideProps } from "lucide-react";

export function ChevronRightLeftIcon(
props: React.ComponentPropsWithoutRef<'svg'>,
props: LucideProps,
) {
return (
<svg viewBox="0 0 20 20" aria-hidden="true" {...props}>
Expand Down
4 changes: 3 additions & 1 deletion src/components/icons/ClipboardIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export function ClipboardIcon(props: React.ComponentPropsWithoutRef<'svg'>) {
import { LucideProps } from "lucide-react";

export function ClipboardIcon(props: LucideProps) {
return (
<svg viewBox="0 0 20 20" aria-hidden="true" {...props}>
<path
Expand Down
4 changes: 3 additions & 1 deletion src/components/icons/CogIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export function CogIcon(props: React.ComponentPropsWithoutRef<'svg'>) {
import { LucideProps } from "lucide-react";

export function CogIcon(props: LucideProps) {
return (
<svg viewBox="0 0 20 20" aria-hidden="true" {...props}>
<path
Expand Down
4 changes: 3 additions & 1 deletion src/components/icons/CopyIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export function CopyIcon(props: React.ComponentPropsWithoutRef<'svg'>) {
import { LucideProps } from "lucide-react";

export function CopyIcon(props: LucideProps) {
return (
<svg viewBox="0 0 20 20" aria-hidden="true" {...props}>
<path
Expand Down
4 changes: 3 additions & 1 deletion src/components/icons/DocumentIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export function DocumentIcon(props: React.ComponentPropsWithoutRef<'svg'>) {
import { LucideProps } from "lucide-react";

export function DocumentIcon(props: LucideProps) {
return (
<svg viewBox="0 0 20 20" aria-hidden="true" {...props}>
<path
Expand Down
4 changes: 3 additions & 1 deletion src/components/icons/EnvelopeIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export function EnvelopeIcon(props: React.ComponentPropsWithoutRef<'svg'>) {
import { LucideProps } from "lucide-react";

export function EnvelopeIcon(props: LucideProps) {
return (
<svg viewBox="0 0 20 20" aria-hidden="true" {...props}>
<path
Expand Down
4 changes: 3 additions & 1 deletion src/components/icons/FaceSmileIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export function FaceSmileIcon(props: React.ComponentPropsWithoutRef<'svg'>) {
import { LucideProps } from "lucide-react";

export function FaceSmileIcon(props: LucideProps) {
return (
<svg viewBox="0 0 20 20" aria-hidden="true" {...props}>
<path
Expand Down
4 changes: 3 additions & 1 deletion src/components/icons/FolderIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export function FolderIcon(props: React.ComponentPropsWithoutRef<'svg'>) {
import { LucideProps } from "lucide-react";

export function FolderIcon(props: LucideProps) {
return (
<svg viewBox="0 0 20 20" aria-hidden="true" {...props}>
<path
Expand Down
4 changes: 3 additions & 1 deletion src/components/icons/LinkIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export function LinkIcon(props: React.ComponentPropsWithoutRef<'svg'>) {
import { LucideProps } from 'lucide-react'

export function LinkIcon(props: LucideProps) {
return (
<svg viewBox="0 0 20 20" aria-hidden="true" {...props}>
<path
Expand Down
4 changes: 3 additions & 1 deletion src/components/icons/ListIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export function ListIcon(props: React.ComponentPropsWithoutRef<'svg'>) {
import { LucideProps } from "lucide-react";

export function ListIcon(props: LucideProps) {
return (
<svg viewBox="0 0 20 20" aria-hidden="true" {...props}>
<path
Expand Down
4 changes: 3 additions & 1 deletion src/components/icons/MagnifyingGlassIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { LucideProps } from "lucide-react";

export function MagnifyingGlassIcon(
props: React.ComponentPropsWithoutRef<'svg'>,
props: LucideProps,
) {
return (
<svg viewBox="0 0 20 20" aria-hidden="true" {...props}>
Expand Down
4 changes: 3 additions & 1 deletion src/components/icons/MapPinIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export function MapPinIcon(props: React.ComponentPropsWithoutRef<'svg'>) {
import { LucideProps } from "lucide-react";

export function MapPinIcon(props: LucideProps) {
return (
<svg viewBox="0 0 20 20" aria-hidden="true" {...props}>
<path
Expand Down
4 changes: 3 additions & 1 deletion src/components/icons/PackageIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export function PackageIcon(props: React.ComponentPropsWithoutRef<'svg'>) {
import { LucideProps } from "lucide-react";

export function PackageIcon(props: LucideProps) {
return (
<svg viewBox="0 0 20 20" aria-hidden="true" {...props}>
<path
Expand Down
4 changes: 3 additions & 1 deletion src/components/icons/PaperAirplaneIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { LucideProps } from "lucide-react";

export function PaperAirplaneIcon(
props: React.ComponentPropsWithoutRef<'svg'>,
props: LucideProps,
) {
return (
<svg viewBox="0 0 20 20" aria-hidden="true" {...props}>
Expand Down
4 changes: 3 additions & 1 deletion src/components/icons/PaperClipIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export function PaperClipIcon(props: React.ComponentPropsWithoutRef<'svg'>) {
import { LucideProps } from "lucide-react";

export function PaperClipIcon(props: LucideProps) {
return (
<svg viewBox="0 0 20 20" aria-hidden="true" {...props}>
<path
Expand Down
4 changes: 3 additions & 1 deletion src/components/icons/ShapesIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export function ShapesIcon(props: React.ComponentPropsWithoutRef<'svg'>) {
import { LucideProps } from "lucide-react";

export function ShapesIcon(props: LucideProps) {
return (
<svg viewBox="0 0 20 20" aria-hidden="true" {...props}>
<path
Expand Down
4 changes: 3 additions & 1 deletion src/components/icons/ShirtIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export function ShirtIcon(props: React.ComponentPropsWithoutRef<'svg'>) {
import { LucideProps } from "lucide-react";

export function ShirtIcon(props: LucideProps) {
return (
<svg viewBox="0 0 20 20" aria-hidden="true" {...props}>
<path
Expand Down
4 changes: 3 additions & 1 deletion src/components/icons/SquaresPlusIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export function SquaresPlusIcon(props: React.ComponentPropsWithoutRef<'svg'>) {
import { LucideProps } from "lucide-react";

export function SquaresPlusIcon(props: LucideProps) {
return (
<svg viewBox="0 0 20 20" aria-hidden="true" {...props}>
<path
Expand Down
4 changes: 3 additions & 1 deletion src/components/icons/TagIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export function TagIcon(props: React.ComponentPropsWithoutRef<'svg'>) {
import { LucideProps } from "lucide-react";

export function TagIcon(props: LucideProps) {
return (
<svg viewBox="0 0 20 20" aria-hidden="true" {...props}>
<path
Expand Down
4 changes: 3 additions & 1 deletion src/components/icons/UserIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export function UserIcon(props: React.ComponentPropsWithoutRef<'svg'>) {
import { LucideProps } from "lucide-react";

export function UserIcon(props: LucideProps) {
return (
<svg viewBox="0 0 20 20" aria-hidden="true" {...props}>
<path
Expand Down
4 changes: 3 additions & 1 deletion src/components/icons/UsersIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export function UsersIcon(props: React.ComponentPropsWithoutRef<'svg'>) {
import { LucideProps } from "lucide-react";

export function UsersIcon(props: LucideProps) {
return (
<svg viewBox="0 0 20 20" aria-hidden="true" {...props}>
<path
Expand Down
3 changes: 2 additions & 1 deletion src/components/mdx.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Link from 'next/link'
import clsx from 'clsx'
import { LucideProps } from 'lucide-react'

import { Feedback } from '@/components/Feedback'
import { Heading } from '@/components/Heading'
Expand All @@ -26,7 +27,7 @@ export const h2 = function H2(
return <Heading level={2} {...props} />
}

function InfoIcon(props: React.ComponentPropsWithoutRef<'svg'>) {
function InfoIcon(props: LucideProps) {
return (
<svg viewBox="0 0 16 16" aria-hidden="true" {...props}>
<circle cx="8" cy="8" r="8" strokeWidth="0" />
Expand Down
Loading

0 comments on commit bec78c6

Please sign in to comment.