CraftUI

World Browser

The player's worlds as cards, with search, sorting, Create new world, Edit, and Delete after confirmation.

Play

All worlds (4)

  • Survival

    Last played yesterday

  • CreativeExperimental

    Last played 3 days ago

  • Creative

    Last played 6 days ago

  • Survival

    Last played 12 days ago

Open on a page of its own

Installation

npx shadcn@latest add @runqora/craft-world-browser

Usage

import { WorldBrowser } from "@/components/craft/blocks/world-browser";

<WorldBrowser
  onCreate={createWorld}
  onDelete={(world) => deleteWorld(world.id)}
  onEdit={(world) => editWorld(world.id)}
  onPlay={(world) => play(world.id)}
  worlds={worlds}
/>;

Props

WorldBrowser

Prop

Type

Accessibility

  • Each card opens its world through a button named "Play" and the world's name.
  • Delete asks for confirmation in an alert dialog first.
  • The search box and sort menu are labelled.

Customization

Worlds sort by when they were last played, newest first, or by name. lastPlayedLabel writes the line under each name, in the player's language. The block keeps only what's on screen, such as the search text. Your data comes in through props, and every action calls one of your handlers, so it works with any backend. Every screen fills its frame, so give it a height, such as h-dvh for a whole page.

Dependencies

  • craft-badge, craft-button, craft-input, craft-screen, craft-select and craft-world-list
  • shadcn's utils, and craft-theme

Source