TopBar
La barra de arriba de cada página con sesión iniciada: la marca, dónde está la persona y las herramientas a la derecha. AppShell la dibuja; úsala suelta cuando el marco es propio de la app.
import { TopBar, OrgSwitcher, ProjectSwitcher, UserMenu, NotificationBell } from '@sypnia/ui/react'
En esta página
La barra de una consola
Código
import { useState } from 'react';
import { Logo, NotificationBell, OrgSwitcher, ProjectSwitcher, TopBar, UserMenu } from '@sypnia/ui/react';
// The bar of a console on its own: brand, where you are (organization / project), and the tools on the right.
export default function Console() {
const [org, setOrg] = useState('acme');
const [project, setProject] = useState('shop');
return (
<TopBar brand={<Logo product="Data" />}
where={<div className="sy-row"><OrgSwitcher current={org} onChange={setOrg} options={[{ id: 'acme', name: 'Acme' }, { id: 'north', name: 'Northwind' }]} /><span className="sy-text--muted">/</span>
<ProjectSwitcher current={project} onChange={setProject} options={[{ id: 'shop', name: 'shop' }, { id: 'analytics', name: 'analytics' }]} /></div>}
tools={<><NotificationBell items={[{ id: '1', title: 'Backup finished', at: new Date(), unread: true, icon: 'backup', tone: 'ok' }]} /><UserMenu name="Ana Ruiz" email="ana@northwind.io" onSignOut={() => {}} /></>} />
);
} Cuándo usarlo
Úsalo cuando
- Apps que no usan AppShell pero quieren la misma barra superior.
- Pon los selectores de organización y de proyecto en
where, y la campana y el menú de la cuenta entools.
No lo uses cuando
- Dentro de AppShell: ya tiene una.
- Muchos botones en la barra: déjala en buscar, notificaciones y la cuenta.
Para todos
- Es una región
header. - Cada herramienta tiene un nombre; los selectores dicen qué cambian.
Props
| TopBar | Tipo | Por defecto |
|---|---|---|
brandobligatorio | ReactNode | |
tools | ReactNode | |
where | ReactNode |
| OrgSwitcher | 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 |
| ProjectSwitcher | 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 |
| UserMenu | Tipo | Por defecto |
|---|---|---|
nameobligatorio | string | |
onSignOutobligatorio | () => void | |
childrenItems between the header and Sign out, as MenuItem: «Account», «Preferences». | ReactNode | |
email | string | |
onAction | ((key: Key) => void) | |
src | string |
| NotificationBell | Tipo | Por defecto |
|---|---|---|
itemsobligatorio | NotificationEntry[] | |
labelDefaults to «Notifications». | string | |
onOpen | ((id: string) => void) | |
onReadAll | (() => void) |