HTML IDs

HTML ID constants for HTMX targeting in the media gallery.

GalleryHtmlIds

Default HTML IDs used by the media gallery. These can be customized via GalleryConfig if needed to avoid conflicts.


GalleryHtmlIds


def GalleryHtmlIds(
    GALLERY:str='media-gallery', CONTENT:str='media-gallery-content', CONTROLS:str='media-gallery-controls',
    VIEW_TOGGLE:str='media-gallery-view-toggle', TYPE_FILTER:str='media-gallery-type-filter',
    GRID:str='media-gallery-grid', GRID_ITEM_PREFIX:str='media-gallery-item-', LIST:str='media-gallery-list',
    LIST_ITEM_PREFIX:str='media-gallery-row-', PREVIEW_MODAL:str='media-preview-modal',
    PREVIEW_CONTENT:str='media-preview-content', PREVIEW_PLAYER:str='media-preview-player',
    PREVIEW_INFO:str='media-preview-info', PAGINATION:str='media-gallery-pagination',
    CURRENT_PAGE_INPUT:str='media-gallery-current-page', VIEW_MODE_INPUT:str='media-gallery-view-mode',
    TYPE_FILTER_INPUT:str='media-gallery-type-filter-value', SELECTED_PATHS_INPUT:str='media-gallery-selected-paths',
    PREVIEW_PATH_INPUT:str='media-gallery-preview-path'
)->None:

Default HTML IDs for media gallery components.

# Test GalleryHtmlIds
ids = GalleryHtmlIds()

# Test constants
assert ids.GALLERY == "media-gallery"
assert ids.CONTENT == "media-gallery-content"
assert ids.CONTROLS == "media-gallery-controls"
assert ids.PREVIEW_MODAL == "media-preview-modal"
assert ids.PAGINATION == "media-gallery-pagination"

# Test grid_item_id
assert GalleryHtmlIds.grid_item_id(0) == "media-gallery-item-0"
assert GalleryHtmlIds.grid_item_id(42) == "media-gallery-item-42"

# Test list_item_id
assert GalleryHtmlIds.list_item_id(0) == "media-gallery-row-0"
assert GalleryHtmlIds.list_item_id(99) == "media-gallery-row-99"

# Test as_selector
assert GalleryHtmlIds.as_selector(ids.GALLERY) == "#media-gallery"
assert GalleryHtmlIds.as_selector(ids.PREVIEW_MODAL) == "#media-preview-modal"

# Test frozen (immutable)
try:
    ids.GALLERY = "new-id"
    assert False, "Should have raised FrozenInstanceError"
except Exception:
    pass  # Expected

print("GalleryHtmlIds tests passed!")
GalleryHtmlIds tests passed!