Salesforce Lightning JS behaviour

Docked Utility Bar

A footer of utility icons that pop open panels in place — the agent’s always-on toolbox docked to the page bottom.

Documentation

Real scenarios

The component as it is used in a product — not a specimen grid.

The agent’s always-on toolbox

Five utilities docked to the console’s bottom edge; each click pops its panel in place and only one is open at a time — chat even sends.

Sales Console My open opportunities
Nabu annual licenseNegotiation · €240M
Hot
Berlin plant rolloutProposal · €98M
On track
Rotterdam retail renewalQualification · €45M
At risk
Istanbul logistics pilotDiscovery · €12M
New

Badge and active states

Counts clamp past nine, and the open utility keeps its white bar until the panel closes.

badge = 9
badge = 9+
active
idle

Important props

Important props
Prop Type Default What it does
panel popover 'above' The panel opens above its icon, one at a time; an outside tap or the same icon closes it.
badge count null Icons carry count badges; anything past 9 clamps to 9+.
active state 'panel-open' The open panel’s icon gains a brand-blue bar beneath and stays lit until closed.
items count '4–8' Four to eight utilities; the overflow folds into a More menu.

Snippet

<div class="sflx-util">
    <div class="sflx-util-panel" role="dialog" aria-label="Chat">…</div>
    <nav class="sflx-util-bar">
        <button aria-expanded="true" aria-label="Chat"><x-nx::icon name="message" /><b>3</b></button>
        <button aria-expanded="false" aria-label="Notifications"><x-nx::icon name="bell" /><b>9+</b></button>
    </nav>
</div>

