DEV Community

himansa
himansa

Posted on

Devlog 3: Doubt

This few days i gotten back to phrototype. Because i felt like phrototype already work like initial system i trying to rebuild.
By the way, I tried to create a simple app using phototype, and results are quite satisfing. As example we can build simple interactive page just by,

public NWindow testMacro(){
        NWindow win = new NWindow("Test Macro");
        win.AddCss(StyleBlock.of(".hidden").display("none"));
        Themes.default_theme(win);

        win.setView(
                new Panel("rootpane h% w% &center &col").addChild(
                        new Panel("toolbar w%").addChild(
                                new Button("togpaneone $toggle pone hidden","Panel one"),
                                new Button("togpanetwo $toggle ptwo hidden","Panel two"),
                                new Button("toggleBoth $toggle ptwo hidden $toggle pone hidden","toggle")
                        ),
                        new Panel("holder w% h% &vbox").addChild(
                                new Panel("pone bg green h50%").addChild(new Label("lone col white","This is Pane one")),
                                new Panel("ptwo bg blue h50% .hidden").addChild(new Label("ltwo col white","This is Pane two"))
                        )
                )
        );
        return win;
    }
Enter fullscreen mode Exit fullscreen mode

this code creates this output,

Where toggle button toggles both panels and first button and second button toggles just that pane. $ toggle isn't a hardcoded function. It's just global macro that user can define. This is,

register("toggle", x -> {
            if (x.component != null) {
                String cnameTest = x.peek();
                String cname;
                if (Objects.equals(cnameTest, "-")) return;
                cname = x.next();

                String classnameTest = x.peek();
                String classname;
                if (Objects.equals(classnameTest, "-")) return;
                classname = x.next();

                x.component.events.addJsEvent(NEvent.CLICK, JS.id(cname).ClassList().toggle(classname).E().toString());
            }
        });
Enter fullscreen mode Exit fullscreen mode

After all, i still doubt do i need to recode from zero. My idea now is replace some parts of the phrototype with new modules and envlove it to be the framework. phrototype is stable enough that Currently i even use it for some of my projects.
Only problem being... well, i don't have much problems to say.. maybe some memory leaks here and there on lists that won't even matter until app runs for days.through i can fix it up without rewrites.
Did anyone have some suggestions?

Top comments (0)