Skip to main content

Skilling Panel Components

Shared React components for consistent skilling panel layouts across Fletching, Cooking, Smelting, Smithing, Crafting, and Tanning interfaces.

Overview

Added: March 26, 2026 (PR #1093) Purpose: Eliminate ~500 lines of duplicated styling and provide consistent visual language for all crafting/processing interfaces. Location: packages/client/src/game/panels/skilling/SkillingPanelShared.tsx

Components

SkillingPanelBody

Outer container for skilling panels with intro text and empty state handling.
Props:
  • theme - Theme object from useThemeStore
  • children - Panel content (recipe lists, quantity selectors)
  • emptyMessage - Message to show when no recipes available (optional)
  • intro - Introductory text explaining the panel (optional)
Usage:
Features:
  • Automatic empty state rendering when emptyMessage provided and no children
  • Intro text with secondary color styling
  • Consistent padding and layout

SkillingSection

Section container for grouping related recipes or controls.
Props:
  • theme - Theme object
  • children - Section content
  • className - Additional CSS classes (optional)
  • style - Additional inline styles (optional)
Usage:
Features:
  • Rounded corners with border
  • Panel secondary background
  • Inset highlight for depth
  • Consistent padding (12px)

SkillingQuantitySelector

Reusable quantity selector with preset buttons and custom input mode.
Props:
  • theme - Theme object
  • showCustomInput - Whether custom input mode is active
  • customQuantity - Current custom quantity input value
  • lastCustomQuantity - Last custom quantity (for placeholder)
  • onCustomQuantityChange - Handler for input value changes
  • onCustomSubmit - Handler for custom quantity submission
  • onCancelCustomInput - Handler for cancelling custom input
  • onPresetQuantity - Handler for preset button clicks (1, 5, 10, All)
  • allQuantity - Value for “All” button (-1 for max, or specific number like 28)
  • onShowCustomInput - Handler for “X” button click
Usage:
Features:
  • Preset buttons: 1, 5, 10, All, X
  • Custom input mode with Enter/Escape key handling
  • Remembers last custom quantity (OSRS feature)
  • Responsive grid layout (2 columns mobile, 5 columns desktop)
  • Cancel button in custom input mode
Keyboard Shortcuts:
  • Enter - Submit custom quantity
  • Escape - Cancel custom input mode

Style Helpers

getSkillingSelectableStyle()

Generate consistent style for selectable recipe items.
Parameters:
  • theme - Theme object
  • selected - Whether item is currently selected
  • disabled - Whether item is disabled (optional, default: false)
Returns: CSSProperties object with background, border, boxShadow, opacity Usage:
Visual States:
  • Selected: Accent primary background (18% opacity), accent border, inset glow
  • Unselected: Dark background, default border
  • Disabled: 48% opacity

getSkillingBadgeStyle()

Generate consistent style for info badges (level, XP, cost).
Parameters:
  • theme - Theme object
Returns: CSSProperties object with background, border, color Usage:
Visual Style:
  • Dark background (rgba(6, 8, 12, 0.34))
  • Default border
  • Secondary text color
  • Pill shape (rounded-full)

Example: Complete Skilling Panel

Migration from Old Panels

Before (Duplicated Code)

Each skilling panel had ~200 lines of duplicated styling:

After (Shared Components)

Reduction: ~200 lines → ~50 lines per panel

Panels Using Shared Components

All skilling panels now use shared components:
  1. FletchingPanel - Arrow shafts, bows, stringing, arrows
  2. CookingPanel - Fish, meat, bread (uses range/fire)
  3. SmeltingPanel - Bars from ores
  4. SmithingPanel - Weapons, armor, tools from bars
  5. CraftingPanel - Leather armor, jewelry, gem cutting
  6. TanningPanel - Hides to leather
Consistency Benefits:
  • Same layout and spacing
  • Same color scheme and hover states
  • Same quantity selector behavior
  • Same keyboard shortcuts
  • Same responsive breakpoints

Accessibility

Keyboard Navigation

  • Tab - Navigate between recipe buttons
  • Enter / Space - Select recipe
  • 1, 5, 0 (zero) - Quick quantity selection
  • X - Open custom quantity input
  • Enter - Submit custom quantity
  • Escape - Cancel custom input

Screen Readers

  • Recipe buttons have descriptive labels
  • Quantity buttons announce their values
  • Custom input has placeholder text
  • Empty state messages are announced

Focus Management

  • Focus trap within custom input mode
  • Autofocus on custom input when opened
  • Focus returns to “X” button after cancel

Theming

All components respect the active theme: Hyperscape Theme:
  • Warm gradients (bronze/gold accents)
  • Subtle inset highlights
  • Parchment-style backgrounds
Other Themes:
  • Accent primary color for selections
  • Theme-specific backgrounds and borders
  • Consistent with theme’s visual language

Performance

Memoization

Components use useMemo for expensive style calculations:

Render Optimization

  • React.memo not used (components are lightweight)
  • Style objects memoized to prevent re-creation
  • No expensive computations in render path

See Also