This component has API which aims to accomplish two goals:
- Increase the flexibility of testing a components edge cases, while reducing the overal amount of boilerplate code that needs to be written
- Clearly document how a component can be used.
A basic example:
Arg | Type | Description |
---|---|---|
@name |
String |
The name of the component |
@description |
String |
(Optional) Information to describe the component |
:description |
Named block | Alternative to @description . Allows you compose markdown support or anything else you may want |
:example |
Named block | Write the code that will be run to preview the component |
:api |
Named block | Yields Args . Use Args to document the component arguments |
Base
is the base argument components that all other args compose. All Arg types support these aruments.
Argument | Type | Description |
---|---|---|
@name |
String |
The name of the argument |
@type |
String |
The argument type, ex String , Number , Action , etc |
@description |
String |
Description of the argument |
@required |
Bool |
Whether this is a required argument |
@defaultValue |
Any |
Does it have a default value? |
@hideControls |
Bool |
Should the argument show the dynamic controls for its value? |
{{yield}} |
The base argument accepts a yielded block. Whatever is in the block will show up in the "Controls" column of the table. Here you can provide a mechanism to dynamicaly modify the value of the argument, updating the preview |
A Boolean argument. Provides a simple toggle.
Argument | Type | Description |
---|---|---|
@value |
Bool |
The current value |
@onInput |
Action |
An action that is called when the button toggles |
A Boolean argument. Provides a simple toggle.
Argument | Type | Description |
---|---|---|
@value |
Bool |
The current value |
@options |
Array |
If the arg only accepts a certain number of values, ie: ['sm', 'md', 'lg'] , provide them here and the control will change to a select menu |
@onInput |
Action |
An action that is called when the input updates |
A number argument.
Argument | Type | Description |
---|---|---|
@value |
Number |
The current value |
@min |
Number |
The minimum acceptable value. When present, along with max, the control will show a range slider instead of an input. |
@max |
Number |
The maximum acceptable value. |
@step |
Number |
Defaults to 1. How much the input slider should step when adjusted |
@onInput |
Action |
An action that is called when the input updates |
A way to document an argument that expects a function to be passed to it. There is currently no dynamic controls for this Argument type.
A way to document an argument that expects a function to be passed to it. There is currently no dynamic controls for this Argument type.
Argument | Type | Description |
---|---|---|
@name |
String |
Optional, if the component has a named block |
When a component expects a type of javascript object as an input. The API row will display a syntax highlighted output of the value passed in.
Argument | Type | Description |
---|---|---|
@name |
String |
Optional, if the component has a named block |
@value |
Object |
Optional. Will display a pretty printed and syntax highlighted representation in the controls column |
@jsonCollapseDepth |
Number |
In the preview, how many levels in should the json object be collapsed on initial render |
An AST transform takes the contents of the <:example>...</:example>
named block and makes it available to the Freestyle::Usage component for
rendering with syntax highlighting.
The AST transform works by looking for a compoent invocation of the form <Freestyle::Usage> ...
. This works find for traditional Ember templates
that use global lookup for components. To facilitate strict mode templates (.gjs/.gts
), the code also looks for <FreestyleUsage>...
. Name your
import accordingly in order to benefit from this feature.