41 lines
1.7 KiB
TypeScript
41 lines
1.7 KiB
TypeScript
import { IMAGES_AFTER_GROUP, type ApiGroup, type HttpMethod } from '@/data/apiCatalogue'
|
|
|
|
export const SECTION_TITLE = 'text-[1.125rem]/6.5 font-semibold text-highlighted'
|
|
|
|
const CHIP_BASE = 'h-5 gap-1 rounded-none px-1.5 py-0 text-xs whitespace-nowrap ring-0 border'
|
|
|
|
export const CHIP_CLASS = {
|
|
neutral: `${CHIP_BASE} border-accented bg-transparent font-normal text-toned`,
|
|
strong: `${CHIP_BASE} border-accented bg-elevated font-medium text-highlighted`,
|
|
success: `${CHIP_BASE} border-transparent bg-(--rc-success-soft) font-medium text-success`,
|
|
dashed: `${CHIP_BASE} border-dashed border-accented bg-transparent font-normal text-muted`,
|
|
}
|
|
|
|
const METHOD_BASE =
|
|
'h-5.5 w-14 shrink-0 justify-center rounded-none px-0 py-0 font-mono text-xs font-medium ring-0 border'
|
|
|
|
export const SESSION_METHOD_CLASS = `${METHOD_BASE} border-dashed border-accented bg-transparent text-muted`
|
|
|
|
const PATCH_CLASS = `${METHOD_BASE} border-warning bg-(--rc-warning-soft) text-warning`
|
|
|
|
export const METHOD_CLASS: Record<HttpMethod, string> = {
|
|
GET: `${METHOD_BASE} border-inverted bg-inverted text-inverted`,
|
|
POST: `${METHOD_BASE} border-success bg-(--rc-success-soft) text-success`,
|
|
PATCH: PATCH_CLASS,
|
|
PUT: PATCH_CLASS,
|
|
DELETE: `${METHOD_BASE} border-error bg-(--rc-error-soft) text-error`,
|
|
}
|
|
|
|
export function splitInlineCode(text: string) {
|
|
return text.split('`').map((value, index) => ({ value, code: index % 2 === 1 }))
|
|
}
|
|
|
|
export function endpointAnchor(id: string) {
|
|
return `ep-${id}`
|
|
}
|
|
|
|
export function groupsAroundImages(groups: ApiGroup[]) {
|
|
const split = groups.findIndex((group) => group.key === IMAGES_AFTER_GROUP) + 1
|
|
return { before: groups.slice(0, split), after: groups.slice(split) }
|
|
}
|