<style>
.sflx-util { position: relative; }
.sflx-util-bar { display: flex; background: #0B5CAB; color: #fff; }
.sflx-util-bar button { inline-size: 3rem; block-size: 2.75rem; position: relative; }
.sflx-util-bar button[aria-expanded='true'] { box-shadow: inset 0 -3px 0 #fff; }
.sflx-util-panel { position: absolute; inset-inline: 0; inset-block-end: 2.75rem;
                   block-size: 16rem; background: #fff; border: 1px solid #DDDBDA; }
</style>
// resources/js/pages/Console.tsx — an Inertia page (React flavor). Inertia
// mounts this component for /console; the docked frame itself is the
// UtilityBar component from the React snippet. Register the route with
// Route::inertia('/console', 'Console') on the Laravel side.
import UtilityBar from '@/components/UtilityBar';

export default function Console() {
  return <UtilityBar />;
}
// UtilityBar.tsx — a Lightning console frame with the Docked Utility Bar on
// its bottom edge: five utilities, one panel open at a time, chat sends.
// The markup mirrors the playground partial (sld-* classes).
import { type CSSProperties, useEffect, useRef, useState } from 'react';
import '@nabuxai/ui-react/css';

const PATHS = {
  grid: 'M4 4h7v7H4zM13 4h7v7h-7zM4 13h7v7H4zM13 13h7v7h-7z',
  message: 'M4 5h16v11H9l-5 4z',
  bell: 'M6 16v-5a6 6 0 1 1 12 0v5l1.5 2h-15zM10 21h4',
  users: 'M9 11a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7zM2.5 20a6.5 6.5 0 0 1 13 0M16 4.2a3.5 3.5 0 0 1 0 6.6M18 14a6.5 6.5 0 0 1 3.5 6',
  folder: 'M3.5 7.5a2 2 0 0 1 2-2h3.8l2 2h7.2a2 2 0 0 1 2 2v7a2 2 0 0 1-2 2h-13a2 2 0 0 1-2-2z',
  mic: 'M12 15a3 3 0 0 0 3-3V6a3 3 0 0 0-6 0v6a3 3 0 0 0 3 3zM19 11a7 7 0 0 1-14 0M12 18v3',
};

const I = ({ d }: { d: string }) => (
  <svg className="nx-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor"
    strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"><path d={d} /></svg>
);

const CREW = [
  { name: 'Elif', initials: 'ED', tint: '#0176D3', online: true },
  { name: 'Lena', initials: 'LF', tint: '#6739B7', online: true },
  { name: 'Marco', initials: 'MB', tint: '#04844B', online: false },
];

// Panel id -> [icon path, aria-label, panel heading].
const PANELS: Record<string, [string, string, string]> = {
  chat: [PATHS.message, 'Chat with the deal team', 'Deal team chat'],
  bell: [PATHS.bell, 'Notifications', '9 unread'],
  users: [PATHS.users, 'Who is online', 'Deal team — 2 online'],
  files: [PATHS.folder, 'Files drawer', 'Recent files'],
  mic: [PATHS.mic, 'Voice note', 'Record a voice note'],
};

export default function UtilityBar() {
  const [open, setOpen] = useState<string | null>(null);
  const [sent, setSent] = useState<string[]>([]);
  const frame = useRef<HTMLDivElement>(null);
  const input = useRef<HTMLInputElement>(null);

  // One panel at a time; Escape or an outside click closes (was Alpine).
  useEffect(() => {
    const click = (e: MouseEvent) => { if (!frame.current?.contains(e.target as Node)) setOpen(null); };
    const esc = (e: KeyboardEvent) => { if (e.key === 'Escape') setOpen(null); };
    document.addEventListener('click', click);
    document.addEventListener('keydown', esc);
    return () => { document.removeEventListener('click', click); document.removeEventListener('keydown', esc); };
  }, []);

  const send = () => {
    const value = input.current?.value.trim();
    if (!value) return;
    setSent([...sent, value]);
    input.current!.value = '';
  };

  return (
    <div className="sld-root">
      <div className="sld-frame" ref={frame}>
        <div className="sld-top"><I d={PATHS.grid} /><b>Sales Console</b><span style={{ opacity: .8 }}>My open opportunities</span></div>
        <div className="sld-body">
          <div className="sld-rec"><div><b>Nabu annual license</b><small>Negotiation · €2.4M</small></div><span className="sld-badge-card">Hot</span></div>
          <div className="sld-rec"><div><b>Anatolia plant rollout</b><small>Proposal · €980K</small></div><span className="sld-badge-card">On track</span></div>
          <div className="sld-rec"><div><b>Aegean retail renewal</b><small>Qualification · €450K</small></div><span className="sld-badge-card">At risk</span></div>
        </div>

        {open && (
          <div className="sld-panelzone">
            <div className="sld-panel" role="dialog" aria-label={PANELS[open][1]}>
              <div className="sld-panel-head">
                <I d={PANELS[open][0]} />
                {PANELS[open][2]}
                <button type="button" onClick={() => setOpen(null)} aria-label="Close">✕</button>
              </div>
              <div className="sld-panel-body">
                {open === 'chat' && (
                  <>
                    <p className="sld-note"><b>Elif</b><span>Spree asked for the revised quote today.</span></p>
                    <p className="sld-note"><b>Lena</b><span>Pricing sheet is with legal now.</span></p>
                    {sent.map((m, i) => <p key={i} className="sld-note"><b>You</b><span>{m}</span></p>)}
                    <div className="sld-typing">
                      <input ref={input} type="text" placeholder="Message the team…"
                        onKeyDown={(e) => e.key === 'Enter' && send()} />
                      <button type="button" onClick={send}>Send</button>
                    </div>
                  </>
                )}
                {open === 'bell' && (
                  <>
                    <p className="sld-note"><b>Approval requested</b><span>€2.4M discount needs a manager sign-off.</span></p>
                    <p className="sld-note"><b>Spree replied</b><span>New comment on the quote — 2 min ago.</span></p>
                  </>
                )}
                {open === 'users' && CREW.map((p) => (
                  <div key={p.name} className="sld-crew">
                    <span className="sld-ava" style={{ '--sld-tint': p.tint } as CSSProperties}>{p.initials}</span>
                    <span>{p.name}</span>
                    <span className="sld-dot" style={!p.online ? { background: 'var(--sld-muted)' } : undefined} />
                  </div>
                ))}
                {open === 'files' && (
                  <>
                    <p className="sld-note"><b>Quote-2026.pdf</b><span>248 KB · shared with Spree</span></p>
                    <p className="sld-note"><b>Pricing sheet Q4.xlsx</b><span>92 KB · edited by Lena</span></p>
                  </>
                )}
                {open === 'mic' && (
                  <p style={{ margin: 0, color: 'var(--sld-muted)' }}>Notes attach straight to "Nabu annual license" and land in the Chatter feed.</p>
                )}
              </div>
            </div>
          </div>
        )}

        <nav className="sld-bar" aria-label="Utility bar">
          {([
            ['chat', PATHS.message, 'Chat, 3 unread', '3'],
            ['bell', PATHS.bell, 'Notifications, 9 unread', '9'],
            ['users', PATHS.users, 'Who is online', null],
            ['files', PATHS.folder, 'Files', null],
            ['mic', PATHS.mic, 'Voice note', null],
          ] as const).map(([id, d, label, badge]) => (
            <button key={id} type="button" className="sld-util"
              aria-expanded={open === id} aria-label={label}
              onClick={() => setOpen(open === id ? null : id)}>
              <I d={d} />
              {badge && <span className="sld-count">{badge}</span>}
            </button>
          ))}
        </nav>
      </div>

      <style>{css}</style>
    </div>
  );
}

const css = `
.sld-root { font-family: 'Salesforce Sans', -apple-system, 'Segoe UI', Roboto, sans-serif; color: #181818;
  --sld-blue-soft: color-mix(in srgb, #0176D3 8%, #FFFFFF); --sld-navy: #0B5CAB; --sld-green: #04844B;
  --sld-muted: #706E6B; --sld-border: #DDDBDA; --sld-bg: #F3F3F3; --sld-card: #FFFFFF; }
@media (prefers-color-scheme: dark) { .sld-root { color: #F3F3F3;
  --sld-blue-soft: color-mix(in srgb, #0D9DDA 16%, #232323); --sld-navy: #0B5CAB; --sld-green: #0E9E5B;
  --sld-muted: #A5A5A5; --sld-border: #474747; --sld-bg: #181818; --sld-card: #232323; } }
.sld-frame { position: relative; max-inline-size: 46rem; margin-inline: auto; block-size: 27rem;
  display: flex; flex-direction: column; overflow: clip; border: 1px solid var(--sld-border);
  border-radius: .5rem; background: var(--sld-bg); }
.sld-top { display: flex; align-items: center; gap: .6rem; padding: .5rem .8rem;
  background: var(--sld-navy); color: #FFFFFF; font-size: .82rem; }
.sld-body { flex: 1; overflow-y: auto; padding: .8rem; display: grid; gap: .5rem; align-content: start; }
.sld-rec { display: flex; align-items: center; gap: .6rem; padding: .55rem .7rem; border: 1px solid var(--sld-border);
  border-radius: .25rem; background: var(--sld-card); }
.sld-rec small { display: block; color: var(--sld-muted); font-size: .74rem; }
.sld-badge-card { margin-inline-start: auto; font-size: .74rem; font-weight: 700; color: var(--sld-green); }
.sld-panelzone { position: absolute; inset-inline: 0; inset-block-end: 2.75rem; z-index: 5;
  display: flex; justify-content: center; padding: 0 .75rem; }
.sld-panel { inline-size: min(100%, 24rem); max-block-size: 17rem; display: flex; flex-direction: column;
  border: 1px solid var(--sld-border); border-radius: .25rem .25rem 0 0; border-block-end: 0;
  background: var(--sld-card); box-shadow: 0 -4px 14px rgba(0, 0, 0, .12); overflow: hidden; }
.sld-panel-head { display: flex; align-items: center; gap: .5rem; padding: .55rem .8rem;
  border-block-end: 1px solid var(--sld-border); background: var(--sld-blue-soft);
  font-size: .82rem; font-weight: 700; }
.sld-panel-head button { margin-inline-start: auto; border: 0; background: transparent;
  color: var(--sld-muted); cursor: pointer; font-weight: 700; }
.sld-panel-body { overflow-y: auto; padding: .6rem .8rem; font-size: .82rem; display: grid; gap: .55rem; align-content: start; }
.sld-note { display: grid; gap: .1rem; margin: 0; padding-block-end: .55rem; border-block-end: 1px solid var(--sld-border); }
.sld-note:last-of-type { border-block-end: 0; padding-block-end: 0; }
.sld-note b { font-size: .8rem; }
.sld-note span { color: var(--sld-muted); font-size: .76rem; }
.sld-crew { display: flex; align-items: center; gap: .55rem; }
.sld-ava { display: grid; place-items: center; inline-size: 1.75rem; block-size: 1.75rem; border-radius: 50%;
  background: var(--sld-tint, var(--sld-navy)); color: #FFFFFF; font-size: .64rem; font-weight: 700; }
.sld-dot { margin-inline-start: auto; inline-size: .5rem; block-size: .5rem; border-radius: 50%; background: var(--sld-green); }
.sld-typing { display: flex; gap: .4rem; }
.sld-typing input { flex: 1; min-inline-size: 0; padding: .4rem .55rem; border: 1px solid var(--sld-border);
  border-radius: .25rem; background: var(--sld-card); color: inherit; font: inherit; font-size: .8rem; }
.sld-typing button { border: 0; border-radius: .25rem; background: var(--sld-navy); color: #FFFFFF;
  cursor: pointer; padding-inline: .7rem; font: inherit; font-size: .8rem; font-weight: 600; }
.sld-bar { display: flex; justify-content: center; gap: .15rem; block-size: 2.75rem;
  background: var(--sld-navy); color: #FFFFFF; }
.sld-util { position: relative; display: grid; place-items: center; inline-size: 3.4rem; border: 0;
  background: transparent; color: #FFFFFF; cursor: pointer; }
.sld-util::after { content: ''; position: absolute; inset-inline: 15%; inset-block-end: 0; block-size: 3px;
  background: transparent; }
.sld-util[aria-expanded='true'] { background: color-mix(in srgb, #FFFFFF 10%, transparent); }
.sld-util[aria-expanded='true']::after { background: #FFFFFF; }
.sld-count { position: absolute; inset-block-start: .3rem; inset-inline-end: .45rem; min-inline-size: 1rem;
  padding-inline: .22rem; block-size: 1rem; display: grid; place-items: center; border-radius: .5rem;
  background: #EA001E; color: #FFFFFF; font-size: .6rem; font-weight: 700; box-shadow: 0 0 0 2px var(--sld-navy); }
`;
<!-- UtilityBar.vue — a Lightning console frame with the Docked Utility Bar
     on its bottom edge: five utilities, one panel open at a time, chat
     sends. Markup mirrors the playground partial (sld-* classes). -->
<script setup lang="ts">
import { onBeforeUnmount, onMounted, ref } from 'vue';

const crew = [
  { name: 'Elif', initials: 'ED', tint: '#0176D3', online: true },
  { name: 'Lena', initials: 'LF', tint: '#6739B7', online: true },
  { name: 'Marco', initials: 'MB', tint: '#04844B', online: false },
];
// Icon paths by utility id (the partial renders these via <x-nx::icon />).
const icons: Record<string, string> = {
  grid: 'M4 4h7v7H4zM13 4h7v7h-7zM4 13h7v7H4zM13 13h7v7h-7z',
  chat: 'M4 5h16v11H9l-5 4z',
  bell: 'M6 16v-5a6 6 0 1 1 12 0v5l1.5 2h-15zM10 21h4',
  users: 'M9 11a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7zM2.5 20a6.5 6.5 0 0 1 13 0M16 4.2a3.5 3.5 0 0 1 0 6.6M18 14a6.5 6.5 0 0 1 3.5 6',
  files: 'M3.5 7.5a2 2 0 0 1 2-2h3.8l2 2h7.2a2 2 0 0 1 2 2v7a2 2 0 0 1-2 2h-13a2 2 0 0 1-2-2z',
  mic: 'M12 15a3 3 0 0 0 3-3V6a3 3 0 0 0-6 0v6a3 3 0 0 0 3 3zM19 11a7 7 0 0 1-14 0M12 18v3',
};
const records = [
  { name: 'Nabu annual license', meta: 'Negotiation · €2.4M', badge: 'Hot' },
  { name: 'Anatolia plant rollout', meta: 'Proposal · €980K', badge: 'On track' },
  { name: 'Aegean retail renewal', meta: 'Qualification · €450K', badge: 'At risk' },
];

const open = ref<string | null>(null);
const sent = ref<string[]>([]);
const draft = ref('');
const frame = ref<HTMLElement | null>(null);

// One panel at a time; Escape or an outside click closes (was Alpine).
const onClick = (e: MouseEvent) => { if (!frame.value?.contains(e.target as Node)) open.value = null; };
const onKey = (e: KeyboardEvent) => { if (e.key === 'Escape') open.value = null; };
onMounted(() => {
  document.addEventListener('click', onClick);
  document.addEventListener('keydown', onKey);
});
onBeforeUnmount(() => {
  document.removeEventListener('click', onClick);
  document.removeEventListener('keydown', onKey);
});

const send = () => {
  const value = draft.value.trim();
  if (!value) return;
  sent.value = [...sent.value, value];
  draft.value = '';
};
</script>

<template>
  <div class="sld-root">
      <div ref="frame" class="sld-frame">
        <div class="sld-top">
          <svg class="nx-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-linecap="round"
            stroke-linejoin="round" aria-hidden="true"><path :d="icons.grid" /></svg>
          <b>Sales Console</b><span style="opacity: .8">My open opportunities</span>
        </div>
      <div class="sld-body">
        <div v-for="r in records" :key="r.name" class="sld-rec">
          <div><b>{{ r.name }}</b><small>{{ r.meta }}</small></div>
          <span class="sld-badge-card">{{ r.badge }}</span>
        </div>
      </div>

      <div v-if="open" class="sld-panelzone">
        <div class="sld-panel" role="dialog" aria-label="Utility panel">
          <div class="sld-panel-head">
            {{ open === 'chat' ? 'Deal team chat' : open === 'bell' ? '9 unread'
              : open === 'users' ? 'Deal team — 2 online'
              : open === 'files' ? 'Recent files' : 'Record a voice note' }}
            <button type="button" aria-label="Close" @click="open = null">✕</button>
          </div>
          <div class="sld-panel-body">
            <template v-if="open === 'chat'">
              <p class="sld-note"><b>Elif</b><span>Spree asked for the revised quote today.</span></p>
              <p class="sld-note"><b>Lena</b><span>Pricing sheet is with legal now.</span></p>
              <p v-for="(m, i) in sent" :key="i" class="sld-note"><b>You</b><span>{{ m }}</span></p>
              <div class="sld-typing">
                <input v-model="draft" type="text" placeholder="Message the team…" @keydown.enter="send" />
                <button type="button" @click="send">Send</button>
              </div>
            </template>
            <template v-else-if="open === 'bell'">
              <p class="sld-note"><b>Approval requested</b><span>€2.4M discount needs a manager sign-off.</span></p>
              <p class="sld-note"><b>Spree replied</b><span>New comment on the quote — 2 min ago.</span></p>
            </template>
            <template v-else-if="open === 'users'">
              <div v-for="p in crew" :key="p.name" class="sld-crew">
                <span class="sld-ava" :style="{ '--sld-tint': p.tint }">{{ p.initials }}</span>
                <span>{{ p.name }}</span>
                <span class="sld-dot" :style="p.online ? undefined : { background: 'var(--sld-muted)' }" />
              </div>
            </template>
            <template v-else-if="open === 'files'">
              <p class="sld-note"><b>Quote-2026.pdf</b><span>248 KB · shared with Spree</span></p>
              <p class="sld-note"><b>Pricing sheet Q4.xlsx</b><span>92 KB · edited by Lena</span></p>
            </template>
            <p v-else style="margin: 0; color: var(--sld-muted)">
              Notes attach straight to "Nabu annual license" and land in the Chatter feed.
            </p>
          </div>
        </div>
      </div>

      <nav class="sld-bar" aria-label="Utility bar">
        <button v-for="u in [
          { id: 'chat', label: 'Chat, 3 unread', badge: '3' },
          { id: 'bell', label: 'Notifications, 9 unread', badge: '9' },
          { id: 'users', label: 'Who is online', badge: null },
          { id: 'files', label: 'Files', badge: null },
          { id: 'mic', label: 'Voice note', badge: null },
        ]" :key="u.id" type="button" class="sld-util"
          :aria-expanded="open === u.id" :aria-label="u.label"
          @click="open = open === u.id ? null : u.id">
          <svg class="nx-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-linecap="round"
            stroke-linejoin="round" aria-hidden="true"><path :d="icons[u.id]" /></svg>
          <span v-if="u.badge" class="sld-count">{{ u.badge }}</span>
        </button>
      </nav>
    </div>
  </div>
</template>

<style scoped>
.sld-root { font-family: 'Salesforce Sans', -apple-system, 'Segoe UI', Roboto, sans-serif; color: #181818;
  --sld-blue-soft: color-mix(in srgb, #0176D3 8%, #FFFFFF); --sld-navy: #0B5CAB; --sld-green: #04844B;
  --sld-muted: #706E6B; --sld-border: #DDDBDA; --sld-bg: #F3F3F3; --sld-card: #FFFFFF; }
@media (prefers-color-scheme: dark) { .sld-root { color: #F3F3F3;
  --sld-blue-soft: color-mix(in srgb, #0D9DDA 16%, #232323); --sld-navy: #0B5CAB; --sld-green: #0E9E5B;
  --sld-muted: #A5A5A5; --sld-border: #474747; --sld-bg: #181818; --sld-card: #232323; } }
.sld-frame { position: relative; max-inline-size: 46rem; margin-inline: auto; block-size: 27rem;
  display: flex; flex-direction: column; overflow: clip; border: 1px solid var(--sld-border);
  border-radius: .5rem; background: var(--sld-bg); }
.sld-top { display: flex; align-items: center; gap: .6rem; padding: .5rem .8rem;
  background: var(--sld-navy); color: #FFFFFF; font-size: .82rem; }
.sld-top b { font-weight: 700; }
.sld-body { flex: 1; overflow-y: auto; padding: .8rem; display: grid; gap: .5rem; align-content: start; }
.sld-rec { display: flex; align-items: center; gap: .6rem; padding: .55rem .7rem;
  border: 1px solid var(--sld-border); border-radius: .25rem; background: var(--sld-card); }
.sld-rec small { display: block; color: var(--sld-muted); font-size: .74rem; }
.sld-badge-card { margin-inline-start: auto; font-size: .74rem; font-weight: 700; color: var(--sld-green); }
.sld-panelzone { position: absolute; inset-inline: 0; inset-block-end: 2.75rem; z-index: 5;
  display: flex; justify-content: center; padding: 0 .75rem; }
.sld-panel { inline-size: min(100%, 24rem); max-block-size: 17rem; display: flex; flex-direction: column;
  border: 1px solid var(--sld-border); border-radius: .25rem .25rem 0 0; border-block-end: 0;
  background: var(--sld-card); box-shadow: 0 -4px 14px rgba(0, 0, 0, .12); overflow: hidden; }
.sld-panel-head { display: flex; align-items: center; gap: .5rem; padding: .55rem .8rem;
  border-block-end: 1px solid var(--sld-border); background: var(--sld-blue-soft);
  font-size: .82rem; font-weight: 700; }
.sld-panel-head button { margin-inline-start: auto; border: 0; background: transparent;
  color: var(--sld-muted); cursor: pointer; font-weight: 700; }
.sld-panel-body { overflow-y: auto; padding: .6rem .8rem; font-size: .82rem; display: grid; gap: .55rem; align-content: start; }
.sld-note { display: grid; gap: .1rem; margin: 0; padding-block-end: .55rem; border-block-end: 1px solid var(--sld-border); }
.sld-note:last-of-type { border-block-end: 0; padding-block-end: 0; }
.sld-note b { font-size: .8rem; }
.sld-note span { color: var(--sld-muted); font-size: .76rem; }
.sld-crew { display: flex; align-items: center; gap: .55rem; }
.sld-ava { display: grid; place-items: center; inline-size: 1.75rem; block-size: 1.75rem; border-radius: 50%;
  background: var(--sld-tint, var(--sld-navy)); color: #FFFFFF; font-size: .64rem; font-weight: 700; flex: none; }
.sld-dot { margin-inline-start: auto; inline-size: .5rem; block-size: .5rem; border-radius: 50%; background: var(--sld-green); }
.sld-typing { display: flex; gap: .4rem; }
.sld-typing input { flex: 1; min-inline-size: 0; padding: .4rem .55rem; border: 1px solid var(--sld-border);
  border-radius: .25rem; background: var(--sld-card); color: inherit; font: inherit; font-size: .8rem; }
.sld-typing button { border: 0; border-radius: .25rem; background: var(--sld-navy); color: #FFFFFF;
  cursor: pointer; padding-inline: .7rem; font: inherit; font-size: .8rem; font-weight: 600; }
.sld-bar { display: flex; justify-content: center; gap: .15rem; block-size: 2.75rem;
  background: var(--sld-navy); color: #FFFFFF; }
.sld-util { position: relative; display: grid; place-items: center; inline-size: 3.4rem; border: 0;
  background: transparent; color: #FFFFFF; cursor: pointer; font-size: 1.05rem; }
.sld-util::after { content: ''; position: absolute; inset-inline: 15%; inset-block-end: 0; block-size: 3px;
  background: transparent; }
.sld-util[aria-expanded='true'] { background: color-mix(in srgb, #FFFFFF 10%, transparent); }
.sld-util[aria-expanded='true']::after { background: #FFFFFF; }
.sld-count { position: absolute; inset-block-start: .3rem; inset-inline-end: .45rem; min-inline-size: 1rem;
  padding-inline: .22rem; block-size: 1rem; display: grid; place-items: center; border-radius: .5rem;
  background: #EA001E; color: #FFFFFF; font-size: .6rem; font-weight: 700; box-shadow: 0 0 0 2px var(--sld-navy); }
</style>
<!-- UtilityBar.svelte — a Lightning console frame with the Docked Utility
     Bar on its bottom edge: five utilities, one panel open at a time, chat
     sends. Markup mirrors the playground partial (sld-* classes). -->
<script lang="ts">
  const crew = [
    { name: 'Elif', initials: 'ED', tint: '#0176D3', online: true },
    { name: 'Lena', initials: 'LF', tint: '#6739B7', online: true },
    { name: 'Marco', initials: 'MB', tint: '#04844B', online: false },
  ];
  const records = [
    { name: 'Nabu annual license', meta: 'Negotiation · €2.4M', badge: 'Hot' },
    { name: 'Anatolia plant rollout', meta: 'Proposal · €980K', badge: 'On track' },
    { name: 'Aegean retail renewal', meta: 'Qualification · €450K', badge: 'At risk' },
  ];
  // id -> [icon path, panel heading]
  const utilities = [
    { id: 'chat', label: 'Chat, 3 unread', badge: '3', d: 'M4 5h16v11H9l-5 4z', heading: 'Deal team chat' },
    { id: 'bell', label: 'Notifications, 9 unread', badge: '9', d: 'M6 16v-5a6 6 0 1 1 12 0v5l1.5 2h-15zM10 21h4', heading: '9 unread' },
    { id: 'users', label: 'Who is online', badge: null, d: 'M9 11a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7zM2.5 20a6.5 6.5 0 0 1 13 0M16 4.2a3.5 3.5 0 0 1 0 6.6M18 14a6.5 6.5 0 0 1 3.5 6', heading: 'Deal team — 2 online' },
    { id: 'files', label: 'Files', badge: null, d: 'M3.5 7.5a2 2 0 0 1 2-2h3.8l2 2h7.2a2 2 0 0 1 2 2v7a2 2 0 0 1-2 2h-13a2 2 0 0 1-2-2z', heading: 'Recent files' },
    { id: 'mic', label: 'Voice note', badge: null, d: 'M12 15a3 3 0 0 0 3-3V6a3 3 0 0 0-6 0v6a3 3 0 0 0 3 3zM19 11a7 7 0 0 1-14 0M12 18v3', heading: 'Record a voice note' },
  ];

  let open = $state<string | null>(null);
  let sent = $state<string[]>([]);
  let draft = $state('');
  let frame: HTMLElement;

  const send = () => {
    const value = draft.trim();
    if (!value) return;
    sent = [...sent, value];
    draft = '';
  };
  const dismiss = (e: MouseEvent) => { if (!frame.contains(e.target as Node)) open = null; };
</script>

<svelte:document onclick={dismiss} onkeydown={(e) => e.key === 'Escape' && (open = null)} />

<div class="sld-root">
  <div bind:this={frame} class="sld-frame">
    <div class="sld-top"><b>Sales Console</b><span style="opacity: .8">My open opportunities</span></div>
    <div class="sld-body">
      {#each records as r (r.name)}
        <div class="sld-rec">
          <div><b>{r.name}</b><small>{r.meta}</small></div>
          <span class="sld-badge-card">{r.badge}</span>
        </div>
      {/each}
    </div>

    {#if open}
      <div class="sld-panelzone">
        <div class="sld-panel" role="dialog" aria-label="Utility panel">
          <div class="sld-panel-head">
            {utilities.find((u) => u.id === open)?.heading}
            <button type="button" aria-label="Close" onclick={() => (open = null)}>✕</button>
          </div>
          <div class="sld-panel-body">
            {#if open === 'chat'}
              <p class="sld-note"><b>Elif</b><span>Spree asked for the revised quote today.</span></p>
              <p class="sld-note"><b>Lena</b><span>Pricing sheet is with legal now.</span></p>
              {#each sent as m, i (i)}
                <p class="sld-note"><b>You</b><span>{m}</span></p>
              {/each}
              <div class="sld-typing">
                <input bind:value={draft} type="text" placeholder="Message the team…"
                  onkeydown={(e) => e.key === 'Enter' && send()} />
                <button type="button" onclick={send}>Send</button>
              </div>
            {:else if open === 'bell'}
              <p class="sld-note"><b>Approval requested</b><span>€2.4M discount needs a manager sign-off.</span></p>
              <p class="sld-note"><b>Spree replied</b><span>New comment on the quote — 2 min ago.</span></p>
            {:else if open === 'users'}
              {#each crew as p (p.name)}
                <div class="sld-crew">
                  <span class="sld-ava" style:--sld-tint={p.tint}>{p.initials}</span>
                  <span>{p.name}</span>
                  <span class="sld-dot" style:background={p.online ? undefined : 'var(--sld-muted)'} />
                </div>
              {/each}
            {:else if open === 'files'}
              <p class="sld-note"><b>Quote-2026.pdf</b><span>248 KB · shared with Spree</span></p>
              <p class="sld-note"><b>Pricing sheet Q4.xlsx</b><span>92 KB · edited by Lena</span></p>
            {:else}
              <p style="margin: 0; color: var(--sld-muted)">
                Notes attach straight to "Nabu annual license" and land in the Chatter feed.
              </p>
            {/if}
          </div>
        </div>
      </div>
    {/if}

    <nav class="sld-bar" aria-label="Utility bar">
      {#each utilities as u (u.id)}
        <button type="button" class="sld-util" aria-expanded={open === u.id} aria-label={u.label}
          onclick={() => (open = open === u.id ? null : u.id)}>
          <svg class="nx-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-linecap="round"
            stroke-linejoin="round" aria-hidden="true"><path d={u.d} /></svg>
          {#if u.badge}<span class="sld-count">{u.badge}</span>{/if}
        </button>
      {/each}
    </nav>
  </div>
</div>

<style>
.sld-root { font-family: 'Salesforce Sans', -apple-system, 'Segoe UI', Roboto, sans-serif; color: #181818;
  --sld-blue-soft: color-mix(in srgb, #0176D3 8%, #FFFFFF); --sld-navy: #0B5CAB; --sld-green: #04844B;
  --sld-muted: #706E6B; --sld-border: #DDDBDA; --sld-bg: #F3F3F3; --sld-card: #FFFFFF; }
@media (prefers-color-scheme: dark) { .sld-root { color: #F3F3F3;
  --sld-blue-soft: color-mix(in srgb, #0D9DDA 16%, #232323); --sld-navy: #0B5CAB; --sld-green: #0E9E5B;
  --sld-muted: #A5A5A5; --sld-border: #474747; --sld-bg: #181818; --sld-card: #232323; } }
.sld-frame { position: relative; max-inline-size: 46rem; margin-inline: auto; block-size: 27rem;
  display: flex; flex-direction: column; overflow: clip; border: 1px solid var(--sld-border);
  border-radius: .5rem; background: var(--sld-bg); }
.sld-top { display: flex; align-items: center; gap: .6rem; padding: .5rem .8rem;
  background: var(--sld-navy); color: #FFFFFF; font-size: .82rem; }
.sld-body { flex: 1; overflow-y: auto; padding: .8rem; display: grid; gap: .5rem; align-content: start; }
.sld-rec { display: flex; align-items: center; gap: .6rem; padding: .55rem .7rem;
  border: 1px solid var(--sld-border); border-radius: .25rem; background: var(--sld-card); }
.sld-rec small { display: block; color: var(--sld-muted); font-size: .74rem; }
.sld-badge-card { margin-inline-start: auto; font-size: .74rem; font-weight: 700; color: var(--sld-green); }
.sld-panelzone { position: absolute; inset-inline: 0; inset-block-end: 2.75rem; z-index: 5;
  display: flex; justify-content: center; padding: 0 .75rem; }
.sld-panel { inline-size: min(100%, 24rem); max-block-size: 17rem; display: flex; flex-direction: column;
  border: 1px solid var(--sld-border); border-radius: .25rem .25rem 0 0; border-block-end: 0;
  background: var(--sld-card); box-shadow: 0 -4px 14px rgba(0, 0, 0, .12); overflow: hidden; }
.sld-panel-head { display: flex; align-items: center; gap: .5rem; padding: .55rem .8rem;
  border-block-end: 1px solid var(--sld-border); background: var(--sld-blue-soft);
  font-size: .82rem; font-weight: 700; }
.sld-panel-head button { margin-inline-start: auto; border: 0; background: transparent;
  color: var(--sld-muted); cursor: pointer; font-weight: 700; }
.sld-panel-body { overflow-y: auto; padding: .6rem .8rem; font-size: .82rem; display: grid; gap: .55rem; align-content: start; }
.sld-note { display: grid; gap: .1rem; margin: 0; padding-block-end: .55rem; border-block-end: 1px solid var(--sld-border); }
.sld-note b { font-size: .8rem; }
.sld-note span { color: var(--sld-muted); font-size: .76rem; }
.sld-crew { display: flex; align-items: center; gap: .55rem; }
.sld-ava { display: grid; place-items: center; inline-size: 1.75rem; block-size: 1.75rem; border-radius: 50%;
  background: var(--sld-tint, var(--sld-navy)); color: #FFFFFF; font-size: .64rem; font-weight: 700; flex: none; }
.sld-dot { margin-inline-start: auto; inline-size: .5rem; block-size: .5rem; border-radius: 50%; background: var(--sld-green); }
.sld-typing { display: flex; gap: .4rem; }
.sld-typing input { flex: 1; min-inline-size: 0; padding: .4rem .55rem; border: 1px solid var(--sld-border);
  border-radius: .25rem; background: var(--sld-card); color: inherit; font: inherit; font-size: .8rem; }
.sld-typing button { border: 0; border-radius: .25rem; background: var(--sld-navy); color: #FFFFFF;
  cursor: pointer; padding-inline: .7rem; font: inherit; font-size: .8rem; font-weight: 600; }
.sld-bar { display: flex; justify-content: center; gap: .15rem; block-size: 2.75rem;
  background: var(--sld-navy); color: #FFFFFF; }
.sld-util { position: relative; display: grid; place-items: center; inline-size: 3.4rem; border: 0;
  background: transparent; color: #FFFFFF; cursor: pointer; }
.sld-util::after { content: ''; position: absolute; inset-inline: 15%; inset-block-end: 0; block-size: 3px;
  background: transparent; }
.sld-util[aria-expanded='true'] { background: color-mix(in srgb, #FFFFFF 10%, transparent); }
.sld-util[aria-expanded='true']::after { background: #FFFFFF; }
.sld-count { position: absolute; inset-block-start: .3rem; inset-inline-end: .45rem; min-inline-size: 1rem;
  padding-inline: .22rem; block-size: 1rem; display: grid; place-items: center; border-radius: .5rem;
  background: #EA001E; color: #FFFFFF; font-size: .6rem; font-weight: 700; box-shadow: 0 0 0 2px var(--sld-navy); }
</style>