From f2a05b1a2ef42b06e151bd3f97d35b491d204156 Mon Sep 17 00:00:00 2001 From: Mathias Jakobsen Date: Fri, 21 Nov 2025 11:23:19 +0000 Subject: [PATCH] Merge pull request #29793 from overleaf/mj-custom-rail-icon [web] Add custom sparkles icon for workbench rail tab GitOrigin-RevId: b332c90532e75b41b494906e021bcb49ff358024 --- .../ide-redesign/components/rail/rail-tab.tsx | 52 ++++++++++++------- .../features/ide-redesign/utils/rail-types.ts | 6 ++- .../stylesheets/pages/editor/rail.scss | 6 +++ 3 files changed, 44 insertions(+), 20 deletions(-) diff --git a/services/web/frontend/js/features/ide-redesign/components/rail/rail-tab.tsx b/services/web/frontend/js/features/ide-redesign/components/rail/rail-tab.tsx index 9798c70926..11478e8a5e 100644 --- a/services/web/frontend/js/features/ide-redesign/components/rail/rail-tab.tsx +++ b/services/web/frontend/js/features/ide-redesign/components/rail/rail-tab.tsx @@ -1,15 +1,14 @@ import OLTooltip from '@/shared/components/ol/ol-tooltip' -import MaterialIcon, { - AvailableUnfilledIcon, -} from '@/shared/components/material-icon' +import MaterialIcon from '@/shared/components/material-icon' import classNames from 'classnames' import { forwardRef, ReactElement } from 'react' import { NavLink } from 'react-bootstrap' +import { RailElement } from '../../utils/rail-types' const RailTab = forwardRef< HTMLAnchorElement, { - icon: AvailableUnfilledIcon + icon: RailElement['icon'] eventKey: string open: boolean indicator?: ReactElement @@ -31,26 +30,43 @@ const RailTab = forwardRef< })} disabled={disabled} > - {open ? ( - - ) : ( - - )} + {indicator} ) }) +const RailTabIcon = ({ + icon, + title, + open, +}: { + icon: RailElement['icon'] + title: string + open: boolean +}) => { + if (typeof icon === 'string') { + return open ? ( + + ) : ( + + ) + } else { + const Component = icon + return + } +} + RailTab.displayName = 'RailTab' export default RailTab diff --git a/services/web/frontend/js/features/ide-redesign/utils/rail-types.ts b/services/web/frontend/js/features/ide-redesign/utils/rail-types.ts index 9963027a52..3d8e0d1f48 100644 --- a/services/web/frontend/js/features/ide-redesign/utils/rail-types.ts +++ b/services/web/frontend/js/features/ide-redesign/utils/rail-types.ts @@ -1,9 +1,11 @@ import { AvailableUnfilledIcon } from '@/shared/components/material-icon' import { RailTabKey } from '../contexts/rail-context' -import { ReactElement } from 'react' +import { FC, ReactElement } from 'react' + +export type CustomRailTabIcon = FC<{ open: boolean; title: string }> export type RailElement = { - icon: AvailableUnfilledIcon + icon: AvailableUnfilledIcon | CustomRailTabIcon key: RailTabKey component: ReactElement | null indicator?: ReactElement diff --git a/services/web/frontend/stylesheets/pages/editor/rail.scss b/services/web/frontend/stylesheets/pages/editor/rail.scss index cd95996120..2d777ed155 100644 --- a/services/web/frontend/stylesheets/pages/editor/rail.scss +++ b/services/web/frontend/stylesheets/pages/editor/rail.scss @@ -93,6 +93,12 @@ body { font-size: 20px; } + .ide-rail-tab-img-icon { + width: 20px; + max-height: 32px; + object-fit: contain; + } + &.open-rail { color: var(--ide-rail-link-active-color); background-color: var(--ide-rail-link-active-background);