Skip to content

Commit 2090b96

Browse files
docs: Tweaked the docs redesign so that it actually looks pretty
1 parent 7d40980 commit 2090b96

18 files changed

+166
-140
lines changed

packages/react/xr/plugins/pretty-md.mjs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,21 @@ export const load = (app) => {
6161
// Replace types that return a promise and react component with a code block so that mdx will parse
6262
page.contents = page.contents.replace(/(Promise<.*>)/g, '`$1`')
6363
// Replace Parameters with props for components
64-
page.contents = page.contents.replace(/## Parameters\n\n### props/g, '## props')
64+
page.contents = page.contents.replace(/## Parameters\n\n### props/g, '## props\n---')
65+
// Replace parameters with proper styling
66+
page.contents = page.contents.replace(
67+
/#### `(.*)` - (.*)/g,
68+
'<span style={{fontSize: 24, color: "rgb(var(--color-primary))"}}>**$1**</span>\n\n$2\n',
69+
)
70+
// Shrink headers that should be smaller, and tweak the color
71+
// page.contents = page.contents.replace(/####? (.*)\n/g, '**$1**\n')
72+
// NOTE: This here is another option for the above, tweaks the param color and size
73+
page.contents = page.contents.replace(
74+
/####? (.*)\n/g,
75+
'<span style={{fontSize: 24, color: "rgb(var(--color-primary))"}}>**$1**</span>\n',
76+
)
77+
// Add a divider after Returns
78+
page.contents = page.contents.replace(/## Returns\n\n/g, '## Returns\n---\n')
6579
})
6680

6781
// Happens after the markdown pages are generated
@@ -126,7 +140,7 @@ export const load = (app) => {
126140

127141
// Update the nav number in the frontmatter
128142
const content = fs.readFileSync(targetFile, 'utf-8')
129-
const updatedContent = content.replace(/nav:\s*\d+/, `nav: ${index + 1}`)
143+
const updatedContent = content.replace(/nav:\s*\d+/, `nav: ${index + 25}`)
130144
fs.writeFileSync(targetFile, updatedContent)
131145
})
132146
}

packages/react/xr/src/anchor.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export {
1111
} from '@pmndrs/xr'
1212

1313
/**
14-
* hook that returns a function that allows to request a xr anchor
14+
* Hook that returns a function that allows to request a xr anchor
1515
*/
1616
export function useRequestXRAnchor() {
1717
const store = useXRStore()

packages/react/xr/src/controller-locomotion.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,27 @@
1-
import { RootState, useFrame } from '@react-three/fiber'
2-
import { RefObject, useMemo } from 'react'
3-
import { Vector3, Object3D } from 'three'
41
import {
52
type XRControllerLocomotionRotationOptions,
63
type XRControllerLocomotionTranslationOptions,
74
createXRControllerLocomotionUpdate,
85
} from '@pmndrs/xr/internals'
6+
import { RootState, useFrame } from '@react-three/fiber'
7+
import { RefObject, useMemo } from 'react'
8+
import { Object3D, Vector3 } from 'three'
99
import { useXRStore } from './xr.js'
1010

1111
/**
1212
* A hook for handling basic locomotion in VR
1313
* @param target Either a `THREE.Group` ref, or a callback function. Recieves movement input (required).
1414
* @param translationOptions Options that control the translation of the user. Set to `false` to disable.
15-
* @param translationOptions.speed The speed at which the user moves.
15+
*
16+
* #### `translationOptions.speed` - The speed at which the user moves.
17+
*
1618
* @param rotationOptions Options that control the rotation of the user. Set to `false` to disable.
17-
* @param rotationOptions.deadZone How far the joystick must be pushed to trigger a turn.
18-
* @param rotationOptions.type Controls how rotation using the controller functions. Can be either 'smooth' or 'snap'.
19-
* @param rotationOptions.degrees If `type` is 'snap', this specifies the number of degrees to snap the user's view by.
20-
* @param rotationOptions.speed If `type` is 'smooth', this specifies the speed at which the user's view rotates.
19+
*
20+
* #### `rotationOptions.deadZone` - How far the joystick must be pushed to trigger a turn.
21+
* #### `rotationOptions.type` - Controls how rotation using the controller functions. Can be either 'smooth' or 'snap'.
22+
* #### `rotationOptions.degrees` - If `type` is 'snap', this specifies the number of degrees to snap the user's view by.
23+
* #### `rotationOptions.speed` - If `type` is 'smooth', this specifies the speed at which the user's view rotates.
24+
*
2125
* @param translationControllerHand Specifies which hand will control the movement. Can be either 'left' or 'right'.
2226
*/
2327
export function useXRControllerLocomotion(

packages/react/xr/src/controller.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ import { XRSpace } from './space.js'
2121
* Component for placing content in the controller anchored at a specific component such as the Thumbstick
2222
*
2323
* @param props
24-
* * `id`: `XRControllerGamepadComponentId` - Is the id of the component where content should be placed (e.g. `"a-button"`)
25-
* * `onPress?`: `Function` - Is an optional callback to receive when the component is pressed
26-
* * `onRelease?`: `Function` - Is an optional callback to receive when the component is released
27-
* * `children?`: `ReactNode` - Children to be placed inside the componenent (e.g. visualizing a tooltip over the button...)
24+
* #### `id` - `XRControllerGamepadComponentId` Is the id of the component where content should be placed (e.g. `"a-button"`)
25+
* #### `onPress?` - `Function` Is an optional callback to receive when the component is pressed
26+
* #### `onRelease?` - `Function` Is an optional callback to receive when the component is released
27+
* #### `children?` - `ReactNode` Children to be placed inside the componenent (e.g. visualizing a tooltip over the button...)
2828
*
2929
* @function
3030
*/
@@ -49,7 +49,7 @@ export const XRControllerComponent = forwardRef<
4949
})
5050

5151
/**
52-
* hook for subscribing to a button state change event on the controller
52+
* Hook for subscribing to a button state change event on the controller
5353
* @param id of the button
5454
* @param onChange callback that gets executed when the state of the button changes
5555
* @param handedness of the controller
@@ -76,8 +76,8 @@ const LoadXRControllerModelSymbol = Symbol('loadXRControllerModel')
7676
/**
7777
* Component for rendering a 3D model for the XRController
7878
* @param props
79-
* * `colorWrite` Configures the colorWrite property of the model
80-
* * `renderOrder` Configures the render order model
79+
* #### `colorWrite` - Configures the colorWrite property of the model
80+
* #### `renderOrder` - Configures the render order model
8181
* @function
8282
*/
8383
export const XRControllerModel = forwardRef<Object3D, XRControllerModelOptions>((options, ref) => {
@@ -104,6 +104,7 @@ const LoadXRControllerLayoutSymbol = Symbol('loadXRControllerLayout')
104104
* Hook for loading a controller layout, which contains info about the controller model and its buttons / controls.
105105
* For xr controllers provided through WebXR, the layout is loaded and provided through the controller state automatically.
106106
* Therefore, this hook's purpose is for building controller demos/tutorials.
107+
*
107108
* @param profileIds
108109
* @param handedness
109110
* @param XRControllerLayoutLoaderOptions

0 commit comments

Comments
 (0)