Skip to content
Snippets Groups Projects
RootView.ts 1.24 KiB
Newer Older
  • Learn to ignore specific revisions
  • Midhun Suresh's avatar
    Midhun Suresh committed
    import { TemplateView } from "hydrogen-view-sdk";
    import { RootViewModel } from "../../viewmodels/RootViewModel";
    import { AccountSetupView } from "./AccountSetupView";
    import { ChatterboxView } from "./ChatterboxView";
    
    export class RootView extends TemplateView<RootViewModel> {
    
    Midhun Suresh's avatar
    Midhun Suresh committed
        constructor(value) {
            super(value);
        }
    
        render(t, vm: RootViewModel) {
    
    Midhun Suresh's avatar
    Midhun Suresh committed
            return t.mapView(vm => vm.activeSection, section => {
                switch(section) {
                    case "start":
    
    Midhun Suresh's avatar
    Midhun Suresh committed
                        window.sendFrameResizeEventToParent("50px", "50px");
    
    Midhun Suresh's avatar
    Midhun Suresh committed
                        return new StartView(vm);
                    case "account-setup":
    
    Midhun Suresh's avatar
    Midhun Suresh committed
                        window.sendFrameResizeEventToParent("115px", "360px");
    
    Midhun Suresh's avatar
    Midhun Suresh committed
                        return new AccountSetupView(vm.accountSetupViewModel);
                    case "timeline":
    
    Midhun Suresh's avatar
    Midhun Suresh committed
                        window.sendFrameResizeEventToParent("600px", "400px");
    
    Midhun Suresh's avatar
    Midhun Suresh committed
                        return new ChatterboxView(vm.chatterboxViewModel);
                }
                return null;
            })
        }
    }
    
    
    class StartView extends TemplateView<RootViewModel> {
    
    Midhun Suresh's avatar
    Midhun Suresh committed
        constructor(value) {
            super(value);
        }
    
    
    Midhun Suresh's avatar
    Midhun Suresh committed
        render(t, vm: RootViewModel) {
    
    Midhun Suresh's avatar
    Midhun Suresh committed
            return t.button({ className: "StartChat", onClick: () => vm.start() });
    
    Midhun Suresh's avatar
    Midhun Suresh committed
        }
    }