UserWrappr prioritizes creating the contents as soon as possible.
When you call `createDisplay`, the following happen in order:
1. View libraries (MobX+React) _start_ to load.
2. A visual approximation of your menus is placed at the bottom of the area.
3. Contents are created in the remaining usable area.
4. Once view libraries are loaded, real menus created using them to replace the fake menus.
### Menus
It's assumed that your menus will exist below your content.
Hovering over a menu title with a mouse will open the menu the content.
Each menu's schema must contain a `title: string` and `options: IOptionSchema[]`.
Options will be created in top-to-bottom order within their parent menu.
The allowed option types, as indicated by the `type` member of the option schemas, are:
*`"action"`: Simple triggerable action with an `action: () => void` callback.
*`"boolean"`: Stores an on/off value.
*`"multi-select"`: Stores multiple options within preset values. Needs:
*`options: string[]`: Given preset values.
*`selections: number`: How many of the preset options must be chosen at once.
*`"number"`: Stores a numeric value. May specify `max` and/or `min` values.
*`"select"`: Stores one of some preset `options: string[]`.
*`"string"`: Stores a string value.
All schema types except `"action"` store their `TValue` type and must also provide:
*`getInitialValue(): TValue`: returns an initial state for the value.
*`saveValue(newValue: TValue, oldValue: TValue): void`: saves a new state for the value.
See [`OptionSchemas.ts`](src/Menus/Options/OptionSchemas.ts) for the full definitions.
### Styles
UserWrappr will provide some default styles to its elements to position them.
You can override them by passing in a `styles` object keying preset identifiers to their CSS styles.
Although they're not used internally, you can also customize which class names are added to elements by passing a `classNames` object mapping preset identifiers to their class names.
Both `styles` and `classNames` will only override with provided values.
See [`ClassNames.ts`](src/Bootstrapping/ClassNames.ts) for default class names and [`Styles.ts`](src/Bootstrapping/Styles.ts) for preset identifiers and their default values.
## API
### Optional Parameters
*`classNames: IClassNames`: Class names to use for display elements.
*`createElement: (tagName: string, properties: IElementProperties)`: Creates a new HTML element.
*`defaultSize: IRelativeSizeSchema`: Initial size to create contents at _(by default, 100% x 100%)_.
*`getAvailableContainerHeight`: Gets how much height is available to hold contents _(by default, `window.innerHeight`)_.
*`menuInitializer: string`: RequireJS path to the menu initialization script.
*`menus: IMenuSchema[]`: Menus to create inside the menus area.
*`styles: IStyles`: Styles to use for display elements.
*`requirejs`: RequireJS (AMD) API to load scripts.
See [`IUserWrappr.ts`](src/IUserWrappr.ts) for specifications on the parameters.
### Examples
Giving each menu title a `.my-menu-title` class and `color: red` CSS style:
```typescript
constuserWrapper=newUserWrappr({
classNames:{
menuTitle:"my-menu-title"
},
createContents:()=>{/* ... */},
styles:{
menuTitle:{
color:"red"
}
}
})
```
Creating a menu with mute and volume inputs for a [GameStartr](https://github.com/FullScreenShenanigans/GameStartr)'s [AudioPlayr](https://github.com/FullScreenShenanigans/AudioPlayr):
Whenever you add, remove, or rename a `*.test.t*` file under `src/`, `watch` will re-run `npm run test:setup` to regenerate the list of static test files in `test/index.html`.