mirror of
https://github.com/modrinth/code.git
synced 2026-08-26 17:44:50 +00:00
* better default state handling
* make next stage button work for going to next project
* fix skill issue
* actually fix initial values this time,
make single line inputs with varying lengths (text input and dropdown) use their widest possible length instead of whatever the hell they used to be
* loaders in progress
* loaders and versions test (probably dont use them as the messages suck and idrk what they should do quick fix/message wise)
* WIP the wip
* good enough for now slug taken improvements
* trim all those extra newlines
* viewedness
* batch prefetch queue + technically slightly faster checklist init
* show all valid alternative project types regardless of current project type
* Hide moderation permissions stage when it should be, and I'm sure this won't cause any issues
* Hide moderation permissions stage when it should be, and I'm sure this won't cause any issues
* gimme them versions
* better moderation permission stage shown check?
* betterer moderation permission stage shown check?
* bettererer moderation permission stage shown check? + also began deleting legacy checklist types
* fix certain stages being able to be considered viewed before being viewed
* more removals + i forgot to remove an import last commit
* changed nothing™️
* remove severities + bandaid post-approval message priorities + dependencies
* fix message preview tooltips
* next stage = next project when done
* insufficient description custom fix
* fix that thing coolbot told me was broken I forgot what it was oops
* oh there was a second bug there
* make alternate versions and incorrect project type required cuz they are
* re-navigate button also damn that's a lot of other stuff that pnpm fix... fixed?
* you cant just quick fix a slug into a taken one
* maybe lets not just try and set a slug to something entirely invalid?
* what if we just didn't drop ur queue :smart:
* more queue upgrades
* tweaks
* I love unbreaking things
* un-nuked renavigate button
* prepr
* prepr worked this time i think
* undo more mistakes
* i love intellij refactoring
* ok i think we're good
198 lines
5.0 KiB
TypeScript
198 lines
5.0 KiB
TypeScript
import {
|
|
ArchiveIcon,
|
|
BoxIcon,
|
|
BracesIcon,
|
|
CalendarIcon,
|
|
CardIcon,
|
|
CheckCircleIcon,
|
|
CircleAlertIcon,
|
|
CurrencyIcon,
|
|
DiscordIcon,
|
|
FileArchiveIcon,
|
|
FileCodeIcon,
|
|
FileIcon,
|
|
FileImageIcon,
|
|
FileTextIcon,
|
|
FolderOpenIcon,
|
|
GithubIcon,
|
|
GlassesIcon,
|
|
GlobeIcon,
|
|
InfoIcon,
|
|
IssuesIcon,
|
|
LinkIcon,
|
|
LockIcon,
|
|
PackageOpenIcon,
|
|
PaintbrushIcon,
|
|
PayPalIcon,
|
|
PlugIcon,
|
|
PolygonIcon,
|
|
ScaleIcon,
|
|
ServerIcon,
|
|
UnknownIcon,
|
|
UpdatedIcon,
|
|
USDCColorIcon,
|
|
XCircleIcon,
|
|
XIcon,
|
|
} from '@modrinth/assets'
|
|
import type { ProjectStatus, ProjectType } from '@modrinth/utils'
|
|
import type { Component } from 'vue'
|
|
|
|
import {
|
|
FILE_ARCHIVE_EXTENSIONS,
|
|
FILE_CODE_EXTENSIONS,
|
|
FILE_IMAGE_EXTENSIONS,
|
|
FILE_TEXT_EXTENSIONS,
|
|
} from './file-extensions'
|
|
|
|
export const PROJECT_TYPE_ICONS: Record<ProjectType, Component> = {
|
|
mod: BoxIcon,
|
|
modpack: PackageOpenIcon,
|
|
resourcepack: PaintbrushIcon,
|
|
shader: GlassesIcon,
|
|
plugin: PlugIcon,
|
|
datapack: BracesIcon,
|
|
project: BoxIcon,
|
|
minecraft_java_server: ServerIcon,
|
|
}
|
|
|
|
export const PAYMENT_METHOD_ICONS: Record<string, Component> = {
|
|
card: CardIcon,
|
|
cashapp: CurrencyIcon,
|
|
paypal: PayPalIcon,
|
|
}
|
|
|
|
export const SOCIAL_PLATFORM_ICONS: Record<string, Component> = {
|
|
discord: DiscordIcon,
|
|
github: GithubIcon,
|
|
}
|
|
|
|
export const SEVERITY_ICONS: Record<string, Component> = {
|
|
info: InfoIcon,
|
|
warning: IssuesIcon,
|
|
error: XCircleIcon,
|
|
critical: XCircleIcon,
|
|
success: CheckCircleIcon,
|
|
moderation: ScaleIcon,
|
|
'circle-warning': CircleAlertIcon,
|
|
}
|
|
|
|
export const PROJECT_STATUS_ICONS: Record<ProjectStatus, Component> = {
|
|
approved: GlobeIcon,
|
|
unlisted: LinkIcon,
|
|
withheld: LinkIcon,
|
|
private: LockIcon,
|
|
scheduled: CalendarIcon,
|
|
draft: FileTextIcon,
|
|
archived: ArchiveIcon,
|
|
rejected: XIcon,
|
|
processing: UpdatedIcon,
|
|
unknown: UnknownIcon,
|
|
}
|
|
|
|
// this should probably be abstracted or something idk
|
|
export type BadgeColor = 'red' | 'orange' | 'green' | 'blue' | 'purple' | 'gray'
|
|
|
|
export const PROJECT_STATUS_COLORS: Record<ProjectStatus, BadgeColor> = {
|
|
approved: 'blue',
|
|
unlisted: 'purple',
|
|
withheld: 'red',
|
|
private: 'gray',
|
|
scheduled: 'orange',
|
|
draft: 'gray',
|
|
archived: 'gray',
|
|
rejected: 'red',
|
|
processing: 'orange',
|
|
unknown: 'gray',
|
|
}
|
|
|
|
export const DIRECTORY_ICONS: Record<string, Component> = {
|
|
config: FolderOpenIcon,
|
|
world: FolderOpenIcon,
|
|
resourcepacks: PaintbrushIcon,
|
|
_default: FolderOpenIcon,
|
|
}
|
|
|
|
const CURRENCY_CONFIG: Record<string, { icon: Component; color: string }> = {
|
|
usdc: { icon: USDCColorIcon, color: 'text-blue' },
|
|
}
|
|
|
|
const BLOCKCHAIN_CONFIG: Record<string, { icon: Component; color: string }> = {
|
|
polygon: { icon: PolygonIcon, color: 'text-purple' },
|
|
}
|
|
|
|
export function getProjectTypeIcon(projectType: ProjectType): Component {
|
|
return PROJECT_TYPE_ICONS[projectType] ?? BoxIcon
|
|
}
|
|
|
|
export function getPaymentMethodIcon(method: string): Component {
|
|
return PAYMENT_METHOD_ICONS[method] ?? UnknownIcon
|
|
}
|
|
|
|
export function getSocialPlatformIcon(platform: string): Component {
|
|
return SOCIAL_PLATFORM_ICONS[platform.toLowerCase()] ?? UnknownIcon
|
|
}
|
|
|
|
export function getSeverityIcon(severity: string): Component {
|
|
return SEVERITY_ICONS[severity] ?? InfoIcon
|
|
}
|
|
|
|
export function getProjectStatusIcon(status: ProjectStatus): Component {
|
|
return PROJECT_STATUS_ICONS[status] ?? UnknownIcon
|
|
}
|
|
|
|
export function getProjectStatusColor(status: ProjectStatus): BadgeColor {
|
|
return PROJECT_STATUS_COLORS[status] ?? `gray`
|
|
}
|
|
|
|
export function getDirectoryIcon(name: string): Component {
|
|
return DIRECTORY_ICONS[name.toLowerCase()] ?? DIRECTORY_ICONS._default
|
|
}
|
|
|
|
export function getFileExtensionIcon(extension: string): Component {
|
|
const ext: string = extension.toLowerCase()
|
|
|
|
if ((FILE_CODE_EXTENSIONS as readonly string[]).includes(ext)) {
|
|
return FileCodeIcon
|
|
}
|
|
if ((FILE_TEXT_EXTENSIONS as readonly string[]).includes(ext)) {
|
|
return FileTextIcon
|
|
}
|
|
if ((FILE_IMAGE_EXTENSIONS as readonly string[]).includes(ext)) {
|
|
return FileImageIcon
|
|
}
|
|
if ((FILE_ARCHIVE_EXTENSIONS as readonly string[]).includes(ext)) {
|
|
return FileArchiveIcon
|
|
}
|
|
|
|
return FileIcon
|
|
}
|
|
|
|
export function getFileIcon(fileName: string): Component {
|
|
const extension = fileName.split('.').pop()?.toLowerCase() || ''
|
|
return getFileExtensionIcon(extension)
|
|
}
|
|
|
|
export function getCurrencyIcon(currency: string): Component | null {
|
|
const lower = currency.toLowerCase()
|
|
const key = Object.keys(CURRENCY_CONFIG).find((k) => lower.includes(k))
|
|
return key ? CURRENCY_CONFIG[key].icon : null
|
|
}
|
|
|
|
export function getCurrencyColor(currency: string): string {
|
|
const lower = currency.toLowerCase()
|
|
const key = Object.keys(CURRENCY_CONFIG).find((k) => lower.includes(k))
|
|
return key ? CURRENCY_CONFIG[key].color : 'text-contrast'
|
|
}
|
|
|
|
export function getBlockchainIcon(blockchain: string): Component | null {
|
|
const lower = blockchain.toLowerCase()
|
|
const key = Object.keys(BLOCKCHAIN_CONFIG).find((k) => lower.includes(k))
|
|
return key ? BLOCKCHAIN_CONFIG[key].icon : null
|
|
}
|
|
|
|
export function getBlockchainColor(blockchain: string): string {
|
|
const lower = blockchain.toLowerCase()
|
|
const key = Object.keys(BLOCKCHAIN_CONFIG).find((k) => lower.includes(k))
|
|
return key ? BLOCKCHAIN_CONFIG[key].color : 'text-contrast'
|
|
}
|