Skip to content

Latest commit

 

History

History
50 lines (40 loc) · 1.7 KB

vaadin-directory-description.md

File metadata and controls

50 lines (40 loc) · 1.7 KB

Published on vaadin.com/directory

<lit-crossword>

<lit-crossword> is a Lit web component for a multiplayer crossword puzzle in Vaadin 14+.

Getting Started

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);
}