kempo-ui 0.0.68 → 0.0.70
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -29,6 +29,8 @@ import{html,css}from"../lit-all.min.js";import ShadowComponent from"./ShadowComp
|
|
|
29
29
|
#switch {
|
|
30
30
|
display: flex;
|
|
31
31
|
align-items: center;
|
|
32
|
+
flex-shrink: 0;
|
|
33
|
+
flex-grow: 0;
|
|
32
34
|
width: var(--switch_width);
|
|
33
35
|
height: var(--switch_height);
|
|
34
36
|
border: var(--switch_border);
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
<h6>Examples</h6>
|
|
24
24
|
<a href="#basicUsage">Basic Usage</a><br />
|
|
25
25
|
<a href="#onByDefault">On By Default</a><br />
|
|
26
|
+
<a href="#responsiveBehavior">Responsive Behavior</a><br />
|
|
26
27
|
<a href="#customStyles">Custom Styles</a><br />
|
|
27
28
|
<a href="#javascriptUsage">JavaScript Usage</a><br />
|
|
28
29
|
|
|
@@ -63,6 +64,23 @@
|
|
|
63
64
|
</div>
|
|
64
65
|
</div>
|
|
65
66
|
|
|
67
|
+
<h3 id="responsiveBehavior"><a href="#responsiveBehavior" class="no-link">Responsive Behavior</a></h3>
|
|
68
|
+
<p>The visual toggle maintains its size even in narrow containers. Only the label shrinks to fit the available space.</p>
|
|
69
|
+
<div class="row -mx">
|
|
70
|
+
<div class="col m-span-12 px">
|
|
71
|
+
<k-card label="HTML">
|
|
72
|
+
<pre><code class="hljs xml"><span class="hljs-tag"><<span class="hljs-name">div</span> <span class="hljs-attr">style</span>=<span class="hljs-string">"width: 150px;"</span>></span><br /> <span class="hljs-tag"><<span class="hljs-name">k-toggle</span>></span>A very long label that should shrink<span class="hljs-tag"></<span class="hljs-name">k-toggle</span>></span><br /><span class="hljs-tag"></<span class="hljs-name">div</span>></span></code></pre>
|
|
73
|
+
</k-card>
|
|
74
|
+
</div>
|
|
75
|
+
<div class="col m-span-12 px">
|
|
76
|
+
<k-card label="Output">
|
|
77
|
+
<div style="width: 150px;">
|
|
78
|
+
<k-toggle>A very long label that should shrink</k-toggle>
|
|
79
|
+
</div>
|
|
80
|
+
</k-card>
|
|
81
|
+
</div>
|
|
82
|
+
</div>
|
|
83
|
+
|
|
66
84
|
<h3 id="customStyles"><a href="#customStyles" class="no-link">Custom Styles</a></h3>
|
|
67
85
|
<div class="row -mx">
|
|
68
86
|
<div class="col m-span-12 px">
|
|
@@ -29,6 +29,8 @@ import{html,css}from"../lit-all.min.js";import ShadowComponent from"./ShadowComp
|
|
|
29
29
|
#switch {
|
|
30
30
|
display: flex;
|
|
31
31
|
align-items: center;
|
|
32
|
+
flex-shrink: 0;
|
|
33
|
+
flex-grow: 0;
|
|
32
34
|
width: var(--switch_width);
|
|
33
35
|
height: var(--switch_height);
|
|
34
36
|
border: var(--switch_border);
|
package/package.json
CHANGED
package/src/components/Toggle.js
CHANGED
|
@@ -512,6 +512,37 @@ export default {
|
|
|
512
512
|
pass('Label content projected');
|
|
513
513
|
},
|
|
514
514
|
|
|
515
|
+
'switch should not shrink in constrained container': async ({pass, fail}) => {
|
|
516
|
+
const { container, toggle } = await createToggle();
|
|
517
|
+
container.style.width = '100px';
|
|
518
|
+
await toggle.updateComplete;
|
|
519
|
+
const switchEl = toggle.shadowRoot.querySelector('#switch');
|
|
520
|
+
const style = window.getComputedStyle(switchEl);
|
|
521
|
+
if(style.flexShrink !== '0'){
|
|
522
|
+
cleanup(container);
|
|
523
|
+
return fail(`Expected switch flex-shrink to be 0, got ${style.flexShrink}`);
|
|
524
|
+
}
|
|
525
|
+
if(style.flexGrow !== '0'){
|
|
526
|
+
cleanup(container);
|
|
527
|
+
return fail(`Expected switch flex-grow to be 0, got ${style.flexGrow}`);
|
|
528
|
+
}
|
|
529
|
+
cleanup(container);
|
|
530
|
+
pass('Switch does not shrink in constrained container');
|
|
531
|
+
},
|
|
532
|
+
|
|
533
|
+
'label should shrink in constrained container': async ({pass, fail}) => {
|
|
534
|
+
const { container, toggle } = await createToggle();
|
|
535
|
+
await toggle.updateComplete;
|
|
536
|
+
const label = toggle.shadowRoot.querySelector('#label');
|
|
537
|
+
const style = window.getComputedStyle(label);
|
|
538
|
+
if(style.flexGrow !== '1'){
|
|
539
|
+
cleanup(container);
|
|
540
|
+
return fail(`Expected label flex-grow to be 1, got ${style.flexGrow}`);
|
|
541
|
+
}
|
|
542
|
+
cleanup(container);
|
|
543
|
+
pass('Label grows to fill remaining space');
|
|
544
|
+
},
|
|
545
|
+
|
|
515
546
|
/*
|
|
516
547
|
Method Chaining
|
|
517
548
|
*/
|