Ir al contenido

EnvironmentSwitcher

Qué entorno del proyecto: producción, pruebas, una vista previa. Producción lleva una luz de aviso para que nadie lo cambie por error.

import { EnvironmentSwitcher } from '@sypnia/ui/react'

En esta página
  1. Tres entornos
  2. Cuándo usarlo
  3. Para todos
  4. Props

Tres entornos

Código
import { useState } from 'react';
import { EnvironmentSwitcher } from '@sypnia/ui/react';

// Production carries a warning light, so nobody changes it thinking it is staging.
export default function Envs() {
  const [env, setEnv] = useState('production');
  return <EnvironmentSwitcher current={env} onChange={setEnv}
    options={[{ id: 'production', name: 'Production', tone: 'warn' }, { id: 'staging', name: 'Staging', tone: 'ok' }, { id: 'preview', name: 'Preview #212', tone: 'neutral', detail: 'Branch fix-login' }]} />;
}

Cuándo usarlo

Úsalo cuando

  • Proyectos con más de un entorno.
  • Marca producción con tone="warn".

No lo uses cuando

  • Un solo entorno.

Para todos

  • La luz es decoración; el nombre dice qué entorno es.

Props

EnvironmentSwitcherTipoPor defecto
currentobligatorio string
onChangeobligatorio (id: string) => void
optionsobligatorio SwitcherOption[]
compact boolean
createLabel

The thing to create: «organization». Defaults to `kind`.

string
kind string
onCreate

Adds «Create …» at the end of the list.

(() => void)
onSettings

Adds a settings entry at the end of the list («Organization settings» on the OrgSwitcher).

(() => void)
settingsLabel

The words of that entry.

string
  1. Tres entornos
  2. Cuándo usarlo
  3. Para todos
  4. Props

    Busca páginas, secciones y términos