diff --git a/gatsby-node.ts b/gatsby-node.ts index b2fdba70409b..9c667f0577d5 100644 --- a/gatsby-node.ts +++ b/gatsby-node.ts @@ -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( diff --git a/package.json b/package.json index db5d97f61c62..497ae65d8bf6 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ed60e251da40..be5de52af182 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -72,8 +72,8 @@ importers: specifier: ^2.11.2 version: 2.11.8 '@posthog/brand': - specifier: 0.13.0 - version: 0.13.0(react@18.3.1) + specifier: 0.17.3 + version: 0.17.3(react@18.3.1) '@posthog/hedgehog-mode': specifier: ^0.0.63 version: 0.0.63(prop-types@15.8.1)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) @@ -3664,8 +3664,8 @@ packages: '@poppinss/exception@1.2.3': resolution: {integrity: sha512-dCED+QRChTVatE9ibtoaxc+WkdzOSjYTKi/+uacHWIsfodVfpsueo3+DKpgU5Px8qXjgmXkSvhXvSCz3fnP9lw==} - '@posthog/brand@0.13.0': - resolution: {integrity: sha512-9QP+SIqv9xmVph/kr3EnCEkth8MX5EC2y0+e13i1emeJjFflTnBLKB7HOt500f9aPAIOEUXlHWMk2PJscdaCuA==} + '@posthog/brand@0.17.3': + resolution: {integrity: sha512-s3x3W18+T9ZlDe7qqAVhACehWmHZFpiEVEmO06iPm7loN4dHpDw6nFc69wV8HohaHJLKYNpfoW9mMdDLkN+dsg==} engines: {node: '>=22.18'} peerDependencies: react: '>=18' @@ -21740,7 +21740,7 @@ snapshots: '@poppinss/exception@1.2.3': {} - '@posthog/brand@0.13.0(react@18.3.1)': + '@posthog/brand@0.17.3(react@18.3.1)': optionalDependencies: react: 18.3.1 diff --git a/scripts/hog-images/make-hog-profile.sh b/scripts/hog-images/make-hog-profile.sh new file mode 100644 index 000000000000..8d7e3846ba0b --- /dev/null +++ b/scripts/hog-images/make-hog-profile.sh @@ -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 diff --git a/src/components/Academy/PostQuote.tsx b/src/components/Academy/PostQuote.tsx index 03d32f5e45fc..c20d10f84898 100644 --- a/src/components/Academy/PostQuote.tsx +++ b/src/components/Academy/PostQuote.tsx @@ -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 @@ -90,12 +90,7 @@ const PostQuote: React.FC = ({ className="size-24" /> ) : ( - + )} diff --git a/src/components/Careers/MegaQuote/index.tsx b/src/components/Careers/MegaQuote/index.tsx index b83b9540dbe9..8a7f3773b68d 100644 --- a/src/components/Careers/MegaQuote/index.tsx +++ b/src/components/Careers/MegaQuote/index.tsx @@ -1,4 +1,3 @@ -import CloudinaryImage from 'components/CloudinaryImage' import React from 'react' import Tooltip from 'components/Tooltip' import { graphql, useStaticQuery } from 'gatsby' @@ -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 } = @@ -35,12 +35,7 @@ const TeamMemberLink = (person) => { className="size-24" /> ) : ( - + )} diff --git a/src/components/Careers/TeamQuotes/index.tsx b/src/components/Careers/TeamQuotes/index.tsx index 5daf5ea1d846..8d225968470c 100644 --- a/src/components/Careers/TeamQuotes/index.tsx +++ b/src/components/Careers/TeamQuotes/index.tsx @@ -1,4 +1,3 @@ -import CloudinaryImage from 'components/CloudinaryImage' import React from 'react' import { graphql, useStaticQuery } from 'gatsby' import { StaticImage } from 'gatsby-plugin-image' @@ -6,6 +5,7 @@ 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 { @@ -54,12 +54,7 @@ const TeamMemberLink = (person) => { className={`size-20 ${color ? `bg-${color}` : 'bg-orange'}`} /> ) : ( - + )} diff --git a/src/components/CloudinaryImage/index.tsx b/src/components/CloudinaryImage/index.tsx index 9ed81d592691..390e66f0612a 100644 --- a/src/components/CloudinaryImage/index.tsx +++ b/src/components/CloudinaryImage/index.tsx @@ -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): JSX.Element { - const cloudinaryPublicId = isCloudinaryImage(src) && getCloudinaryPublicId(src) + const isCloudinary = isCloudinaryImage(src) + const cloudinaryPublicId = isCloudinary && getCloudinaryPublicId(src) const hasCommas = src?.includes(',') - return cloudinaryPublicId && !hasCommas ? ( -
- - {width && } - -
- ) : ( - - ) + if (cloudinaryPublicId && !hasCommas) { + return ( +
+ + {width && } + +
+ ) + } + // 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 ( +
+ +
+ ) + } + return } diff --git a/src/components/Hogpedia/README.md b/src/components/Hogpedia/README.md index 859bc8df6f38..02b86231b175 100644 --- a/src/components/Hogpedia/README.md +++ b/src/components/Hogpedia/README.md @@ -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. diff --git a/src/components/Products/Slides/VideosSlide.tsx b/src/components/Products/Slides/VideosSlide.tsx index 6ee2e90799e4..0e80ea8ce40c 100644 --- a/src/components/Products/Slides/VideosSlide.tsx +++ b/src/components/Products/Slides/VideosSlide.tsx @@ -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 @@ -411,13 +412,11 @@ function AuthorInfo({ name }: { name: string }) { ) : ( - +
+ {fullName} +
)}
diff --git a/src/components/Squeak/components/Question.tsx b/src/components/Squeak/components/Question.tsx index cf8b4ac42a0c..00926abc017e 100644 --- a/src/components/Squeak/components/Question.tsx +++ b/src/components/Squeak/components/Question.tsx @@ -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 @@ -88,7 +89,7 @@ const MaxReply = ({ children, isInForum }: { children: React.ReactNode; isInForu
diff --git a/src/components/TeamMember/index.tsx b/src/components/TeamMember/index.tsx index 5d019272d614..521b3e3de0d2 100644 --- a/src/components/TeamMember/index.tsx +++ b/src/components/TeamMember/index.tsx @@ -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' @@ -55,13 +55,7 @@ export const TeamMemberLink = ({ className={`${PHOTO_AVATAR_SIZE} bg-${color ? color : 'red'}`} /> ) : ( - + )} @@ -86,13 +80,7 @@ export const TeamMemberLink = ({ className={`${PHOTO_AVATAR_SIZE} bg-${color ? color : 'red'}`} /> ) : ( - + )} @@ -119,12 +107,7 @@ export const TeamMemberLink = ({
) : (
- +
)} {displayName} diff --git a/src/hooks/useInkeepSettings.ts b/src/hooks/useInkeepSettings.ts index 5a9da1f73341..2d6f146c5bb7 100644 --- a/src/hooks/useInkeepSettings.ts +++ b/src/hooks/useInkeepSettings.ts @@ -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 @@ -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, diff --git a/src/images/hog-profile.png b/src/images/hog-profile.png new file mode 100644 index 000000000000..c57254fa80ba Binary files /dev/null and b/src/images/hog-profile.png differ