From 862f4d19a6a52906d097f2366cd4208a11c9bfc1 Mon Sep 17 00:00:00 2001 From: Jacob Lamont Date: Mon, 26 Aug 2024 21:51:45 -0400 Subject: [PATCH] [SegmentedControl]: Add variable to set width of control (#792) This will default to the container being `fit-content`. If the width is wider than the necessary width of it's children, then the children will evenly divide across the total width. --- examples/plain-html/index.html | 36 +++++++++++++------ src/components/controlItem/controlItem.svelte | 3 ++ .../segmentedControl.stories.svelte | 5 +++ .../segmentedControl/segmentedControl.svelte | 8 ++++- 4 files changed, 40 insertions(+), 12 deletions(-) diff --git a/examples/plain-html/index.html b/examples/plain-html/index.html index ac119a949..a3122cc7a 100644 --- a/examples/plain-html/index.html +++ b/examples/plain-html/index.html @@ -12,6 +12,7 @@ @@ -99,7 +104,9 @@ const dropdown = document.querySelector('leo-dropdown') const dropdownSelected = document.querySelector('leo-dropdown [slot="value"]') const input = document.querySelector('leo-input') - const segmentedControl = document.querySelector('leo-segmentedcontrol'); + const segmentedControlExample = document.querySelector('#example-segmented-control'); + const segmentedControlToggle = segmentedControlExample.querySelector('leo-toggle'); + const segmentedControl = segmentedControlExample.querySelector('leo-segmentedcontrol'); function updateSelectedOption(e) { for (const radio of radios) @@ -147,6 +154,10 @@ toggleButton.textContent = e.value }) + segmentedControlToggle.addEventListener('change', () => { + segmentedControl.classList.toggle('segmented-control-full') + }) + dialogButton.addEventListener('click', () => { dialog.isOpen = true dialogButton.isDisabled = true @@ -245,16 +256,19 @@ Primary - - - Full - - - - Simple - - - +
+ Toggle segmented control from automatic to parent's width + + + Full + + + + Simple + + + +