feat: implement Skills widget with level progression and categories

Add comprehensive Skills widget to dashboard system with category organization,
XP tracking, level progression, and multiple view modes.

Widget Features:
- Three sub-tabs: All Skills, By Category, Quick View
- Level-up and level-down buttons for manual progression
- XP progress bars with visual feedback
- Search and filter functionality
- Category collapse/expand in By Category view
- Editable skill names and categories
- Delete skills and categories
- Add new skills and categories
- Configurable max level and XP display

UI Improvements:
- Scrollable content area for large skill lists
- Responsive card layout
- Shortened tab labels for compact display ("All", "Quick" vs "All Skills", "Quick View")
- Proper flex layout for skill names (no longer truncated)
- Level badges and action buttons

Technical Implementation:
- Event handler deduplication to prevent exponential level-up bug
- Flag-based handler attachment: container.dataset.handlersAttached
- Nested flex containers for proper space distribution
- Scrollable views wrapper matching Inventory/Quests pattern

Dashboard Integration:
- Added Skills tab to defaultLayout.js (tab 5)
  - Icon: fa-solid fa-book (fixed invalid fa-book-sparkles)
  - Dimensions: 3x7 grid cells
  - Default config: All Skills tab, show XP, show categories
- Auto-arrange support in dashboardManager.js
  - Skills category group with priority order 6
  - Auto-creates Skills tab when skills widgets detected
- Widget registration in dashboardIntegration.js

Widget Files:
- src/systems/dashboard/widgets/userSkillsWidget.js (new)
  - Full widget implementation with all sub-tabs and features
  - State management with Map-based storage
  - Category-based and flat views
  - Search/filter/sort functionality

Styling:
- style.css: Added skills widget styles
  - Skill cards, headers, action buttons
  - Level-down button with accent color
  - XP progress bars
  - Category sections

Fixes from iteration:
1. Invalid FontAwesome icon (fa-book-sparkles → fa-book)
2. Tab labels too wide (shortened to single words)
3. Skill names truncated (fixed with proper flex structure)
4. Widget height incorrect (adjusted to h:7)
5. Level-up exponential bug (duplicate handlers, added flag guard)
6. No level-down button (added with minimum level 1)
7. No scrollbar on long lists (added .rpg-skills-views wrapper)

Category: skills
Integration: Fully integrated with dashboard v2.0 system
Tested: Layout, interactions, scrolling, level progression

