Krizaka UI
Krizaka UI
Composants

State screen

What a screen says when it has nothing to show, when it failed, or when the network is gone: an icon, a title in plain words, the reason and the way out — announced as it should be. With the slim offline banner for a screen that still shows saved data.

Web · n/aMobile · ✓Bureau · n/aBêtaRetours
State screen — Empty, tel que React Native le rend

« Empty », son histoire React Native à la largeur d’un téléphone — le même code sur iOS et Android.

Mobile uniquement — React Native, depuis @krizaka/ui/native. Bêta : son API peut encore changer à une version mineure.

  • Web · n/a. On the web these are the empty state and the error page. → Empty state
  • Bureau · n/a. The Mac app's window is the web: its states are the empty state and the error page. → Empty state

Pourquoi il est là. the native apps: Yomizaka and Akinaza mobile, Orazaka mobile: the empty, error and offline screens (krizaka-ui#753, #741).

Quand l’utiliser

  • A list or a screen with nothing in it yet.
  • A request that failed and can be retried.
  • The network is gone: the banner when saved data shows, the full state when nothing does.

Quand ne pas l’utiliser

Installation

Installer

npx expo install react-native-svg
npm install @krizaka/ui

Importer

import { StateScreen, OfflineBanner } from "@krizaka/ui/native";

Enveloppez l’application une fois dans ThemeProvider de @krizaka/ui/native : chaque composant lit ses rôles de couleur.

Exemples

React Native n’a pas d’aperçu en direct sur le web : chaque exemple montre la capture de sa story, testée dans les deux thèmes, et le code à copier.

Empty

Nothing yet, and the one way to fill it.

State screen — Empty, tel que React Native le rendState screen — Empty, tel que React Native le rend

Error

What failed in plain words, Try again, and a quieter way to get help.

State screen — Error, tel que React Native le rendState screen — Error, tel que React Native le rend

Offline

The slim banner over the saved data, and the full state when there is none.

State screen — Offline, tel que React Native le rendState screen — Offline, tel que React Native le rend

Props

StateScreen

The empty, error and offline screens. An error is announced as an alert, an offline state as a status; an empty one is just there.

PropTypeDéfautDescription
kindrequisStateKind—empty (nothing yet), error (it failed) or offline (no network).
titlerequisstring—What happened, in a few words (“No notifications yet”). Passed translated.
actionStateAction—The way out: Try again, Add one, Open settings.
descriptionstring—Why, and what to do.
iconReactNode—Replaces the icon of the kind.
inlineboolean—Fills its parent and centres (default), or sits in the flow of a list (inline).
secondaryStateAction—A quieter second way out (Contact support).
styleViewStyle—Styles merged last.
testIDstring—For tests.

OfflineBanner

A slim strip at the top of a screen that still shows saved data while the network is gone.

PropTypeDéfautDescription
labelrequisstring—“You're offline. Showing what was saved.” Passed translated.
actionLabelstring—“Try again”.
onAction(() => void)—Called by the action.
testIDstring—For tests.

Accessibilité

  • An error is announced as an alert, an offline state as a status; an empty state is just a heading and a button.
  • The icon is decorative; the title is the heading.

Bonnes pratiques

  • Say what happened in a few words and what to do: « We could not load your files » and « Try again », never « Error 500 ».
  • One main way out (action), a quieter second (secondary). An empty state's way out is how to fill it.
  • inline puts the state in the flow of a list; by default it fills its parent and centres.
  • The app detects the network (NetInfo) and passes the state: this component never reaches for the network itself.

Générée depuis le code de @krizaka/ui 3.69.0 : son meta.ts, ses exemples et ses types.Modifier cette documentation sur GitHub

Sur cette page