Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
support string arrays in <Text>
Browse files Browse the repository at this point in the history
  • Loading branch information
Bela Bohlender committed Aug 18, 2023
1 parent 19b0e3c commit 63f27ec
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion docs/components.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ The image renders a 2D plane with an image. The image also has the properties of

## Text

Renders a string into individual glyphs based on a multi-channel signed distance function. The text requires the provision of a FontFamilyProvider. The text also has the properties of the container to render a background.
Renders a string or array of strings into individual glyphs based on a multi-channel signed distance function. The text requires the provision of a FontFamilyProvider. The text also has the properties of the container to render a background.

| Parameter | Description |
| -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@coconut-xr/koestlich",
"version": "0.3.9",
"version": "0.3.10",
"homepage": "https://coconut-xr.github.io/koestlich",
"license": "SEE LICENSE IN LICENSE",
"description": "user interfaces for Three.js",
Expand Down
4 changes: 2 additions & 2 deletions src/components/text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -656,11 +656,11 @@ export function useText(
material,
...props
}: TextProperties & YogaProperties,
children: string | undefined,
children: string | Array<string> | undefined,
): undefined {
const font = useFont(fontFamily);

const text = children ?? textDefaults["children"];
const text = Array.isArray(children) ? children.join("") : children ?? textDefaults["children"];

const glyphProperties = useMemo<GlyphProperties>(
() => ({
Expand Down
4 changes: 2 additions & 2 deletions tests/manual/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ export default function Index() {
fontFamily="roboto"
onClick={() => setBold(!bold)}
>
Coconut XR
Coconut {"XR"}!
</Text>
)}
{!bold && (
Expand All @@ -308,7 +308,7 @@ export default function Index() {
fontFamily="opensans"
onClick={() => setBold(!bold)}
>
Coconut XR
Coconut {"XR"}!
</Text>
)}
</Suspense>
Expand Down

0 comments on commit 63f27ec

Please sign in to comment.