|
|
@@ -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 ? (
|
|
|
- <MaterialIcon
|
|
|
- className="ide-rail-tab-link-icon"
|
|
|
- type={icon}
|
|
|
- accessibilityLabel={title}
|
|
|
- />
|
|
|
- ) : (
|
|
|
- <MaterialIcon
|
|
|
- className="ide-rail-tab-link-icon"
|
|
|
- type={icon}
|
|
|
- accessibilityLabel={title}
|
|
|
- unfilled
|
|
|
- />
|
|
|
- )}
|
|
|
+ <RailTabIcon icon={icon} title={title} open={open} />
|
|
|
{indicator}
|
|
|
</NavLink>
|
|
|
</OLTooltip>
|
|
|
)
|
|
|
})
|
|
|
|
|
|
+const RailTabIcon = ({
|
|
|
+ icon,
|
|
|
+ title,
|
|
|
+ open,
|
|
|
+}: {
|
|
|
+ icon: RailElement['icon']
|
|
|
+ title: string
|
|
|
+ open: boolean
|
|
|
+}) => {
|
|
|
+ if (typeof icon === 'string') {
|
|
|
+ return open ? (
|
|
|
+ <MaterialIcon
|
|
|
+ type={icon}
|
|
|
+ className="ide-rail-tab-link-icon"
|
|
|
+ accessibilityLabel={title}
|
|
|
+ />
|
|
|
+ ) : (
|
|
|
+ <MaterialIcon
|
|
|
+ type={icon}
|
|
|
+ className="ide-rail-tab-link-icon"
|
|
|
+ unfilled
|
|
|
+ accessibilityLabel={title}
|
|
|
+ />
|
|
|
+ )
|
|
|
+ } else {
|
|
|
+ const Component = icon
|
|
|
+ return <Component open={open} title={title} />
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
RailTab.displayName = 'RailTab'
|
|
|
|
|
|
export default RailTab
|