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
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
| EnvironmentSwitcher | Tipo | Por defecto |
|---|---|---|
currentobligatorio | string | |
onChangeobligatorio | (id: string) => void | |
optionsobligatorio | SwitcherOption[] | |
compact | boolean | |
createLabelThe thing to create: «organization». Defaults to `kind`. | string | |
kind | string | |
onCreateAdds «Create …» at the end of the list. | (() => void) | |
onSettingsAdds a settings entry at the end of the list («Organization settings» on the OrgSwitcher). | (() => void) | |
settingsLabelThe words of that entry. | string |