mirror of
https://github.com/kennethnym/aris.git
synced 2026-03-20 17:11:17 +00:00
Introduce Button.Icon to enforce consistent icon styling (size, theme-aware color) instead of hardcoding Feather props at each call site. Update showcase and json-render registry to use it. Co-authored-by: Ona <no-reply@ona.com>
40 lines
1.5 KiB
TypeScript
40 lines
1.5 KiB
TypeScript
import { defineRegistry } from "@json-render/react-native"
|
|
import { View } from "react-native"
|
|
import tw from "twrnc"
|
|
|
|
import { Button } from "@/components/ui/button"
|
|
import { FeedCard } from "@/components/ui/feed-card"
|
|
import { MonospaceText } from "@/components/ui/monospace-text"
|
|
import { SansSerifText } from "@/components/ui/sans-serif-text"
|
|
import { SerifText } from "@/components/ui/serif-text"
|
|
|
|
import { catalog } from "./catalog"
|
|
|
|
type ButtonIconName = React.ComponentProps<typeof Button.Icon>["name"]
|
|
|
|
export const { registry } = defineRegistry(catalog, {
|
|
components: {
|
|
View: ({ props, children }) => <View style={props.style ? tw`${props.style}` : undefined}>{children}</View>,
|
|
Button: ({ props, emit }) => (
|
|
<Button
|
|
label={props.label}
|
|
leadingIcon={props.leadingIcon ? <Button.Icon name={props.leadingIcon as ButtonIconName} /> : undefined}
|
|
trailingIcon={props.trailingIcon ? <Button.Icon name={props.trailingIcon as ButtonIconName} /> : undefined}
|
|
onPress={() => emit("press")}
|
|
/>
|
|
),
|
|
FeedCard: ({ props, children }) => (
|
|
<FeedCard style={props.style ? tw`${props.style}` : undefined}>{children}</FeedCard>
|
|
),
|
|
SansSerifText: ({ props }) => (
|
|
<SansSerifText style={props.style ? tw`${props.style}` : undefined}>{props.text}</SansSerifText>
|
|
),
|
|
SerifText: ({ props }) => (
|
|
<SerifText style={props.style ? tw`${props.style}` : undefined}>{props.text}</SerifText>
|
|
),
|
|
MonospaceText: ({ props }) => (
|
|
<MonospaceText style={props.style ? tw`${props.style}` : undefined}>{props.text}</MonospaceText>
|
|
),
|
|
},
|
|
})
|