Width slider, scale slider, and card count selector components.
render_width_slider
Range slider for adjusting the card stack viewport width. The oninput handler references the namespaced JS function window.cardStacks[prefix].updateWidth().
def render_width_slider( config:CardStackConfig, # Card stack configuration ids:CardStackHtmlIds, # HTML IDs for this instance card_width:int=80, # Current card width in rem)->Any: # Width slider component
def render_card_count_select( config:CardStackConfig, # Card stack configuration ids:CardStackHtmlIds, # HTML IDs for this instance current_count:int=1, # Currently selected card count is_auto_mode:bool=True, # Whether auto-adjust mode is active)->Any: # Card count dropdown component
Render the card count dropdown selector.
# Test render_card_count_select — default is auto modeselect_el = render_card_count_select(config, ids)html = to_xml(select_el)assert'id="test-card-count-select"'in htmlassert"window.cardStacks['test'].handleCountChange"in htmlassert'value="auto" selected'in html # Auto selected by defaultassert"Auto"in htmlassert"1 card"in htmlassert"3 cards"in htmlassert"5 cards"in htmlassert"7 cards"in htmlassert"9 cards"in htmlprint("render_card_count_select default tests passed!")
# Test with custom visible_count_optionscustom_config = CardStackConfig(prefix="custom", visible_count_options=(3, 5, 7))custom_ids = CardStackHtmlIds(prefix="custom")select_el = render_card_count_select(custom_config, custom_ids)html = to_xml(select_el)assert"1 card"notin html # Not in custom optionsassert"3 cards"in htmlassert"9 cards"notin html # Not in custom optionsassert"Auto"in html # Auto always presentassert'value="auto" selected'in html # Auto selected by defaultprint("Custom options test passed!")# Test is_auto_mode=False selects numeric optionselect_manual = render_card_count_select(config, ids, current_count=5, is_auto_mode=False)html_manual = to_xml(select_manual)assert'value="auto" selected'notin html_manual # Auto NOT selectedassert'value="5" selected'in html_manual # Numeric should be selectedprint("is_auto_mode=False test passed!")