EnvironmentSwitcher
Which environment of the project: production, staging, a preview. Production carries a warning light so nobody changes it by mistake.
import { EnvironmentSwitcher } from '@sypnia/ui/react'
Three environments
Code
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' }]} />;
} When to use it
Use it when
- Projects with more than one environment.
- Mark production with
tone="warn".
Do not use it when
- One environment only.
For everyone
- The light is decoration; the name says which environment it is.
Props
| EnvironmentSwitcher | Type | Default |
|---|---|---|
currentrequired | string | |
onChangerequired | (id: string) => void | |
optionsrequired | 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 |