import {Flex, Text} from '@sanity/ui'
import type {ConceptStatusMarker} from '../../core/publicationStatus'
/**
* Studio draws these with `RingIcon` and `CircleSmallIcon` from its own
* `temporary-icons/` folder, whose files carry the header
* `THIS FILE IS TEMPORARY - IMPORT FROM @SANITY/ICONS WHEN AVAILABLE`. Neither
* is exported from `sanity`, and neither exists in `@sanity/icons` yet — so the
* geometry is copied here rather than imported from something marked for
* deletion. `@sanity/icons` has no near match: `CircleIcon` is r=8 against the
* ring's r=2.9. Swap both out when they ship.
*/
const VIEW_BOX = '0 0 25 25'
function DraftRingGlyph(props: {style?: React.CSSProperties}) {
return (
)
}
function PublishedDotGlyph(props: {style?: React.CSSProperties}) {
return (
)
}
/**
* The badge dot colors from the `@sanity/ui` theme, the same variables Studio's
* own indicator sets. Taking the tokens rather than hex values means the dots
* follow the theme into dark mode without us tracking either palette.
*
* Set on the glyph itself, not an ancestor: `Text` declares its own color, so a
* color further up would be overridden before `currentColor` resolved.
*/
const MARKER_STYLE: Record = {
draft: {color: 'var(--card-badge-caution-dot-color)'},
published: {color: 'var(--card-badge-positive-dot-color)'},
}
/** What each combination means, said once for assistive technology. */
const MARKER_LABELS: Record = {
'draft,published': 'Published, with unpublished changes',
published: 'Published',
draft: 'Not published',
}
/**
* #### Concept Status Markers
* The publication dots beside a row: a caution ring for a draft, a positive dot
* for a published version, in that order.
*
* Which dots to draw is decided in `core/publicationStatus`; this draws them.
* Each sits in a fixed-width slot so rows with different states keep their
* labels and actions on the same vertical edges, and the glyphs are sized by
* `Text size={2}` — the row label's size — rather than by a measurement of ours.
* A derived width is what went wrong in the row-layout pass, and jsdom cannot
* check one.
*/
export function ConceptStatusMarkers({markers}: {markers: readonly ConceptStatusMarker[]}) {
if (markers.length === 0) return null
return (
{markers.map((marker) => (
{marker === 'draft' ? (
) : (
)}
))}
)
}