diff --git a/addons/rose/addon/components/rose/dropdown/index.hbs b/addons/rose/addon/components/rose/dropdown/index.hbs index 90f899281..5d02e87e8 100644 --- a/addons/rose/addon/components/rose/dropdown/index.hbs +++ b/addons/rose/addon/components/rose/dropdown/index.hbs @@ -22,14 +22,28 @@ -
- {{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) - )}} -
+ {{#if @ignoreClickInside}} +
+ {{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") + )}} +
+ {{else}} +
+ {{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") + )}} +
+ {{/if}} diff --git a/addons/rose/addon/components/rose/dropdown/index.stories.mdx b/addons/rose/addon/components/rose/dropdown/index.stories.mdx index a6b7a1b52..58a0575bf 100644 --- a/addons/rose/addon/components/rose/dropdown/index.stories.mdx +++ b/addons/rose/addon/components/rose/dropdown/index.stories.mdx @@ -63,6 +63,24 @@ A simple dropdown component with support for links and buttons. }} + + {{ + template: hbs` + + + <:key>Name + <:value>Key/Value + + + + <:key>Description + <: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? + + + `, + }} + + ```html @@ -125,3 +143,14 @@ form field. ``` + +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 + + + <:key>ID + <:value>cl_nbv9375hLHs + + +``` diff --git a/addons/rose/addon/components/rose/dropdown/key-value/index.hbs b/addons/rose/addon/components/rose/dropdown/key-value/index.hbs new file mode 100644 index 000000000..a160906c5 --- /dev/null +++ b/addons/rose/addon/components/rose/dropdown/key-value/index.hbs @@ -0,0 +1,9 @@ +
+
+ {{yield to='key'}} +
+ +
+ {{yield to='value'}} +
+
diff --git a/addons/rose/addon/styles/rose/components/dropdown/_index.scss b/addons/rose/addon/styles/rose/components/dropdown/_index.scss index ad9bba47a..4f44734f8 100644 --- a/addons/rose/addon/styles/rose/components/dropdown/_index.scss +++ b/addons/rose/addon/styles/rose/components/dropdown/_index.scss @@ -3,3 +3,4 @@ @import 'link'; @import 'item'; @import 'section'; +@import 'key-value'; diff --git a/addons/rose/addon/styles/rose/components/dropdown/_key-value.scss b/addons/rose/addon/styles/rose/components/dropdown/_key-value.scss new file mode 100644 index 000000000..70b9b6510 --- /dev/null +++ b/addons/rose/addon/styles/rose/components/dropdown/_key-value.scss @@ -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; + } +} diff --git a/addons/rose/app/components/rose/dropdown/key-value.js b/addons/rose/app/components/rose/dropdown/key-value.js new file mode 100644 index 000000000..51e6ae804 --- /dev/null +++ b/addons/rose/app/components/rose/dropdown/key-value.js @@ -0,0 +1 @@ +export { default } from 'rose/components/rose/dropdown/key-value'; diff --git a/addons/rose/tests/dummy/app/templates/index.hbs b/addons/rose/tests/dummy/app/templates/index.hbs index e3cd92620..ed8345c31 100644 --- a/addons/rose/tests/dummy/app/templates/index.hbs +++ b/addons/rose/tests/dummy/app/templates/index.hbs @@ -1,3 +1,31 @@ +

KeyValue Dropdown

+ + + <:key>ID + <:value>cl_nbv9375hLHs + + + + + + <:key>Name + <:value>Key/Value + + + + + + <:key>Description + <: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? + + + +

Condensed dropdown

+ <:key>key + <:value>value + + `); + + assert.equal(find('.rose-dropdown-key').textContent.trim(), 'key'); + assert.equal(find('.rose-dropdown-value').textContent.trim(), 'value'); + }); +});