Merge branch 'main' into feat-desktop-reveal-component

This commit is contained in:
Randall Morey authored and GitHub committed 2021-06-23 10:13:42 -04:00
commit 1208fea0a4
8 files changed
+122 -9

No files matched your search

@@ -22,14 +22,28 @@
</summary>
<div class="rose-dropdown-content" {{on-click-inside this.close}}>
{{yield (hash
link=(component "rose/dropdown/link" style=this.style)
button=(component "rose/dropdown/button" style=this.style)
item=(component "rose/anonymous" class="rose-dropdown-item")
separator=(component "rose/anonymous" tagName="hr" class="rose-dropdown-separator")
section=(component "rose/dropdown/section" style=this.style)
)}}
</div>
{{#if @ignoreClickInside}}
<div class="rose-dropdown-content">
{{yield (hash
link=(component "rose/dropdown/link" style=this.style)
button=(component "rose/dropdown/button" style=this.style)
item=(component "rose/anonymous" class="rose-dropdown-item")
separator=(component "rose/anonymous" tagName="hr" class="rose-dropdown-separator")
section=(component "rose/dropdown/section" style=this.style)
key-value=(component "rose/dropdown/key-value")
)}}
</div>
{{else}}
<div class="rose-dropdown-content" {{on-click-inside this.close}}>
{{yield (hash
link=(component "rose/dropdown/link" style=this.style)
button=(component "rose/dropdown/button" style=this.style)
item=(component "rose/anonymous" class="rose-dropdown-item")
separator=(component "rose/anonymous" tagName="hr" class="rose-dropdown-separator")
section=(component "rose/dropdown/section" style=this.style)
key-value=(component "rose/dropdown/key-value")
)}}
</div>
{{/if}}
</details>
@@ -63,6 +63,24 @@ A simple dropdown component with support for links and buttons.
}}</Story>
</Preview>
<Preview>
<Story name="Dropdown with Key Value Items" height="13rem">{{
template: hbs`
<Rose::Dropdown @text="View details" @showCaret={{showCaret}} @ignoreClickInside={{true}} as |dropdown|>
<dropdown.key-value>
<:key>Name</:key>
<:value>Key/Value</:value>
</dropdown.key-value>
<dropdown.separator />
<dropdown.key-value>
<:key>Description</:key>
<:value>Lorem ipsum dolor sit amet consectetur adipisicing elit. Assumenda illo ratione libero ducimus magnam, porro sed provident repellat mollitia a, repellendus placeat. Magni consequuntur cumque, debitis obcaecati dolores quasi natus?</:value>
</dropdown.key-value>
</Rose::Dropdown>
`,
}}</Story>
</Preview>
```html
<Rose::Dropdown @text="Choose One&hellip;" as |dropdown|>
@@ -125,3 +143,14 @@ form field.
</form.radioGroup>
</Rose::Form>
```
Closing dropdown after clicking inside it's content can be ignored using `ignoreClickInside`. This is useful when dropdown contains keyvalue items that users need to select/copy/interact with.
```html
<Rose::Dropdown @text="View details" @showCaret={{true}} @ignoreClickInside={{true}} as |dropdown|>
<dropdown.key-value>
<:key>ID</:key>
<:value>cl_nbv9375hLHs</:value>
</dropdown.key-value>
</Rose::Dropdown>
```
@@ -0,0 +1,9 @@
<dl class='rose-dropdown-key-value rose-dropdown-item'>
<dt class='rose-dropdown-key'>
{{yield to='key'}}
</dt>
<dd class='rose-dropdown-value'>
{{yield to='value'}}
</dd>
</dl>
@@ -3,3 +3,4 @@
@import 'link';
@import 'item';
@import 'section';
@import 'key-value';
@@ -0,0 +1,11 @@
@use '../../variables/sizing';
.rose-dropdown-key-value {
.rose-dropdown-key {
text-transform: capitalize;
}
.rose-dropdown-value {
color: var(--ui-gray);
padding: sizing.rems(xxs) sizing.rems(s) 0 0;
}
}
@@ -0,0 +1 @@
export { default } from 'rose/components/rose/dropdown/key-value';
@@ -1,3 +1,31 @@
<h2>KeyValue Dropdown</h2>
<Rose::Dropdown
@text="Credential library details"
@showCaret={{true}}
@ignoreClickInside={{true}}
as |dropdown|
>
<dropdown.key-value>
<:key>ID</:key>
<:value>cl_nbv9375hLHs</:value>
</dropdown.key-value>
<dropdown.separator />
<dropdown.key-value>
<:key>Name</:key>
<:value>Key/Value</:value>
</dropdown.key-value>
<dropdown.separator />
<dropdown.key-value>
<:key>Description</:key>
<:value>Lorem ipsum dolor sit amet consectetur adipisicing elit. Assumenda illo ratione libero ducimus magnam, porro sed provident repellat mollitia a, repellendus placeat. Magni consequuntur cumque, debitis obcaecati dolores quasi natus?</:value>
</dropdown.key-value>
</Rose::Dropdown>
<h2>Condensed dropdown</h2>
<Rose::Dropdown
@style="condensed"
@@ -0,0 +1,20 @@
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render, find } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';
module('Integration | Component | rose/dropdown/key-value', function (hooks) {
setupRenderingTest(hooks);
test('it renders', async function (assert) {
await render(hbs`
<Rose::Dropdown::KeyValue>
<:key>key</:key>
<:value>value</:value>
</Rose::Dropdown::KeyValue>
`);
assert.equal(find('.rose-dropdown-key').textContent.trim(), 'key');
assert.equal(find('.rose-dropdown-value').textContent.trim(), 'value');
});
});