Refs: AI tracker integration (separate commit)
This commit is contained in:
Lucas 'Paperboy' Rose-Winters
2025-11-06 22:08:48 +11:00
parent 0f96c62c62
commit a9d98a3076
5 changed files with 1821 additions and 2 deletions
@@ -27,6 +27,7 @@ import { registerSceneInfoWidget } from './widgets/sceneInfoWidget.js';
import { registerPresentCharactersWidget } from './widgets/presentCharactersWidget.js'; import { registerPresentCharactersWidget } from './widgets/presentCharactersWidget.js';
import { registerInventoryWidget } from './widgets/inventoryWidget.js'; import { registerInventoryWidget } from './widgets/inventoryWidget.js';
import { registerQuestsWidget } from './widgets/questsWidget.js'; import { registerQuestsWidget } from './widgets/questsWidget.js';
import { registerUserSkillsWidget } from './widgets/userSkillsWidget.js';
// Global dashboard manager instance // Global dashboard manager instance
let dashboardManager = null; let dashboardManager = null;
@@ -254,6 +255,9 @@ function registerAllWidgets(registry, dependencies) {
// Quest widget // Quest widget
registerQuestsWidget(registry, dependencies); registerQuestsWidget(registry, dependencies);
// Skills widget
registerUserSkillsWidget(registry, dependencies);
console.log(`[RPG Companion] Registered ${registry.getAll().length} widgets`); console.log(`[RPG Companion] Registered ${registry.getAll().length} widgets`);
} }
+17 -2
View File
@@ -949,7 +949,8 @@ export class DashboardManager {
scene: [], scene: [],
social: [], social: [],
inventory: [], inventory: [],
quests: [] quests: [],
skills: []
}; };
widgets.forEach(widget => { widgets.forEach(widget => {
@@ -1031,6 +1032,19 @@ export class DashboardManager {
this.gridEngine.autoLayout(groups.quests, { preserveOrder: true }); this.gridEngine.autoLayout(groups.quests, { preserveOrder: true });
} }
// Create Skills tab if there are skills widgets
if (groups.skills.length > 0) {
this.dashboard.tabs.push({
id: 'tab-skills',
name: 'Skills',
icon: 'fa-solid fa-book',
order: 5,
widgets: groups.skills
});
this.gridEngine.autoLayout(groups.skills, { preserveOrder: true });
}
console.log('[DashboardManager] Created', this.dashboard.tabs.length, 'tabs'); console.log('[DashboardManager] Created', this.dashboard.tabs.length, 'tabs');
// Re-render tabs and switch to first tab // Re-render tabs and switch to first tab
@@ -1070,7 +1084,8 @@ export class DashboardManager {
'social': 3, 'social': 3,
'inventory': 4, 'inventory': 4,
'quests': 5, 'quests': 5,
'other': 6 'skills': 6,
'other': 7
}; };
// Specific widget type ordering within user category // Specific widget type ordering within user category
+23
View File
@@ -167,6 +167,29 @@ export function generateDefaultDashboard() {
} }
} }
] ]
},
// Tab 5: Skills (Full tab for skills system)
{
id: 'tab-skills',
name: 'Skills',
icon: 'fa-solid fa-book',
order: 4,
widgets: [
{
id: 'widget-userskills',
type: 'userSkills',
x: 0,
y: 0,
w: 3,
h: 7,
config: {
defaultSubTab: 'all',
showXP: true,
showCategories: true,
maxLevel: 10
}
}
]
} }
], ],
File diff suppressed because it is too large Load Diff
+698
View File
@@ -4370,6 +4370,82 @@ body:has(.rpg-panel.rpg-position-left) #sheld {
color: var(--rpg-highlight); color: var(--rpg-highlight);
} }
/* Apply theme colors to skills subtabs */
.rpg-panel[data-theme="sci-fi"] .rpg-skills-subtabs,
.rpg-panel[data-theme="fantasy"] .rpg-skills-subtabs,
.rpg-panel[data-theme="cyberpunk"] .rpg-skills-subtabs {
border-bottom-color: var(--rpg-border);
}
.rpg-panel[data-theme="sci-fi"] .rpg-skills-subtab,
.rpg-panel[data-theme="fantasy"] .rpg-skills-subtab,
.rpg-panel[data-theme="cyberpunk"] .rpg-skills-subtab {
border-color: var(--rpg-border);
color: var(--rpg-text);
}
.rpg-panel[data-theme="sci-fi"] .rpg-skills-subtab:hover,
.rpg-panel[data-theme="fantasy"] .rpg-skills-subtab:hover,
.rpg-panel[data-theme="cyberpunk"] .rpg-skills-subtab:hover {
border-color: var(--rpg-highlight);
color: var(--rpg-highlight);
}
.rpg-panel[data-theme="sci-fi"] .rpg-skills-subtab.active,
.rpg-panel[data-theme="fantasy"] .rpg-skills-subtab.active,
.rpg-panel[data-theme="cyberpunk"] .rpg-skills-subtab.active {
border-color: var(--rpg-highlight);
color: var(--rpg-highlight);
}
/* Apply theme colors to skill cards */
.rpg-panel[data-theme="sci-fi"] .rpg-skill-card,
.rpg-panel[data-theme="fantasy"] .rpg-skill-card,
.rpg-panel[data-theme="cyberpunk"] .rpg-skill-card {
border-color: var(--rpg-border);
}
.rpg-panel[data-theme="sci-fi"] .rpg-skill-card:hover,
.rpg-panel[data-theme="fantasy"] .rpg-skill-card:hover,
.rpg-panel[data-theme="cyberpunk"] .rpg-skill-card:hover {
border-color: var(--rpg-highlight);
}
/* Apply theme colors to category headers */
.rpg-panel[data-theme="sci-fi"] .rpg-category-header,
.rpg-panel[data-theme="fantasy"] .rpg-category-header,
.rpg-panel[data-theme="cyberpunk"] .rpg-category-header {
background: var(--rpg-highlight);
border-color: var(--rpg-border);
}
.rpg-panel[data-theme="sci-fi"] .rpg-category-name,
.rpg-panel[data-theme="fantasy"] .rpg-category-name,
.rpg-panel[data-theme="cyberpunk"] .rpg-category-name {
color: var(--rpg-text);
}
/* Apply theme colors to XP bars */
.rpg-panel[data-theme="sci-fi"] .rpg-xp-bar,
.rpg-panel[data-theme="fantasy"] .rpg-xp-bar,
.rpg-panel[data-theme="cyberpunk"] .rpg-xp-bar {
border-color: var(--rpg-border);
}
.rpg-panel[data-theme="sci-fi"] .rpg-xp-fill,
.rpg-panel[data-theme="fantasy"] .rpg-xp-fill,
.rpg-panel[data-theme="cyberpunk"] .rpg-xp-fill {
background: linear-gradient(90deg, var(--rpg-highlight), var(--rpg-accent));
}
/* Apply theme colors to skills add button */
.rpg-panel[data-theme="sci-fi"] .rpg-skills-add-btn,
.rpg-panel[data-theme="fantasy"] .rpg-skills-add-btn,
.rpg-panel[data-theme="cyberpunk"] .rpg-skills-add-btn {
border-color: var(--rpg-highlight);
color: var(--rpg-highlight);
}
/* Apply theme colors to storage locations */ /* Apply theme colors to storage locations */
.rpg-panel[data-theme="sci-fi"] .rpg-storage-location, .rpg-panel[data-theme="sci-fi"] .rpg-storage-location,
.rpg-panel[data-theme="fantasy"] .rpg-storage-location, .rpg-panel[data-theme="fantasy"] .rpg-storage-location,
@@ -7723,6 +7799,628 @@ body:has(.rpg-panel.rpg-position-left) #sheld {
color: var(--rpg-highlight); color: var(--rpg-highlight);
} }
/* ============================================
SKILLS WIDGET STYLES
============================================ */
/* Skills Widget - Flex container for proper scrolling */
.rpg-skills-widget {
display: flex;
flex-direction: column;
flex: 1;
min-height: 0;
overflow: hidden;
}
/* Skills Views - Scrollable content area */
.rpg-skills-views {
flex: 1;
min-height: 0;
overflow-y: auto;
overflow-x: hidden;
}
/* Skills Sub-tabs Navigation */
.rpg-skills-subtabs {
display: flex;
gap: 0.5rem;
border-bottom: 2px solid var(--SmartThemeBorderColor);
padding-bottom: 0.5rem;
overflow-x: auto;
overflow-y: hidden;
flex-wrap: nowrap;
scrollbar-width: thin;
scrollbar-color: var(--SmartThemeBorderColor) transparent;
}
.rpg-skills-subtabs::-webkit-scrollbar {
height: 6px;
}
.rpg-skills-subtabs::-webkit-scrollbar-track {
background: transparent;
}
.rpg-skills-subtabs::-webkit-scrollbar-thumb {
background: var(--SmartThemeBorderColor);
border-radius: 3px;
}
.rpg-skills-subtabs::-webkit-scrollbar-thumb:hover {
background: var(--rpg-accent);
}
.rpg-skills-subtab {
flex: 1;
min-width: fit-content;
white-space: nowrap;
padding: 0.5rem 1rem;
background: transparent;
border: 2px solid var(--SmartThemeBorderColor);
border-radius: 0.25rem;
color: var(--SmartThemeBodyColor);
cursor: pointer;
transition: all 0.2s ease;
font-weight: 500;
display: flex;
align-items: center;
justify-content: center;
gap: 0.5rem;
}
.rpg-skills-subtab i {
font-size: 1rem;
}
.rpg-skills-subtab:hover {
background: rgba(var(--rpg-highlight-rgb, 233, 69, 96), 0.1);
border-color: var(--rpg-highlight);
color: var(--rpg-highlight);
}
.rpg-skills-subtab.active {
background: transparent;
border-color: var(--rpg-highlight);
color: var(--rpg-highlight);
font-weight: 600;
}
/* Skills Sections */
.rpg-skills-section {
display: flex;
flex-direction: column;
gap: 0.75rem;
}
.rpg-skills-header {
display: flex;
justify-content: space-between;
align-items: center;
padding-bottom: 0.5rem;
border-bottom: 1px solid var(--SmartThemeBorderColor);
gap: 0.5rem;
overflow-x: auto;
overflow-y: hidden;
flex-wrap: nowrap;
scrollbar-width: thin;
scrollbar-color: var(--SmartThemeBorderColor) transparent;
}
.rpg-skills-header::-webkit-scrollbar {
height: 6px;
}
.rpg-skills-header::-webkit-scrollbar-track {
background: transparent;
}
.rpg-skills-header::-webkit-scrollbar-thumb {
background: var(--SmartThemeBorderColor);
border-radius: 3px;
}
.rpg-skills-header::-webkit-scrollbar-thumb:hover {
background: var(--rpg-accent);
}
.rpg-skills-header h4 {
margin: 0;
font-size: 1.1rem;
color: var(--SmartThemeBodyColor);
white-space: nowrap;
min-width: fit-content;
}
.rpg-skills-content {
display: flex;
flex-direction: column;
gap: 0.75rem;
}
/* Skills Add Button */
.rpg-skills-add-btn {
padding: 0.4rem 0.75rem;
border: 1px solid var(--SmartThemeBorderColor);
border-radius: 0.25rem;
background: transparent;
border-color: var(--rpg-highlight);
color: var(--rpg-highlight);
white-space: nowrap;
min-width: fit-content;
cursor: pointer;
transition: all 0.2s ease;
font-size: 0.85rem;
display: flex;
align-items: center;
gap: 0.35rem;
}
.rpg-skills-add-btn:hover {
background: rgba(var(--rpg-highlight-rgb, 233, 69, 96), 0.1);
border-color: var(--rpg-highlight);
}
/* Skills Empty State */
.rpg-skills-empty {
padding: 2rem;
text-align: center;
color: var(--SmartThemeFastUISliderColColor);
font-style: italic;
font-size: 0.9rem;
}
/* Skills Filter */
.rpg-skills-filter {
margin-bottom: 0.75rem;
}
.rpg-filter-input {
width: 100%;
padding: 0.5rem 0.75rem;
background: var(--SmartThemeBlurTintColor);
border: 1px solid var(--SmartThemeBorderColor);
border-radius: 0.25rem;
color: var(--SmartThemeBodyColor);
font-size: 0.9rem;
font-family: inherit;
}
.rpg-filter-input:focus {
outline: none;
border-color: var(--ac-style-color-matchedText);
box-shadow: 0 0 0 2px rgba(var(--ac-style-color-matchedText-rgb, 66, 135, 245), 0.2);
}
.rpg-filter-input::placeholder {
color: var(--SmartThemeFastUISliderColColor);
font-style: italic;
}
/* Category Headers (Collapsible) */
.rpg-category-header {
display: flex;
align-items: center;
gap: 0.5rem;
padding: 0.5rem;
background: var(--SmartThemeQuoteColor);
border: 1px solid var(--SmartThemeBorderColor);
border-radius: 0.25rem;
cursor: pointer;
margin-top: 0.5rem;
}
.rpg-category-toggle {
background: none;
border: none;
color: var(--SmartThemeBodyColor);
cursor: pointer;
padding: 0.25rem;
display: flex;
align-items: center;
justify-content: center;
transition: transform 0.2s ease;
}
.rpg-category-toggle:hover {
color: var(--ac-style-color-matchedText);
}
.rpg-category-toggle i {
transition: transform 0.2s ease;
}
.rpg-category-header.collapsed .rpg-category-toggle i {
transform: rotate(-90deg);
}
.rpg-category-name {
flex: 1;
margin: 0;
font-size: 1rem;
font-weight: 600;
color: #000000;
}
.rpg-category-actions {
display: flex;
gap: 0.5rem;
}
.rpg-category-content {
margin-top: 0.75rem;
}
.rpg-category-header.collapsed + .rpg-category-content {
display: none;
}
/* Skill Cards - List and Grid Views */
.rpg-skills-list {
display: flex;
flex-direction: column;
gap: 0.5rem;
min-height: 2rem;
padding: 0.5rem 0;
}
.rpg-skill-card {
display: flex;
align-items: center;
justify-content: space-between;
gap: 1rem;
padding: 0.75rem 1rem;
background: transparent;
border: 2px solid var(--rpg-highlight);
border-radius: 0.25rem;
color: var(--SmartThemeBodyColor);
font-size: 0.95rem;
transition: all 0.2s ease;
}
.rpg-skill-card:hover {
border-color: var(--rpg-highlight);
background: rgba(var(--rpg-highlight-rgb, 233, 69, 96), 0.1);
}
.rpg-skill-info {
flex: 1;
display: flex;
flex-direction: column;
gap: 0.35rem;
min-width: 0;
}
.rpg-skill-header-row {
display: flex;
align-items: center;
gap: 0.75rem;
}
.rpg-skill-name {
font-weight: 500;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
cursor: text;
}
.rpg-skill-name.rpg-editable {
border-bottom: 1px dashed var(--SmartThemeBorderColor);
transition: all 0.2s ease;
}
.rpg-skill-name.rpg-editable:hover {
border-bottom-color: var(--ac-style-color-matchedText);
}
.rpg-skill-name.rpg-editable:focus {
outline: none;
border-bottom-color: var(--ac-style-color-matchedText);
background: var(--SmartThemeQuoteColor);
}
.rpg-skill-level {
font-size: 0.85rem;
color: var(--rpg-highlight);
font-weight: 600;
white-space: nowrap;
}
.rpg-skill-actions {
display: flex;
gap: 0.5rem;
align-items: center;
flex-shrink: 0;
}
.rpg-skill-action {
padding: 0.3rem 0.6rem;
background: transparent;
border: 1px solid var(--SmartThemeBorderColor);
border-radius: 0.25rem;
color: var(--SmartThemeBodyColor);
cursor: pointer;
transition: all 0.2s ease;
font-size: 0.85rem;
white-space: nowrap;
}
.rpg-skill-action:hover {
background: var(--ac-style-color-matchedText);
border-color: var(--ac-style-color-matchedText);
color: white;
}
.rpg-skill-action.rpg-level-up-btn {
border-color: var(--rpg-highlight);
color: var(--rpg-highlight);
}
.rpg-skill-action.rpg-level-up-btn:hover {
background: var(--rpg-highlight);
color: white;
}
.rpg-skill-action.rpg-level-down-btn {
border-color: var(--rpg-accent);
color: var(--rpg-accent);
}
.rpg-skill-action.rpg-level-down-btn:hover {
background: var(--rpg-accent);
color: white;
}
.rpg-skill-action.rpg-delete-btn {
color: var(--SmartThemeFastUISliderColColor);
}
.rpg-skill-action.rpg-delete-btn:hover {
background: #dc3545;
border-color: #dc3545;
color: white;
}
/* XP Progress Bar */
.rpg-xp-bar {
position: relative;
width: 100%;
height: 1.25rem;
background: var(--SmartThemeBlurTintColor);
border: 1px solid var(--SmartThemeBorderColor);
border-radius: 0.25rem;
overflow: hidden;
}
.rpg-xp-fill {
position: absolute;
top: 0;
left: 0;
height: 100%;
background: linear-gradient(90deg,
var(--rpg-highlight),
rgba(var(--rpg-highlight-rgb, 233, 69, 96), 0.7));
transition: width 0.3s ease;
border-radius: 0.25rem 0 0 0.25rem;
}
.rpg-xp-text {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
font-size: 0.75rem;
font-weight: 600;
color: var(--SmartThemeBodyColor);
text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}
/* Grid View for Skills */
.rpg-skills-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
gap: 0.75rem;
padding: 0.5rem 0;
}
.rpg-skills-grid .rpg-skill-card {
flex-direction: column;
align-items: stretch;
padding: 1rem 0.75rem;
min-height: 100px;
}
.rpg-skills-grid .rpg-skill-info {
align-items: center;
text-align: center;
}
.rpg-skills-grid .rpg-skill-header-row {
flex-direction: column;
gap: 0.5rem;
}
.rpg-skills-grid .rpg-skill-name {
text-align: center;
word-wrap: break-word;
overflow-wrap: break-word;
white-space: normal;
max-width: 100%;
}
.rpg-skills-grid .rpg-skill-actions {
flex-direction: column;
width: 100%;
}
.rpg-skills-grid .rpg-skill-action {
width: 100%;
}
/* Quick View - Compact List */
.rpg-skills-quick-list {
display: flex;
flex-direction: column;
gap: 0.35rem;
padding: 0.5rem 0;
}
.rpg-skills-quick-list .rpg-skill-card {
padding: 0.5rem 0.75rem;
gap: 0.5rem;
}
.rpg-skills-quick-list .rpg-skill-info {
gap: 0;
}
.rpg-skills-quick-list .rpg-xp-bar {
display: none;
}
.rpg-skills-quick-list .rpg-skill-action {
padding: 0.25rem 0.5rem;
font-size: 0.8rem;
}
/* Inline Forms for Skills and Categories */
.rpg-add-skill-form,
.rpg-add-category-form {
display: flex;
flex-direction: column;
gap: 0.5rem;
padding: 0.75rem;
background: var(--SmartThemeQuoteColor);
border: 1px solid var(--ac-style-color-matchedText);
border-radius: 0.25rem;
margin-bottom: 0.75rem;
}
/* Header Actions (View Toggle + Add Button) */
.rpg-skills-header-actions {
display: flex;
align-items: center;
gap: 0.75rem;
flex-wrap: nowrap;
min-width: fit-content;
}
/* Sort and Filter Controls */
.rpg-skills-controls {
display: flex;
gap: 0.75rem;
align-items: center;
flex-wrap: wrap;
margin-bottom: 0.75rem;
}
.rpg-sort-dropdown {
padding: 0.4rem 0.75rem;
background: var(--SmartThemeBlurTintColor);
border: 1px solid var(--SmartThemeBorderColor);
border-radius: 0.25rem;
color: var(--SmartThemeBodyColor);
font-size: 0.85rem;
cursor: pointer;
transition: all 0.2s ease;
}
.rpg-sort-dropdown:hover {
border-color: var(--ac-style-color-matchedText);
}
.rpg-sort-dropdown:focus {
outline: none;
border-color: var(--ac-style-color-matchedText);
box-shadow: 0 0 0 2px rgba(var(--ac-style-color-matchedText-rgb, 66, 135, 245), 0.2);
}
/* Responsive Classes - Wide Layout */
.rpg-skills-wide .rpg-skills-header h4 {
font-size: 1.2rem;
}
.rpg-skills-wide .rpg-skill-card {
padding: 1rem 1.25rem;
}
/* Responsive Classes - Compact Layout */
.rpg-skills-compact .rpg-skills-header h4 {
font-size: 1rem;
}
.rpg-skills-compact .rpg-skill-card {
padding: 0.5rem 0.75rem;
gap: 0.75rem;
}
.rpg-skills-compact .rpg-skills-add-btn {
font-size: 0.8rem;
padding: 0.35rem 0.6rem;
}
.rpg-skills-compact .rpg-skill-action {
padding: 0.25rem 0.5rem;
font-size: 0.8rem;
}
.rpg-skills-compact .rpg-xp-bar {
height: 1rem;
}
.rpg-skills-compact .rpg-xp-text {
font-size: 0.7rem;
}
/* Mobile Responsiveness for Skills */
@media (max-width: 768px) {
.rpg-skills-subtabs {
gap: 0.35rem;
}
.rpg-skills-subtab {
padding: 0.4rem 0.75rem;
font-size: 0.85rem;
}
.rpg-skills-subtab .rpg-subtab-label {
display: none;
}
.rpg-skills-grid {
grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
gap: 0.5rem;
}
.rpg-skills-header {
flex-wrap: wrap;
}
.rpg-skills-header h4 {
font-size: 1rem;
}
.rpg-skill-card {
flex-direction: column;
align-items: flex-start;
gap: 0.75rem;
}
.rpg-skill-actions {
width: 100%;
flex-wrap: wrap;
}
.rpg-skill-action {
flex: 1;
min-width: fit-content;
}
}
/* ============================================ /* ============================================
DESKTOP TABS SYSTEM DESKTOP TABS SYSTEM
============================================ */ ============================================ */