| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- //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)
- result := NewContainerComponentWeb(optionsContainer.View)
- if optionsContainer.Controller.Handler != nil {
- result.SetHandler(optionsContainer.Controller.Handler)
- }
- if optionsContainer.Model.Value != nil {
- result.SetValue(optionsContainer.Model.Value)
- }
- return result
- }
- func (this *WebFactory) NewText(options any) Component {
- optionsText := options.(TextComponentOptions)
- result := NewTextComponentWeb(optionsText.View)
- if optionsText.Model.Format != "" && optionsText.Model.Values != nil {
- result.SetValue(
- optionsText.Model.Format,
- optionsText.Model.Values,
- )
- }
- return result
- }
- 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)
- }
- if optionsImage.Model.Width != 0 {
- result.SetWidth(optionsImage.Model.Width)
- }
- 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, optionsMarkdown.Model.Paragraph)
- }
- 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
- }
|