refactor(files): the provider marks and the map that keys them live apart

The marks module exports components only, so fast refresh keeps it whole and react-refresh no longer counts it; the map by provider id moves to documentProviderIconMap.ts, which every caller now imports.
This commit is contained in:
Maurice
2026-10-25 11:24:36 +01:00
parent dcfbf89234
commit c33eb5b593
11 changed files with 36 additions and 24 deletions
@@ -13,7 +13,7 @@
import { describe, it, expect } from 'vitest'
import { DOCUMENT_PROVIDER_IDS } from '@trek/shared'
import { render } from '../../../tests/helpers/render'
import { DOCUMENT_PROVIDER_ICONS } from './DocumentProviderIcons'
import { DOCUMENT_PROVIDER_ICONS } from './documentProviderIconMap'
import TrekIcon from './TrekIcon'
const marks = Object.entries(DOCUMENT_PROVIDER_ICONS)
@@ -15,7 +15,7 @@ import React from 'react'
* for legibility in a monochrome row.
*/
interface GlyphProps {
export interface GlyphProps {
size?: number
className?: string
}
@@ -34,7 +34,7 @@ function frame(size: number, className: string | undefined) {
}
/** Paperless-ngx: the leaf, with the shoot curling out of its stem. */
function PaperlessIcon({ size = 20, className }: GlyphProps): React.ReactElement {
export function PaperlessIcon({ size = 20, className }: GlyphProps): React.ReactElement {
return (
<svg {...frame(size, className)}>
<path
@@ -64,7 +64,7 @@ function PaperlessIcon({ size = 20, className }: GlyphProps): React.ReactElement
}
/** Papra: a sheet with a folded corner and its lines of text. */
function PapraIcon({ size = 20, className }: GlyphProps): React.ReactElement {
export function PapraIcon({ size = 20, className }: GlyphProps): React.ReactElement {
return (
<svg {...frame(size, className)}>
<path
@@ -87,7 +87,7 @@ function PapraIcon({ size = 20, className }: GlyphProps): React.ReactElement {
}
/** Nextcloud: the three rings. */
function NextcloudIcon({ size = 20, className }: GlyphProps): React.ReactElement {
export function NextcloudIcon({ size = 20, className }: GlyphProps): React.ReactElement {
return (
<svg {...frame(size, className)}>
<circle cx="256" cy="256" r="97" stroke="currentColor" strokeWidth="42" />
@@ -98,7 +98,7 @@ function NextcloudIcon({ size = 20, className }: GlyphProps): React.ReactElement
}
/** OpenCloud: the open hexagon with the junction inside it. */
function OpenCloudIcon({ size = 20, className }: GlyphProps): React.ReactElement {
export function OpenCloudIcon({ size = 20, className }: GlyphProps): React.ReactElement {
return (
<svg {...frame(size, className)}>
<path d="M26 128 256 8l230 120v72L256 80 26 200z" fill="currentColor" />
@@ -112,7 +112,7 @@ function OpenCloudIcon({ size = 20, className }: GlyphProps): React.ReactElement
}
/** Synology Drive: the wordmark's own glyph, as the addon list already draws it. */
function SynologyDriveIcon({ size = 20, className }: GlyphProps): React.ReactElement {
export function SynologyDriveIcon({ size = 20, className }: GlyphProps): React.ReactElement {
return (
<svg
width={className ? undefined : size}
@@ -126,12 +126,3 @@ function SynologyDriveIcon({ size = 20, className }: GlyphProps): React.ReactEle
</svg>
)
}
/** Keyed by the provider ids in `document_providers`. */
export const DOCUMENT_PROVIDER_ICONS: Record<string, React.ComponentType<GlyphProps>> = {
paperless: PaperlessIcon,
papra: PapraIcon,
nextcloud: NextcloudIcon,
opencloud: OpenCloudIcon,
synologydrive: SynologyDriveIcon,
}
@@ -0,0 +1,21 @@
import type React from 'react';
import {
type GlyphProps,
NextcloudIcon,
OpenCloudIcon,
PaperlessIcon,
PapraIcon,
SynologyDriveIcon,
} from './DocumentProviderIcons';
/**
* The document providers' marks keyed by the provider ids in `document_providers`.
* Kept apart from the drawings so that module exports components only.
*/
export const DOCUMENT_PROVIDER_ICONS: Record<string, React.ComponentType<GlyphProps>> = {
paperless: PaperlessIcon,
papra: PapraIcon,
nextcloud: NextcloudIcon,
opencloud: OpenCloudIcon,
synologydrive: SynologyDriveIcon,
};