Skip to content

Commit 09bbd2a

Browse files
committed
add documentation examples to components
1 parent 908936c commit 09bbd2a

15 files changed

Lines changed: 158 additions & 32 deletions

src/components/button.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@ export interface ButtonProperties extends UIProperties {
2424
icon: string;
2525
}
2626

27+
/**
28+
* A `<acc-button>` element.
29+
* @example
30+
* ```html
31+
*
32+
* <acc-button label="My Button" icon="my-icon.png"></acc-button>
33+
* <acc-button label="My Button" disabled></acc-button>
34+
* ```
35+
*/
2736
export class ButtonElement extends AbstractUIElement {
2837

2938
/**

src/components/content.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,18 @@ const isFocusable = (el: any): el is { focus: ()=> void } =>
3636
const isInputWithCanvas = (c: any): c is { canvas: HTMLCanvasElement } =>
3737
typeof c.canvas === 'object' && typeof c.canvas.getContext === 'function';
3838

39+
/**
40+
* An `<acc-content>` element is intended as a container for the main content area.
41+
* If using an AbstractInput such as `<acc-mouse-input>` or `<acc-pose-input>`
42+
* the coordinate space will be mapped to this element and can optionally
43+
* simplify display of the camera image.
44+
*
45+
* @example ```html
46+
*
47+
* <acc-content webcamOpacity="0.25" grayscale mounted></acc-content>
48+
* ```
49+
*
50+
*/
3951
export class ContentElement extends AbstractUIElement {
4052

4153

src/components/group.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,16 @@ const extractValue = (el:any):any => {
5454
return null;
5555
}
5656

57+
/**
58+
* A `<acc-group>` element. Make a group (typically within side-panel) of related
59+
* controls. Provides proper headings and aria-labels and consistent focusing.
60+
*
61+
* @example ```html
62+
*
63+
* <acc-group label="My Group" shortcut="Shift G"></acc-group>
64+
* <acc-group label="My Group" disabled></acc-group>
65+
* ```
66+
*/
5767
export class GroupElement extends AbstractUIElement {
5868

5969
/**

src/components/input-mode-select.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,17 @@ interface UIElements {
3333
}
3434

3535
/**
36-
* <acc-input-mode-select>
37-
* Creates a UI element for selecting an appropriate input method,
38-
* bundles proper initialization, event bubbling, access to calibration
36+
* An `<acc-input-mode-select>` element creates a UI element for selecting an input
37+
* method. It bundles proper initialization, event bubbling, access to calibration
3938
* and messaging.
40-
* @extends AbstractSelectElement
39+
*
40+
* @example ```html
41+
*
42+
* <acc-input-mode-select>
43+
* <acc-mouse-input amplification="5"></acc-mouse-input>
44+
* <acc-pose-input amplification="2" part="nose" smoothing="0.5"></acc-pose-input>
45+
* </acc-input-mode-select>
46+
* ```
4147
*/
4248
export class InputModeSelectElement extends AbstractSelectElement {
4349

src/components/mouse-input.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ enum MouseKeyboardInputMode {
3232
}
3333

3434

35+
/**
36+
* A Mouse Input element binds mouse, keyboard and touch as a single method
37+
* of translating a cursor position.
38+
*
39+
* @see InputModeSelectElement
40+
*/
3541
class MouseInputElement extends AbstractInputElement {
3642

3743
@property({ type: String })

src/components/optgroup.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ import { property } from './decorators';
1717

1818

1919
/**
20-
* <acc-optgroup> is an element to designate a group within an <acc-select>
21-
* @example
20+
* `<acc-optgroup>` is an element to designate a group within an <acc-select>
21+
* @example ```html
22+
*
2223
* <acc-select label="Instruments">
2324
* <acc-optgroup label="Strings">
2425
* <acc-item label="guitar"></acc-item>
@@ -29,6 +30,7 @@ import { property } from './decorators';
2930
* <acc-item label="tamborine"></acc-item>
3031
* </acc-optgroup>
3132
* </acc-select>
33+
* ```
3234
*/
3335
export class OptgroupElement extends LitElement {
3436

src/components/pose-input.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,17 @@ export class ACCPoseInputEvent extends ACCInputEvent {
190190

191191
const _tmpContentDims: [number, number] = [NaN, NaN];
192192

193+
/**
194+
* `<acc-pose-input>` element easily adds PoseNet based tracking for controlling
195+
* the cursor position on a webpage with a chosen body part of the user.
196+
* For example with a couple lines of code, a user's nose can be used to control
197+
* a webpage.
198+
*
199+
* @example ```html
200+
*
201+
* <acc-pose-input amplification="2" smoothing="0.5" part="nose"></acc-pose-input>
202+
* ```
203+
*/
193204
export class PoseInputElement extends AbstractInputElement {
194205

195206
@property({ type: String })

src/components/range.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,15 @@ export interface RangeProperties extends UIProperties {
4242
value: string;
4343
}
4444

45+
/**
46+
* `<acc-range>` element is a custom range / slider component that simplifies
47+
* labelling.
48+
*
49+
* @example ```html
50+
*
51+
* <acc-range label="amplification" min="1" max="10" step="0.1" value="2"></acc-range>
52+
* ```
53+
*/
4554
class RangeElement extends AbstractUIElement {
4655

4756
@property({ type: String })

src/components/select.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,24 @@ const toOptionTemplate = (node: OptionItem) =>
4242

4343

4444

45+
/**
46+
* `<acc-select>` element is similar to a `<select>` element with built-in
47+
* labelling and aria attributes.
48+
*
49+
* @example ```html
50+
*
51+
* <acc-select label="Instruments">
52+
* <acc-optgroup label="Strings">
53+
* <acc-item label="guitar"></acc-item>
54+
* <acc-item label="cello"></acc-item>
55+
* </acc-optgroup>
56+
* <acc-optgroup label="percussion">
57+
* <acc-item label="drums"></acc-item>
58+
* <acc-item label="tamborine"></acc-item>
59+
* </acc-optgroup>
60+
* </acc-select>
61+
* ```
62+
*/
4563
export class SelectElement extends AbstractSelectElement {
4664

4765

src/components/side-panel.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,20 @@ interface PanelProperties extends UIProperties {
3636

3737

3838
/**
39+
* `<acc-side-panel label="App Name">`
40+
* The side panel element is a collapsable menu that houses UI elements. It
41+
* simplifies tab management, heading structure and provides a "skip to content"
42+
* link when navigated with keyboard.
43+
*
44+
* @example ```html
45+
*
3946
* <acc-side-panel label="App Name">
40-
* The side panel element that houses UI elements.
47+
* <acc-group label="Group 1">
48+
* <acc-range label="Slider" value="5" max="10"></acc-range>
49+
* <acc-button label="Button"></acc-button>
50+
* </acc-group>
51+
* </acc-side-panel>
52+
* ```
4153
*/
4254
export class SidePanel extends GroupElement {
4355

0 commit comments

Comments
 (0)