Files
orca/mobile/src/components/MobileSyntaxSegments.tsx
T
2026-06-08 17:41:27 -07:00

46 lines
1.0 KiB
TypeScript

import { StyleSheet, Text, type TextStyle } from 'react-native'
import type { MobileSyntaxSegment, MobileSyntaxTokenKind } from '../session/mobile-file-syntax'
import { colors } from '../theme/mobile-theme'
export function MobileSyntaxSegments({ segments }: { segments: MobileSyntaxSegment[] }) {
return (
<>
{segments.map((segment, index) => (
<Text key={`${index}:${segment.kind}`} style={syntaxTokenStyles[segment.kind]}>
{segment.text}
</Text>
))}
</>
)
}
const syntaxTokenStyles: Record<MobileSyntaxTokenKind, TextStyle> = StyleSheet.create({
plain: {
color: colors.textPrimary
},
comment: {
color: colors.syntaxComment
},
keyword: {
color: colors.syntaxKeyword
},
string: {
color: colors.syntaxString
},
number: {
color: colors.syntaxNumber
},
type: {
color: colors.syntaxType
},
function: {
color: colors.syntaxFunction
},
variable: {
color: colors.syntaxVariable
},
meta: {
color: colors.syntaxMeta
}
})