Skip to content

Repository files navigation

@sourecode/frame

CI

A dockable panel layout system for building IDE-style UIs.

Installation

Download the tarball from the latest GitHub Release and install it:

npm install https://github.com/SoureCode/frame/releases/download/v0.1.0/sourecode-frame-0.1.0.tgz

Import the stylesheet:

import'@sourecode/frame/styles';

Quick Start

import{FrameLayout,LocalStorageAdapter,SlotName}from'@sourecode/frame';importtype{PanelConfig}from'@sourecode/frame';constpanels: PanelConfig[]=[{id: 'explorer',title: 'Explorer',slot: SlotName.LeftTop,pinned: true},{id: 'debug',title: 'Debug',slot: SlotName.LeftBottom,pinned: true},{id: 'outline',title: 'Outline',slot: SlotName.RightTop,pinned: false},];constlayout=newFrameLayout(document.getElementById('app')!,panels,{animated: true,storage: newLocalStorageAdapter('my-layout'),});

API

new FrameLayout(mount, panels, options?)

ParameterTypeDescription
mountHTMLElementElement to render the layout into
panelsPanelConfig[]Panel definitions
optionsFrameOptionsOptional configuration

FrameOptions

PropertyTypeDescription
animatedbooleanEnable CSS transitions
transitionTransitionConfigCustom { duration, easing }
storageStorageAdapterPersist layout state
railsPartial<Record<DockEdge, RailConfig>>Per-rail configuration

Instance properties and methods

MemberDescription
elementThe root HTMLElement
getStage()Returns the central content area HTMLElement
getState()Returns the current LayoutState
getTheme()Returns the current Theme | string
setTheme(theme)Set theme by name (Theme or custom string)
setWidescreen(enabled)Toggle widescreen mode
setAnimated(enabled)Toggle animations at runtime
openPanel(id)Activate a panel
closePanel(id)Deactivate a panel
toggleFullscreen(id)Toggle a panel to fullscreen over the frame
movePanel(id, slot)Move a panel to a different SlotName
disableRail(edge, autoMoveTarget?)Disable a rail and its dock
enableRail(edge)Re-enable a disabled rail
isRailDisabled(edge)Check if a rail is disabled
destroy()Remove the layout from the DOM and clean up

PanelConfig

PropertyTypeDescription
idstringUnique panel identifier
titlestringDisplay title
slotSlotNameInitial slot position
pinnedbooleanKeep panel open when dock is inactive
fullscreenablebooleanShow fullscreen button (default true)
iconPanelIconOptional icon (HTMLElement, SVG string, or factory)
contentHTMLElementOptional panel body element

SlotName

enumSlotName{LeftTop,LeftBottom,RightTop,RightBottom,TopLeft,TopRight,BottomLeft,BottomRight,}

DockEdge

enumDockEdge{Left,Right,Top,Bottom,}

RailConfig

PropertyTypeDescription
disabledbooleanDisable this rail (default false)
autoMoveTargetDockEdgeMove panels to this edge when disabling

LocalStorageAdapter

Persists layout state to localStorage.

conststorage=newLocalStorageAdapter('storage-key');

Implements StorageAdapter:

interfaceStorageAdapter{load(): LayoutState|null;save(state: LayoutState): void;}

Events

All events are CustomEvents dispatched on the frame element with bubbles: true.

EventDetailDescription
frame:theme{ theme, previous }Theme changed via setTheme()
frame:fullscreen{ panelId, slot }Panel fullscreen toggled
frame:pin{ panelId, slot }Panel pin toggled
frame:close{ panelId, slot }Panel closed
frame:rail-click{ panelId, slot }Rail icon clicked
frame:rail-move{ panelId, toSlot, beforePanelId }Panel moved via rail drag
frame:splitter-change{ edge, ratio }Splitter position changed
frame:resizer-change{ edge, size }Dock resized
frame:rail-disabled{ edge, disabled }Rail enabled or disabled
frame:overlay-close{ edge }Click outside unpinned dock

Theming

Set data-theme on the mount element or use setTheme() / getTheme():

layout.setTheme('dracula');layout.element.addEventListener('frame:theme',(e)=>{console.log(e.detail.previous,'->',e.detail.theme);});

Available themes:

  • obsidian (default; omit data-theme or set it to empty)
  • light
  • solarized
  • rose
  • paper
  • high-contrast
  • warm
  • nord
  • terminal
  • dracula
  • monokai
  • glass-dark
  • glass-light
  • catppuccin
  • gruvbox
  • tokyo-night
  • synthwave
  • everforest
  • sepia
  • github-light
  • github-dark
  • github-dimmed
  • ayu
  • mint
  • lavender
  • sky
  • sand

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages