From cbf39454b3363f9cb99cd40035ca87a012876141 Mon Sep 17 00:00:00 2001 From: Michael Lange Date: Fri, 29 Jun 2018 14:21:33 -0700 Subject: [PATCH] Dropdown entry to the styleguide --- ui/app/components/freestyle/sg-dropdown.js | 30 ++++++++++ .../components/freestyle/sg-dropdown.hbs | 55 +++++++++++++++++++ ui/app/templates/freestyle.hbs | 4 ++ 3 files changed, 89 insertions(+) create mode 100644 ui/app/components/freestyle/sg-dropdown.js create mode 100644 ui/app/templates/components/freestyle/sg-dropdown.hbs diff --git a/ui/app/components/freestyle/sg-dropdown.js b/ui/app/components/freestyle/sg-dropdown.js new file mode 100644 index 000000000..bc9980efc --- /dev/null +++ b/ui/app/components/freestyle/sg-dropdown.js @@ -0,0 +1,30 @@ +import Component from '@ember/component'; + +export default Component.extend({ + options: [ + { name: 'Consul' }, + { name: 'Nomad' }, + { name: 'Packer' }, + { name: 'Terraform' }, + { name: 'Vagrant' }, + { name: 'Vault' }, + ], + + manyOptions: [ + 'One', + 'Two', + 'Three', + 'Four', + 'Five', + 'Six', + 'Seven', + 'Eight', + 'Nine', + 'Ten', + 'Eleven', + 'Twelve', + 'Thirteen', + 'Fourteen', + 'Fifteen', + ].map(name => ({ name })), +}); diff --git a/ui/app/templates/components/freestyle/sg-dropdown.hbs b/ui/app/templates/components/freestyle/sg-dropdown.hbs new file mode 100644 index 000000000..c15239eb7 --- /dev/null +++ b/ui/app/templates/components/freestyle/sg-dropdown.hbs @@ -0,0 +1,55 @@ +{{#freestyle-usage "dropdown" title="Simple Dropdown"}} + {{#power-select + options=options + selected=selectedOption + searchField="name" + searchEnabled=(gt options.length 10) + onchange=(action (mut selectedOption)) + as |option|}} + {{option.name}} + {{/power-select}} +{{/freestyle-usage}} + +{{#freestyle-annotation}} + Power Select currently fulfills all of Nomad's dropdown needs out of the box. +{{/freestyle-annotation}} + +{{#freestyle-usage "dropdown-sized" title="Dropdown Resized"}} +
+
+ {{#power-select + options=options + selected=selectedOption2 + searchField="name" + searchEnabled=(gt options.length 10) + onchange=(action (mut selectedOption2)) + as |option|}} + {{option.name}} + {{/power-select}} +
+
+{{/freestyle-usage}} + +{{#freestyle-annotation}} + Dropdowns are always 100% wide. To control the width of a dropdown, adjust the dimensions of its container. One way to achieve this is using columns. +{{/freestyle-annotation}} + +{{#freestyle-usage "dropdown-search" title="Dropdown with Search"}} +
+
+ {{#power-select + options=manyOptions + selected=selectedOption3 + searchField="name" + searchEnabled=(gt manyOptions.length 10) + onchange=(action (mut selectedOption3)) + as |option|}} + {{option.name}} + {{/power-select}} +
+
+{{/freestyle-usage}} + +{{#freestyle-annotation}} + Whether or not the dropdown has a search box is configurable. Typically the default is to show a search once a dropdown has more than 10 options. +{{/freestyle-annotation}} diff --git a/ui/app/templates/freestyle.hbs b/ui/app/templates/freestyle.hbs index 5c8fd1c3c..33240f661 100644 --- a/ui/app/templates/freestyle.hbs +++ b/ui/app/templates/freestyle.hbs @@ -30,8 +30,12 @@ {{#section.subsection name="Diff Viewer"}} {{freestyle/sg-diff-viewer}} {{/section.subsection}} + + {{#section.subsection name="Dropdown"}} + {{freestyle/sg-dropdown}} {{/section.subsection}} + {{#section.subsection name="Event stream"}} {{/section.subsection}} {{#section.subsection name="Gutter navigation"}}