EnumStyleProp
Table of contents
Extends StyleProp<T>
.
See StyleProp & StyleProp.defineEnum
class EnumStyleProp<T> extends StyleProp<T> {}
Properties
from
StyleProp
defaultValue: Type
from
StyleProp
readonly id: string
from
StyleProp
readonly type: T.Validatable<Type>
readonly values: readonly T[]
Methods
from
StyleProp
Define a new StyleProp.
static define<Type>(
uniqueId: string,
options: {
defaultValue: Type
type?: T.Validatable<Type>
}
): StyleProp<Type>
Example
import { StyleProp } from '@tldraw/tlschema'
import { T } from '@tldraw/validate'
const MyLineWidthProp = StyleProp.define('myApp:lineWidth', {
defaultValue: 1,
type: T.number,
})
Parameters
Name | Description |
---|---|
|
Each StyleProp must have a unique ID. We recommend you prefix this with your app/library name. |
|
|
Returns
StyleProp<Type>
from
StyleProp
Define a new StyleProp as a list of possible values.
static defineEnum<const Values extends readonly unknown[]>(
uniqueId: string,
options: {
defaultValue: Values[number]
values: Values
}
): EnumStyleProp<Values[number]>
Example
import { StyleProp } from '@tldraw/tlschema'
const MySizeProp = StyleProp.defineEnum('myApp:size', {
defaultValue: 'medium',
values: ['small', 'medium', 'large'],
})
Parameters
Name | Description |
---|---|
|
Each StyleProp must have a unique ID. We recommend you prefix this with your app/library name. |
|
|
Returns
EnumStyleProp<Values[number]>
from
StyleProp
setDefaultValue(value: Type): void
Parameters
Name | Description |
---|---|
|
|
Returns
void
from
StyleProp
validate(value: unknown): Type
Parameters
Name | Description |
---|---|
|
|
Returns
Type
from
StyleProp
validateUsingKnownGoodVersion(prevValue: Type, newValue: unknown): Type
Parameters
Name | Description |
---|---|
|
|
|
|
Returns
Type