Home Reference Source
import Stylist from 'potassium-es/src/style/Stylist.js'
public class | source

Stylist

Extends:

EventHandler → Stylist

Stylist takes the KSS derived JSON emitted by postcss-potassium and applies it to a Three.js Scene

Constructor Summary

Public Constructor
public

Member Summary

Public Members
public get

Method Summary

Public Methods
public

applyStyles(scene: *, renderer: *)

Apply the styles previously calculated in calculateStyles to the scene

public

calculateStyles(scene: *)

Annotate each node in the scene with applicable direct or cascaded KSS-defined styles

public

loadData(kssData: *)

public

async loadLinks()

Looks in the document for one or more link elements with a rel attribute of spatial-stylesheet and then attempts to load them as KSS data For example:

<head> <link rel='spatial-stylesheet' href='./path/to/styles.json'> </head>

Inherited Summary

From class EventHandler
public get

listeners: EventListener[]: *

public

addListener(callback: function(eventName: string, eventSource: EventHandler), eventName: Object | Symbol, once: bool)

public
public

removeListener(callback: *, eventName: undefined)

public

trigger(eventName: *, params: ...*)

Send an event to listeners

Public Constructors

public constructor() source

Public Members

public get stylesheets: * source

Public Methods

public applyStyles(scene: *, renderer: *) source

Apply the styles previously calculated in calculateStyles to the scene

Params:

NameTypeAttributeDescription
scene *
renderer *

public calculateStyles(scene: *) source

Annotate each node in the scene with applicable direct or cascaded KSS-defined styles

Params:

NameTypeAttributeDescription
scene *

public loadData(kssData: *) source

Params:

NameTypeAttributeDescription
kssData *

Looks in the document for one or more link elements with a rel attribute of spatial-stylesheet and then attempts to load them as KSS data For example:

<head> <link rel='spatial-stylesheet' href='./path/to/styles.json'> </head>