Skip to content
Closed
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
13 changes: 13 additions & 0 deletions gatsby-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,19 @@ export const onCreateWebpackConfig: GatsbyNode['onCreateWebpackConfig'] = ({ sta
constants: path.resolve(__dirname, 'src', 'constants'),
logic: path.resolve(__dirname, 'src', 'logic'),
hooks: path.resolve(__dirname, 'src', 'hooks'),
// Brand hoggie PNGs as plain files, so Gatsby's image loader returns a bundled URL:
// import hedgehogStopPng from 'brand-hoggie-pngs/stop.png'
// The package's own `@posthog/brand/hoggies/png/*` modules resolve to a JS module here.
'brand-hoggie-pngs': path.resolve(
__dirname,
'node_modules',
'@posthog',
'brand',
'dist',
'generated',
'hoggies',
'png'
),
// Mapping
docs: path.resolve(__dirname, '.cache', 'gatsby-source-git', 'posthog-main-repo', 'docs'),
onboarding: path.resolve(
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"@mdx-js/react": "^1.6.22",
"@mdxeditor/editor": "^3.32.3",
"@popperjs/core": "^2.11.2",
"@posthog/brand": "0.13.0",
"@posthog/brand": "0.17.3",
"@posthog/hedgehog-mode": "^0.0.63",
"@posthog/icons": "0.36.6",
"@posthog/quill-charts": "0.3.0-beta.31",
Expand Down
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions scripts/hog-images/make-hog-profile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/zsh
# Rebuild hog-profile.png: @posthog/brand "sitting" hoggie, cropped to a bust, on a #FF906E circle.
# Same format as the old hog-9.png avatar (round, transparent corners), at 400x400.
# Usage (from repo root): zsh scripts/hog-images/make-hog-profile.sh (needs ImageMagick)
set -e
SRC=node_modules/@posthog/brand/dist/generated/hoggies/png/sitting.png
OUT=src/images/hog-profile.png
TMP=$(mktemp -d)
# Crop window, in source pixels (1000x1000 source; negative values reach into transparent padding).
X=-10 Y=-60 S=880 PAD=300
magick -size 400x400 xc:none -fill "#FF906E" -draw "circle 199.5,199.5 199.5,0" $TMP/bg.png
magick $SRC -bordercolor none -border $PAD -crop ${S}x${S}+$((X+PAD))+$((Y+PAD)) +repage -resize 400x400 $TMP/crop.png
magick -size 400x400 xc:black -fill white -draw "circle 199.5,199.5 199.5,0" $TMP/mask.png
magick $TMP/bg.png $TMP/crop.png -composite $TMP/mask.png -alpha off -compose CopyOpacity -composite -strip -define png:compression-level=9 $OUT
rm -rf $TMP
magick identify $OUT
9 changes: 2 additions & 7 deletions src/components/Academy/PostQuote.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react'
import CloudinaryImage from 'components/CloudinaryImage'
import { graphql, useStaticQuery } from 'gatsby'
import Link from 'components/Link'
import slugify from 'slugify'
import hogProfile from '../../images/hog-profile.png'

interface PostQuoteProps {
title?: string
Expand Down Expand Up @@ -90,12 +90,7 @@ const PostQuote: React.FC<PostQuoteProps> = ({
className="size-24"
/>
) : (
<CloudinaryImage
alt=""
width={24}
src="https://res.cloudinary.com/dmukukwp6/image/upload/posthog.com/src/pages-content/images/hog-9.png"
className="size-24"
/>
<img src={hogProfile} alt="" className="size-24" />
)}
</div>
</div>
Expand Down
9 changes: 2 additions & 7 deletions src/components/Careers/MegaQuote/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import CloudinaryImage from 'components/CloudinaryImage'
import React from 'react'
import Tooltip from 'components/Tooltip'
import { graphql, useStaticQuery } from 'gatsby'
Expand All @@ -10,6 +9,7 @@ import { IconCake } from '@posthog/icons'
import dayjs from 'dayjs'
import slugify from 'slugify'
import Link from 'components/Link'
import hogProfile from '../../../images/hog-profile.png'

const TeamMemberLink = (person) => {
const { firstName, lastName, country, startDate, pineappleOnPizza, squeakId, avatar, teams, leadTeams, color } =
Expand All @@ -35,12 +35,7 @@ const TeamMemberLink = (person) => {
className="size-24"
/>
) : (
<CloudinaryImage
alt=""
width={24}
src="https://res.cloudinary.com/dmukukwp6/image/upload/posthog.com/src/pages-content/images/hog-9.png"
className="size-24"
/>
<img src={hogProfile} alt="" className="size-24" />
)}
</div>
</div>
Expand Down
9 changes: 2 additions & 7 deletions src/components/Careers/TeamQuotes/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import CloudinaryImage from 'components/CloudinaryImage'
import React from 'react'
import { graphql, useStaticQuery } from 'gatsby'
import { StaticImage } from 'gatsby-plugin-image'
import Stickers from 'components/ProfileStickers'
import slugify from 'slugify'
import Link from 'components/Link'
import Masonry from 'react-masonry-css'
import hogProfile from '../../../images/hog-profile.png'

const TeamMemberLink = (person) => {
const {
Expand Down Expand Up @@ -54,12 +54,7 @@ const TeamMemberLink = (person) => {
className={`size-20 ${color ? `bg-${color}` : 'bg-orange'}`}
/>
) : (
<CloudinaryImage
alt=""
width={20}
src="https://res.cloudinary.com/dmukukwp6/image/upload/posthog.com/src/pages-content/images/hog-9.png"
className="size-20 bg-orange"
/>
<img src={hogProfile} alt="" className="size-20 bg-orange" />
)}
</Link>
</div>
Expand Down
46 changes: 29 additions & 17 deletions src/components/CloudinaryImage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,40 @@ export default function CloudinaryImage({
objectPosition,
...other
}: {
src: `https://res.cloudinary.com/${string}`
/** A Cloudinary URL, or a bundled image URL (an imported file). */
src: string
width?: number
className?: string
imgClassName?: string
objectFit?: 'cover' | 'contain'
objectPosition?: 'top' | 'bottom' | 'left' | 'right' | 'center'
} & React.ImgHTMLAttributes<HTMLImageElement>): JSX.Element {
const cloudinaryPublicId = isCloudinaryImage(src) && getCloudinaryPublicId(src)
const isCloudinary = isCloudinaryImage(src)
const cloudinaryPublicId = isCloudinary && getCloudinaryPublicId(src)
const hasCommas = src?.includes(',')
return cloudinaryPublicId && !hasCommas ? (
<div className={`inline-block ${className}`}>
<Image
{...other}
publicId={cloudinaryPublicId}
cloudName={process.env.GATSBY_CLOUDINARY_CLOUD_NAME}
className={imgClassName}
secure
>
{width && <Transformation width={width} crop="scale" />}
</Image>
</div>
) : (
<img src={src} width={width} className={`inline-block ${imgClassName}`} {...other} />
)
if (cloudinaryPublicId && !hasCommas) {
return (
<div className={`inline-block ${className}`}>
<Image
{...other}
publicId={cloudinaryPublicId}
cloudName={process.env.GATSBY_CLOUDINARY_CLOUD_NAME}
className={imgClassName}
secure
>
{width && <Transformation width={width} crop="scale" />}
</Image>
</div>
)
}
// A bundled file (for example a brand hoggie PNG) lays out like a Cloudinary image: the same
// wrapper and classes, with `width` as the display width Cloudinary would have scaled to.
if (!isCloudinary) {
return (
<div className={`inline-block ${className}`}>
<img src={src} width={width} className={imgClassName} {...other} />
</div>
)
}
return <img src={src} width={width} className={`inline-block ${imgClassName}`} {...other} />
}
2 changes: 1 addition & 1 deletion src/components/Hogpedia/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ In the body, use Markdown plus two components:

**Never `import * as` from `@posthog/brand/hoggies`.** An article names its hog as a string, so the component is looked up at run time – but a namespace import defeats tree-shaking and pulls all 130-odd illustrations into every page that renders one. Each one inlines its own SVG path data, on the order of 240 KB of module source. That added about 8 MB of JavaScript before `hogs.ts` existed. To use a new illustration in an infobox, add a named import and an entry to the `HOGS` registry in `src/components/Hogpedia/hogs.ts`.

The Main Page's "Featured hog" rotates through the same registry for the same reason, so it adds no weight. Widening it to the whole library needs the illustrations served as images rather than inlined: `@posthog/brand/hoggies/png` exports URLs that would be free, but Gatsby's webpack rules turn the referenced file into a JS module and the package's own `new URL()` resolves to that module instead of the image, so it needs a webpack asset rule first.
The Main Page's "Featured hog" rotates through the same registry for the same reason, so it adds no weight. Widening it to the whole library needs the illustrations served as images rather than inlined: the package's own `@posthog/brand/hoggies/png` exports don't work here, because Gatsby's webpack rules turn the referenced file into a JS module and the package's `new URL()` resolves to that module instead of the image. Import the files through the `brand-hoggie-pngs` alias (set in `gatsby-node.ts`) instead, for example `import url from 'brand-hoggie-pngs/chart.png'`, which returns a plain image URL.

**Centre illustrations with auto margins, not `text-align`.** Tailwind's preflight sets `img, svg { display: block }` site-wide, so `text-align: center` on a container does nothing to the image inside it.

Expand Down
13 changes: 6 additions & 7 deletions src/components/Products/Slides/VideosSlide.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import SmallTeam from 'components/SmallTeam'
import { useToast } from '../../../context/Toast'
import OSButton from 'components/OSButton'
import { Link, graphql, useStaticQuery } from 'gatsby'
import hogProfile from '../../../images/hog-profile.png'

interface VideoChapter {
title: string
Expand Down Expand Up @@ -411,13 +412,11 @@ function AuthorInfo({ name }: { name: string }) {
</Link>
) : (
<Link to={`/community/profiles/${person.squeakId}`} state={{ newWindow: true }}>
<CloudinaryImage
src="https://res.cloudinary.com/dmukukwp6/image/upload/posthog.com/src/pages-content/images/hog-9.png"
alt={fullName}
className={`size-16 rounded-full overflow-hidden border-2 border-${color} p-[1.5px]`}
imgClassName={`object-cover rounded-full bg-${color}`}
width={80}
/>
<div
className={`inline-block size-16 rounded-full overflow-hidden border-2 border-${color} p-[1.5px]`}
>
<img src={hogProfile} alt={fullName} className={`object-cover rounded-full bg-${color}`} />
</div>
</Link>
)}
<div className="text-left">
Expand Down
3 changes: 2 additions & 1 deletion src/components/Squeak/components/Question.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import ReportSpamButton from './ReportSpamButton'
import OSButton from 'components/OSButton'
import { useToast } from '../../../context/Toast'
import { useWindow } from '../../../context/Window'
import hogProfile from '../../../images/hog-profile.png'

type QuestionProps = {
// TODO: Deal with id possibly being undefined at first
Expand Down Expand Up @@ -88,7 +89,7 @@ const MaxReply = ({ children, isInForum }: { children: React.ReactNode; isInForu
<div className="mr-2 relative">
<Avatar
className={` ${isInForum ? 'size-8' : 'w-[25px] h-[25px]'} rounded-full`}
image="https://res.cloudinary.com/dmukukwp6/image/upload/v1688579513/thumbnail_max_c5dd553db8.png"
image={hogProfile}
/>
<span className="absolute -right-1.5 -bottom-2 h-[20px] w-[20px] flex items-center justify-center rounded-full bg-white text-primary dark:text-primary-dark">
<Logo layout="logomark" className="w-[16px]" />
Expand Down
25 changes: 4 additions & 21 deletions src/components/TeamMember/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import CloudinaryImage from 'components/CloudinaryImage'
import Tooltip from 'components/Tooltip'
import { graphql, useStaticQuery } from 'gatsby'
import React from 'react'
import ReactCountryFlag from 'react-country-flag'
import { Link } from 'gatsby'
import hogProfile from '../../images/hog-profile.png'

const PHOTO_AVATAR_SIZE = 'size-4 [:is(h1,h2,h3,h4,h5,h6)_&]:size-6'
const PHOTO_NAME_SIZE = '!text-[13px] !leading-none [:is(h1,h2,h3,h4,h5,h6)_&]:!text-sm'
Expand Down Expand Up @@ -55,13 +55,7 @@ export const TeamMemberLink = ({
className={`${PHOTO_AVATAR_SIZE} bg-${color ? color : 'red'}`}
/>
) : (
<CloudinaryImage
alt=""
width={40}
src="https://res.cloudinary.com/dmukukwp6/image/upload/posthog.com/src/pages-content/images/hog-9.png"
className={`${PHOTO_AVATAR_SIZE} bg-red`}
imgClassName={PHOTO_AVATAR_SIZE}
/>
<img src={hogProfile} alt="" className={`${PHOTO_AVATAR_SIZE} bg-red`} />
)}
</span>
<span className={`${PHOTO_NAME_SIZE} hover:underline font-semibold inline-block truncate`}>
Expand All @@ -86,13 +80,7 @@ export const TeamMemberLink = ({
className={`${PHOTO_AVATAR_SIZE} bg-${color ? color : 'red'}`}
/>
) : (
<CloudinaryImage
alt=""
width={40}
src="https://res.cloudinary.com/dmukukwp6/image/upload/posthog.com/src/pages-content/images/hog-9.png"
className={`${PHOTO_AVATAR_SIZE} bg-red`}
imgClassName={PHOTO_AVATAR_SIZE}
/>
<img src={hogProfile} alt="" className={`${PHOTO_AVATAR_SIZE} bg-red`} />
)}
</span>
<span className={`${PHOTO_NAME_SIZE} hover:underline font-semibold inline-block truncate`}>
Expand All @@ -119,12 +107,7 @@ export const TeamMemberLink = ({
</div>
) : (
<div className="inline-block size-24 bg-yellow rounded-full overflow-hidden p-1 border border-primary">
<CloudinaryImage
alt=""
width={100}
src="https://res.cloudinary.com/dmukukwp6/image/upload/posthog.com/src/pages-content/images/hog-9.png"
className="w-24"
/>
<img src={hogProfile} alt="" className="w-24" />
</div>
)}
<strong className="text-[15px] mt-1">{displayName}</strong>
Expand Down
5 changes: 3 additions & 2 deletions src/hooks/useInkeepSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { InkeepAIChatSettings, InkeepBaseSettings } from '@inkeep/cxkit-rea
import { useValues } from 'kea'
import { layoutLogic } from 'logic/layoutLogic'
import { useEffect, useState } from 'react'
import hogProfile from '../images/hog-profile.png'
type InkeepSharedSettings = {
baseSettings: InkeepBaseSettings
aiChatSettings: InkeepAIChatSettings
Expand Down Expand Up @@ -422,8 +423,8 @@ gap: .5rem;

const defaultAiChatSettings: InkeepAIChatSettings = {
aiAssistantAvatar: {
light: 'https://res.cloudinary.com/dmukukwp6/image/upload/v1688579513/max_c5dd553db8.png',
dark: 'https://res.cloudinary.com/dmukukwp6/image/upload/v1688579513/max_c5dd553db8.png',
light: hogProfile,
dark: hogProfile,
},
aiAssistantName: 'PostHog AI',
isFirstExampleQuestionHighlighted: false,
Expand Down
Binary file added src/images/hog-profile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading