<lit-crossword> is a Lit web component for a multiplayer crossword puzzle in Vaadin 14+.
To use <lit-crossword>, create an instance of the Crossword class, passing a unique identifier for the local user. Then pass a valid Puzzle instance to the setPuzzle() method. Puzzle is a JSON parser that uses the standard defined here.
import java.io.InputStream;
import java.util.UUID;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.vaadin.addons.crossword.Crossword;
import org.vaadin.addons.crossword.Puzzle;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.router.Route;
@Route("")
public class CrosswordView extends VerticalLayout {
Crossword crossword = new Crossword(UUID.randomUUID().toString());
try {
InputStream json = CrosswordView.class.getResource(
"/puzzle.json").openStream();
Puzzle puzzle = new ObjectMapper()
.readerFor(Puzzle.class)
.readValue(json);
crossword.setPuzzle(puzzle);
} catch (Exception e) {
e.printStackTrace();
}
add(crossword);
}