| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- //go:build js && wasm
- package ultraviolet
- type WebFactory struct {
- }
- func NewWebFactory() Factory {
- return &WebFactory{}
- }
- func (this *WebFactory) NewRoot(options any) Component {
- optionsRoot := options.(RootComponentOptions)
- return NewRootComponentWeb(optionsRoot.View)
- }
- func (this *WebFactory) NewContainer(options any) Component {
- optionsContainer := options.(ContainerComponentOptions)
- return NewContainerComponentWeb(optionsContainer.View)
- }
- func (this *WebFactory) NewButton(options any) Component {
- optionsButton := options.(ButtonComponentOptions)
- result := NewButtonComponentWeb(optionsButton.View)
- if optionsButton.Controller.Handler != nil {
- result.SetHandler(optionsButton.Controller.Handler)
- }
- if optionsButton.Model.Format != "" && optionsButton.Model.Values != nil {
- result.SetValue(
- optionsButton.Model.Format,
- optionsButton.Model.Values,
- )
- }
- return result
- }
- func (this *WebFactory) NewImage(options any) Component {
- optionsImage := options.(ImageComponentOptions)
- result := NewImageComponentWeb(optionsImage.View)
- if optionsImage.Model.Path != "" {
- result.SetPath(optionsImage.Model.Path)
- }
- return result
- }
- func (this *WebFactory) NewMarkdown(options any) Component {
- optionsMarkdown := options.(MarkdownComponentOptions)
- result := NewMarkdownComponentWeb(optionsMarkdown.View)
- if optionsMarkdown.Model.Content != "" {
- result.SetMarkdown(optionsMarkdown.Model.Content)
- }
- return result
- }
- func (this *WebFactory) NewFrame(options any) Component {
- optionsFrame := options.(FrameComponentOptions)
- result := NewFrameComponentWeb(optionsFrame.View)
- if optionsFrame.Model.URL != "" {
- result.SetUrl(optionsFrame.Model.URL)
- }
- return result
- }
- func (this *WebFactory) NewCode(options any) Component {
- optionsCode := options.(CodeComponentOptions)
- result := NewCodeComponentWeb(optionsCode.View)
- if optionsCode.Model.Language != "" && optionsCode.Model.Content != "" {
- result.SetCode(
- optionsCode.Model.Language,
- optionsCode.Model.Content,
- )
- }
- return result
- }
|