feat(inventory): add mobile tab support for inventory section
- Include inventory in mobile tab system alongside user stats - Add inventory to Stats tab (grouped with user stats) - Update setupMobileTabs() to detect and organize inventory section - Update removeMobileTabs() to restore inventory in correct order - Handle inventory show/hide in mobile tab transitions Inventory now works seamlessly on mobile viewports with proper tab organization.
This commit is contained in:
@@ -512,17 +512,19 @@ export function setupMobileTabs() {
|
|||||||
const $userStats = $('#rpg-user-stats');
|
const $userStats = $('#rpg-user-stats');
|
||||||
const $infoBox = $('#rpg-info-box');
|
const $infoBox = $('#rpg-info-box');
|
||||||
const $thoughts = $('#rpg-thoughts');
|
const $thoughts = $('#rpg-thoughts');
|
||||||
|
const $inventory = $('#rpg-inventory');
|
||||||
|
|
||||||
// If no sections exist, nothing to organize
|
// If no sections exist, nothing to organize
|
||||||
if ($userStats.length === 0 && $infoBox.length === 0 && $thoughts.length === 0) {
|
if ($userStats.length === 0 && $infoBox.length === 0 && $thoughts.length === 0 && $inventory.length === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create tab navigation (only show tabs for sections that exist)
|
// Create tab navigation (only show tabs for sections that exist)
|
||||||
const tabs = [];
|
const tabs = [];
|
||||||
const hasInfoOrCharacters = $infoBox.length > 0 || $thoughts.length > 0;
|
const hasInfoOrCharacters = $infoBox.length > 0 || $thoughts.length > 0;
|
||||||
|
const hasStatsOrInventory = $userStats.length > 0 || $inventory.length > 0;
|
||||||
|
|
||||||
if ($userStats.length > 0) {
|
if (hasStatsOrInventory) {
|
||||||
tabs.push('<button class="rpg-mobile-tab active" data-tab="stats"><i class="fa-solid fa-chart-bar"></i><span>Stats</span></button>');
|
tabs.push('<button class="rpg-mobile-tab active" data-tab="stats"><i class="fa-solid fa-chart-bar"></i><span>Stats</span></button>');
|
||||||
}
|
}
|
||||||
// Combine Info and Characters into one tab
|
// Combine Info and Characters into one tab
|
||||||
@@ -534,7 +536,7 @@ export function setupMobileTabs() {
|
|||||||
|
|
||||||
// Determine which tab should be active
|
// Determine which tab should be active
|
||||||
let firstTab = '';
|
let firstTab = '';
|
||||||
if ($userStats.length > 0) firstTab = 'stats';
|
if (hasStatsOrInventory) firstTab = 'stats';
|
||||||
else if (hasInfoOrCharacters) firstTab = 'info-characters';
|
else if (hasInfoOrCharacters) firstTab = 'info-characters';
|
||||||
|
|
||||||
// Create tab content wrappers
|
// Create tab content wrappers
|
||||||
@@ -549,6 +551,10 @@ export function setupMobileTabs() {
|
|||||||
$statsTab.append($userStats.detach());
|
$statsTab.append($userStats.detach());
|
||||||
$userStats.show();
|
$userStats.show();
|
||||||
}
|
}
|
||||||
|
if ($inventory.length > 0) {
|
||||||
|
$statsTab.append($inventory.detach());
|
||||||
|
$inventory.show();
|
||||||
|
}
|
||||||
if ($infoBox.length > 0) {
|
if ($infoBox.length > 0) {
|
||||||
$combinedWrapper.append($infoBox.detach());
|
$combinedWrapper.append($infoBox.detach());
|
||||||
$infoBox.show();
|
$infoBox.show();
|
||||||
@@ -571,7 +577,7 @@ export function setupMobileTabs() {
|
|||||||
$mobileContainer.append($tabNav);
|
$mobileContainer.append($tabNav);
|
||||||
|
|
||||||
// Only append tab content wrappers that have content
|
// Only append tab content wrappers that have content
|
||||||
if ($userStats.length > 0) $mobileContainer.append($statsTab);
|
if (hasStatsOrInventory) $mobileContainer.append($statsTab);
|
||||||
if (hasInfoOrCharacters) $mobileContainer.append($infoCharactersTab);
|
if (hasInfoOrCharacters) $mobileContainer.append($infoCharactersTab);
|
||||||
|
|
||||||
// Insert mobile tab structure at the beginning of content box
|
// Insert mobile tab structure at the beginning of content box
|
||||||
@@ -599,6 +605,7 @@ export function removeMobileTabs() {
|
|||||||
const $userStats = $('#rpg-user-stats').detach();
|
const $userStats = $('#rpg-user-stats').detach();
|
||||||
const $infoBox = $('#rpg-info-box').detach();
|
const $infoBox = $('#rpg-info-box').detach();
|
||||||
const $thoughts = $('#rpg-thoughts').detach();
|
const $thoughts = $('#rpg-thoughts').detach();
|
||||||
|
const $inventory = $('#rpg-inventory').detach();
|
||||||
|
|
||||||
// Remove mobile tab container
|
// Remove mobile tab container
|
||||||
$('.rpg-mobile-container').remove();
|
$('.rpg-mobile-container').remove();
|
||||||
@@ -606,17 +613,20 @@ export function removeMobileTabs() {
|
|||||||
// Get dividers
|
// Get dividers
|
||||||
const $dividerStats = $('#rpg-divider-stats');
|
const $dividerStats = $('#rpg-divider-stats');
|
||||||
const $dividerInfo = $('#rpg-divider-info');
|
const $dividerInfo = $('#rpg-divider-info');
|
||||||
|
const $dividerThoughts = $('#rpg-divider-thoughts');
|
||||||
|
|
||||||
// Restore original sections to content box in correct order
|
// Restore original sections to content box in correct order
|
||||||
const $contentBox = $('.rpg-content-box');
|
const $contentBox = $('.rpg-content-box');
|
||||||
|
|
||||||
// Re-insert sections in original order
|
// Re-insert sections in original order: User Stats, Info Box, Thoughts, Inventory
|
||||||
if ($dividerStats.length) {
|
if ($dividerStats.length) {
|
||||||
$dividerStats.before($userStats);
|
$dividerStats.before($userStats);
|
||||||
$dividerInfo.before($infoBox);
|
$dividerInfo.before($infoBox);
|
||||||
$contentBox.append($thoughts);
|
$dividerThoughts.before($thoughts);
|
||||||
|
$contentBox.append($inventory);
|
||||||
} else {
|
} else {
|
||||||
// Fallback if dividers don't exist
|
// Fallback if dividers don't exist
|
||||||
|
$contentBox.prepend($inventory);
|
||||||
$contentBox.prepend($thoughts);
|
$contentBox.prepend($thoughts);
|
||||||
$contentBox.prepend($infoBox);
|
$contentBox.prepend($infoBox);
|
||||||
$contentBox.prepend($userStats);
|
$contentBox.prepend($userStats);
|
||||||
@@ -626,6 +636,7 @@ export function removeMobileTabs() {
|
|||||||
$userStats.show();
|
$userStats.show();
|
||||||
$infoBox.show();
|
$infoBox.show();
|
||||||
$thoughts.show();
|
$thoughts.show();
|
||||||
|
$inventory.show();
|
||||||
$('.rpg-divider').show();
|
$('.rpg-divider').show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user