|
| 1 | +import clsx from 'clsx'; |
| 2 | +import useBaseUrl from '@docusaurus/useBaseUrl'; |
| 3 | + |
| 4 | +import styles from './ToolMark.module.css'; |
| 5 | + |
| 6 | +type ToolMarkProps = { |
| 7 | + // Site-relative path to the official mark, e.g. `/img/terminal-logos/ghostty.svg`. |
| 8 | + src: string; |
| 9 | + // Luminance masking for opaque official app-icon compositions: preserves |
| 10 | + // their bright foreground geometry instead of flattening every filled layer. |
| 11 | + luminance?: boolean; |
| 12 | + // Direct rendering preserves official compound/app-icon layer relationships. |
| 13 | + mode?: 'mask' | 'image'; |
| 14 | + // Brightens a dark app-icon foreground without restoring its brand hue. |
| 15 | + imageTone?: 'standard' | 'foreground'; |
| 16 | + // Replaces rasterized app-icon edging with a theme-colored CSS outline. |
| 17 | + imageFrame?: boolean; |
| 18 | + // Dark-theme presentation for official artwork drawn in dark tones: |
| 19 | + // 'lift' raises mid-tone bodies above the dark tile. |
| 20 | + darkImageTone?: 'lift'; |
| 21 | + // Optional asset with colors selected for the dark theme. |
| 22 | + darkSrc?: string; |
| 23 | +}; |
| 24 | + |
| 25 | +// Neutral 48px tile rendering an official tool logo. Decorative only: the |
| 26 | +// adjacent heading text stays the accessible name. |
| 27 | +export default function ToolMark({ |
| 28 | + src, |
| 29 | + luminance = false, |
| 30 | + mode = 'mask', |
| 31 | + imageTone = 'standard', |
| 32 | + imageFrame = false, |
| 33 | + darkImageTone, |
| 34 | + darkSrc, |
| 35 | +}: ToolMarkProps) { |
| 36 | + const url = useBaseUrl(src); |
| 37 | + const darkUrl = useBaseUrl(darkSrc ?? src); |
| 38 | + const imageClass = clsx( |
| 39 | + imageTone === 'foreground' && styles.imageForeground, |
| 40 | + imageFrame && styles.imageFrame, |
| 41 | + darkImageTone === 'lift' && styles.imageDarkLift |
| 42 | + ); |
| 43 | + return ( |
| 44 | + <span |
| 45 | + aria-hidden="true" |
| 46 | + className={clsx(styles.frame, darkSrc && styles.withDarkImage)} |
| 47 | + > |
| 48 | + {mode === 'image' ? ( |
| 49 | + <> |
| 50 | + <img className={clsx(styles.image, imageClass)} src={url} alt="" /> |
| 51 | + {darkSrc && ( |
| 52 | + <img |
| 53 | + className={clsx(styles.darkImage, imageClass)} |
| 54 | + src={darkUrl} |
| 55 | + alt="" |
| 56 | + /> |
| 57 | + )} |
| 58 | + </> |
| 59 | + ) : ( |
| 60 | + <span |
| 61 | + className={clsx(styles.mark, luminance && styles.luminance)} |
| 62 | + style={{ |
| 63 | + maskImage: `url('${url}')`, |
| 64 | + WebkitMaskImage: `url('${url}')`, |
| 65 | + }} |
| 66 | + /> |
| 67 | + )} |
| 68 | + </span> |
| 69 | + ); |
| 70 | +} |
0 commit comments