vaadin / docs

Official documentation for Vaadin and Hilla.
https://vaadin.com/docs
Other
29 stars 195 forks source link

In case of code sample contains custom classes add comments #1898

Open TatuLund opened 1 year ago

TatuLund commented 1 year ago

E.g. in Split layout documentation there are code snippets like this. For a new user it is not obvious that MasterContent and DetailContent can be any Vaadin component.

package com.vaadin.demo.component.splitlayout;

import com.vaadin.flow.component.html.Div;
import com.vaadin.flow.component.splitlayout.SplitLayout;
import com.vaadin.flow.router.Route;

@Route("split-layout-basic")
public class SplitLayoutBasic extends Div {

    public SplitLayoutBasic() {
        MasterContent master = new MasterContent();
        DetailContent detail = new DetailContent();

        SplitLayout splitLayout = new SplitLayout(master, detail);

        splitLayout.setMaxHeight("280px");
        add(splitLayout);
    }

}

Proposal

package com.vaadin.demo.component.splitlayout;

import com.vaadin.flow.component.html.Div;
import com.vaadin.flow.component.splitlayout.SplitLayout;
import com.vaadin.flow.router.Route;

@Route("split-layout-basic")
public class SplitLayoutBasic extends Div {

    public SplitLayoutBasic() {
        MasterContent master = new MasterContent(); // replace MasterContent with your layout component
        DetailContent detail = new DetailContent(); // replace DetailContent with your layout component

        SplitLayout splitLayout = new SplitLayout(master, detail);

        splitLayout.setMaxHeight("280px");
        add(splitLayout);
    }

}

image

vaadin-bot commented 1 year ago

Thanks for using Vaadin! We appreciate helping us to have better documentation and we’ll take care of this as soon as possible.

juuso-vaadin commented 1 year ago

In addition to comments, the custom classes could be named to be more obvious. For example DemoContent() or DemoContentRenderer() or PlaceholderContent() or even ReplaceThisWithAnyContent().

juuso-vaadin commented 1 year ago

SplitPanel examples could be further improved by using or mentioning the addToPrimary() and addToSecondary() methods somewhere.