Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
chore: dry up file type chip component in top bar (#2394)
gbirman4c6bd0bbd674
diff --git a/js/app/packages/block-code/component/CodeFileTypeChip.tsx b/js/app/packages/block-code/component/CodeFileTypeChip.tsxindex 22c156d257..7136adcadb 100644--- a/js/app/packages/block-code/component/CodeFileTypeChip.tsx+++ b/js/app/packages/block-code/component/CodeFileTypeChip.tsx@@ -1,4 +1,5 @@import { useBlockId } from '@core/block';+import { FileTypeChip } from '@core/component/FileTypeChip';import { blockMetadataSignal } from '@core/signal/load';import { useCanEdit } from '@core/signal/permissions';import { Popover } from '@kobalte/core/popover';@@ -74,14 +75,7 @@ export function CodeFileTypeChip() {return (<Show when={fileType()}>- <Show- when={canEdit()}- fallback={- <span class="shrink-0 rounded px-1 py-0.5 text-[0.625rem] font-mono font-medium uppercase leading-none bg-code-bg text-code">- {fileType()}- </span>- }- >+ <Show when={canEdit()} fallback={<FileTypeChip />}><Popoverplacement="bottom-start"open={open()}diff --git a/js/app/packages/block-image/component/TopBar.tsx b/js/app/packages/block-image/component/TopBar.tsxindex 3651791026..8911127621 100644--- a/js/app/packages/block-image/component/TopBar.tsx+++ b/js/app/packages/block-image/component/TopBar.tsx@@ -10,7 +10,7 @@ import { BlockItemSplitLabel } from '@app/component/split-layout/components/Spliimport { useIsAuthenticated } from '@core/auth';import { useBlockId } from '@core/block';-import { blockMetadataSignal } from '@core/signal/load';+import { FileTypeChip } from '@core/component/FileTypeChip';import {ReferencesButton,REFERENCES_DRAWER_ID,@@ -30,18 +30,6 @@ import Download from '@icon/regular/download.svg';import Quotes from '@icon/regular/quotes.svg';import IconShared from '@macro-icons/wide/share.svg';import { createCallback } from '@solid-primitives/rootless';-import { Show } from 'solid-js';--function FileTypeChip() {- const fileType = () => blockMetadataSignal()?.fileType;- return (- <Show when={fileType()}>- <span class="shrink-0 rounded px-1 py-0.5 text-[0.625rem] font-mono font-medium uppercase leading-none bg-image-bg text-image">- {fileType()}- </span>- </Show>- );-}export function TopBar() {const isAuth = useIsAuthenticated();diff --git a/js/app/packages/block-unknown/component/TopBar.tsx b/js/app/packages/block-unknown/component/TopBar.tsxindex 27585305f6..a7fe6d80c0 100644--- a/js/app/packages/block-unknown/component/TopBar.tsx+++ b/js/app/packages/block-unknown/component/TopBar.tsx@@ -10,7 +10,7 @@ import { BlockItemSplitLabel } from '@app/component/split-layout/components/Spliimport { useIsAuthenticated } from '@core/auth';import { useBlockId } from '@core/block';-import { blockMetadataSignal } from '@core/signal/load';+import { FileTypeChip } from '@core/component/FileTypeChip';import {ReferencesButton,REFERENCES_DRAWER_ID,@@ -29,21 +29,9 @@ import DownloadSimple from '@icon/regular/download-simple.svg';import Quotes from '@icon/regular/quotes.svg';import IconShared from '@macro-icons/wide/share.svg';import { createCallback } from '@solid-primitives/rootless';-import { Show } from 'solid-js';import { toast } from 'core/component/Toast/Toast';import { useGetFileBlob } from '../signal/blockData';-function FileTypeChip() {- const fileType = () => blockMetadataSignal()?.fileType;- return (- <Show when={fileType()}>- <span class="shrink-0 rounded px-1 py-0.5 text-[0.625rem] font-mono font-medium uppercase leading-none bg-surface-secondary text-ink-muted">- {fileType()}- </span>- </Show>- );-}-export function TopBar() {const isAuth = useIsAuthenticated();const blockId = useBlockId();diff --git a/js/app/packages/core/component/FileTypeChip.tsx b/js/app/packages/core/component/FileTypeChip.tsxnew file mode 100644index 0000000000..4636d01d2a--- /dev/null+++ b/js/app/packages/core/component/FileTypeChip.tsx@@ -0,0 +1,22 @@+import { useBlockAliasedName } from '@core/block';+import { blockMetadataSignal } from '@core/signal/load';+import { Show } from 'solid-js';+import { ENTITY_ICON_CONFIGS, type EntityWithValidIcon } from './EntityIcon';++export function FileTypeChip() {+ const fileType = () => blockMetadataSignal()?.fileType;+ const blockName = useBlockAliasedName();+ const config = () =>+ ENTITY_ICON_CONFIGS[blockName as EntityWithValidIcon] ??+ ENTITY_ICON_CONFIGS.default;++ return (+ <Show when={fileType()}>+ <span+ class={`shrink-0 rounded px-1 py-0.5 text-[0.625rem] font-mono font-medium uppercase leading-none ${config().background} ${config().foreground}`}+ >+ {fileType()}+ </span>+ </Show>+ );+}