feat: Add option to hide dropdown indicator icon

This commit is contained in:
Susmitha Girumala committed 2020-08-27 12:13:58 -04:00
1 parent 290c38738e
commit ac1affcb6b
5 files changed
+36 -5

No files matched your search

@@ -1,5 +1,6 @@
import { Meta, Story, Preview } from '@storybook/addon-docs/blocks';
import { hbs } from 'ember-cli-htmlbars';
import { boolean } from '@storybook/addon-knobs';
<Meta title="Rose|Dropdown" component="Dropdown" />
@@ -10,13 +11,16 @@ A simple dropdown component with support for links and buttons.
<Preview>
<Story name="Basic Dropdown" height="5rem">{{
template: hbs`
<Rose::Dropdown @text="Choose One&hellip;" @icon="user-organization" as |dropdown|>
<Rose::Dropdown @text="Choose One&hellip;" @icon="user-organization" @hideDropdownIndicator={{hideDropdownIndicator}} as |dropdown|>
<dropdown.link @route="index">Menu item</dropdown.link>
<dropdown.link @route="about">Menu item</dropdown.link>
<dropdown.separator />
<dropdown.button>Button menu item</dropdown.button>
</Rose::Dropdown>
`,
context: {
hideDropdownIndicator: boolean('hideDropdownIndicator', false),
},
}}</Story>
</Preview>
@@ -34,7 +38,7 @@ A simple dropdown component with support for links and buttons.
</Preview>
```htmlbars
```html
<Rose::Dropdown @text="Choose One&hellip;" as |dropdown|>
<dropdown.link @route="index">Menu item</dropdown.link>
<dropdown.link @route="about">Menu item</dropdown.link>
@@ -44,7 +48,7 @@ A simple dropdown component with support for links and buttons.
Dropdown content can be aligned to right edge of the component instead of the default left edge, which is the default setting. The following example floats the component to right edge of the page inorder to provide enough space to display right aligned dropdown content.
```htmlbars
```html
<Rose::Dropdown @text="Choose One&hellip;" style="float: right" @dropdownRight={{true}} as |dropdown|>
<dropdown.link @route="index">Menu item</dropdown.link>
<dropdown.link @route="about">Menu item</dropdown.link>
@@ -55,9 +59,18 @@ Dropdown content can be aligned to right edge of the component instead of the de
Dropdown supports `danger` styling through `style` attribute.
```htmlbars
```html
<Rose::Dropdown @text="Dropdown" as |dropdown|>
<dropdown.link @style="danger">Link - danger</dropdown.link>
<dropdown.button @style="danger">Button - danger</dropdown.button>
</Rose::Dropdown>
```
Dropdown indicator can be hidden using `hideDropdownIndicator` attribute.
```html
<Rose::Dropdown @hideDropdownIndicator={{true}} @icon="more-horizontal" as |dropdown|>
<dropdown.link @route="index">Menu item</dropdown.link>
<dropdown.button>Button menu item</dropdown.button>
</Rose::Dropdown>
```
@@ -58,6 +58,11 @@ $chevron: "data:image/svg+xml;utf-8,<svg viewBox='0 0 24 24' fill='%231b1f26' xm
}
}
&.hide-dropdown-indicator {
background: none;
padding-right: sizing.rems(s);
}
// Hide default twistie triangle
// Webkit / Chromium
&::-webkit-details-marker {
@@ -5,7 +5,7 @@
>
<summary
class="rose-dropdown-trigger {{if @iconOnly "has-icon-only"}}"
class="rose-dropdown-trigger {{if @iconOnly "has-icon-only"}} {{if @hideDropdownIndicator "hide-dropdown-indicator"}}"
title={{@text}}
>
@@ -36,3 +36,8 @@
<dropdown.button>Button menu item</dropdown.button>
<dropdown.button @style="danger">Button - danger</dropdown.button>
</Rose::Dropdown>
<Rose::Dropdown @hideDropdownIndicator={{true}} @icon="more-horizontal" as |dropdown|>
<dropdown.link @route="index">Menu item</dropdown.link>
<dropdown.button>Button menu item</dropdown.button>
</Rose::Dropdown>
@@ -10,6 +10,7 @@ module('Integration | Component | rose/dropdown', function (hooks) {
await render(hbs`<Rose::Dropdown />`);
assert.ok(find('.rose-dropdown'));
assert.notOk(find('.rose-dropdown-right'));
assert.notOk(find('.hide-dropdown-indicator'));
});
test('it renders with html attributes', async function (assert) {
@@ -40,6 +41,13 @@ module('Integration | Component | rose/dropdown', function (hooks) {
assert.ok(find('.rose-dropdown-right'));
});
test('it supports hiding dropdown indicator', async function (assert) {
await render(hbs`
<Rose::Dropdown @hideDropdownIndicator={{true}} />
`);
assert.ok(find('.hide-dropdown-indicator'));
});
test('it renders with content', async function (assert) {
await render(hbs`<Rose::Dropdown @text="Click me" as |dropdown|>
<dropdown.link @route="about"/>