From 8651376db86ff8461e5dbbba734942fab3a4cc2d Mon Sep 17 00:00:00 2001 From: Levi Thomason Date: Fri, 21 Apr 2017 10:05:31 -0700 Subject: [PATCH] feat(Dropdown): add upward prop (#1603) --- .../Dropdown/Usage/DropdownExampleUpward.js | 14 ++++++++++++++ .../Usage/DropdownExampleUpwardInline.js | 18 ++++++++++++++++++ .../Usage/DropdownExampleUpwardSelection.js | 14 ++++++++++++++ .../Examples/modules/Dropdown/Usage/index.js | 11 +++++++++++ src/modules/Dropdown/Dropdown.d.ts | 5 ++++- src/modules/Dropdown/Dropdown.js | 13 +++++++++---- test/specs/modules/Dropdown/Dropdown-test.js | 1 + 7 files changed, 71 insertions(+), 5 deletions(-) create mode 100644 docs/app/Examples/modules/Dropdown/Usage/DropdownExampleUpward.js create mode 100644 docs/app/Examples/modules/Dropdown/Usage/DropdownExampleUpwardInline.js create mode 100644 docs/app/Examples/modules/Dropdown/Usage/DropdownExampleUpwardSelection.js diff --git a/docs/app/Examples/modules/Dropdown/Usage/DropdownExampleUpward.js b/docs/app/Examples/modules/Dropdown/Usage/DropdownExampleUpward.js new file mode 100644 index 0000000000..6caa00b19e --- /dev/null +++ b/docs/app/Examples/modules/Dropdown/Usage/DropdownExampleUpward.js @@ -0,0 +1,14 @@ +import React from 'react' +import { Dropdown } from 'semantic-ui-react' + +const options = [ + { key: 'new', text: 'New', value: 'new' }, + { key: 'save', text: 'Save as...', value: 'save' }, + { key: 'edit', text: 'Edit', value: 'edit' }, +] + +const DropdownExampleUpward = () => ( + +) + +export default DropdownExampleUpward diff --git a/docs/app/Examples/modules/Dropdown/Usage/DropdownExampleUpwardInline.js b/docs/app/Examples/modules/Dropdown/Usage/DropdownExampleUpwardInline.js new file mode 100644 index 0000000000..52615c0bb2 --- /dev/null +++ b/docs/app/Examples/modules/Dropdown/Usage/DropdownExampleUpwardInline.js @@ -0,0 +1,18 @@ +import React from 'react' +import { Dropdown } from 'semantic-ui-react' + +const options = [ + { key: 's', text: 'small', value: 's' }, + { key: 'm', text: 'medium', value: 'm' }, + { key: 'l', text: 'large', value: 'l' }, +] + +const DropdownExampleUpwardInline = () => ( +
+ I'd like a size{' '} + + {' '}T-shirt, please. +
+) + +export default DropdownExampleUpwardInline diff --git a/docs/app/Examples/modules/Dropdown/Usage/DropdownExampleUpwardSelection.js b/docs/app/Examples/modules/Dropdown/Usage/DropdownExampleUpwardSelection.js new file mode 100644 index 0000000000..6bd2244c05 --- /dev/null +++ b/docs/app/Examples/modules/Dropdown/Usage/DropdownExampleUpwardSelection.js @@ -0,0 +1,14 @@ +import React from 'react' +import { Dropdown } from 'semantic-ui-react' + +const options = [ + { key: 1, text: 'One', value: 1 }, + { key: 2, text: 'Two', value: 2 }, + { key: 3, text: 'Three', value: 3 }, +] + +const DropdownExampleUpwardSelection = () => ( + +) + +export default DropdownExampleUpwardSelection diff --git a/docs/app/Examples/modules/Dropdown/Usage/index.js b/docs/app/Examples/modules/Dropdown/Usage/index.js index 8a99be2f3a..0fd670bb74 100644 --- a/docs/app/Examples/modules/Dropdown/Usage/index.js +++ b/docs/app/Examples/modules/Dropdown/Usage/index.js @@ -76,6 +76,17 @@ const DropdownUsageExamples = () => ( description='A dropdown item can be rendered differently inside the menu.' examplePath='modules/Dropdown/Usage/DropdownExampleItemContent' /> + + + ) diff --git a/src/modules/Dropdown/Dropdown.d.ts b/src/modules/Dropdown/Dropdown.d.ts index ad740cc7c5..2370ffd3cf 100644 --- a/src/modules/Dropdown/Dropdown.d.ts +++ b/src/modules/Dropdown/Dropdown.d.ts @@ -56,7 +56,7 @@ export interface DropdownProps { defaultSelectedLabel?: number | string; /** Initial value or value array if multiple. */ - defaultValue?: string | number | Array; + defaultValue?: string | number | Array; /** A disabled dropdown menu or item does not allow user interaction. */ disabled?: boolean; @@ -232,6 +232,9 @@ export interface DropdownProps { /** Current value or value array if multiple. Creates a controlled component. */ value?: number | string | Array; + + /** A dropdown can open upward. */ + upward: boolean; } interface DropdownComponent extends React.ComponentClass { diff --git a/src/modules/Dropdown/Dropdown.js b/src/modules/Dropdown/Dropdown.js index 8bea159e4b..f709137f00 100644 --- a/src/modules/Dropdown/Dropdown.js +++ b/src/modules/Dropdown/Dropdown.js @@ -312,6 +312,9 @@ export default class Dropdown extends Component { PropTypes.node, ]), + /** A dropdown can open upward. */ + upward: PropTypes.bool, + /** Current value or value array if multiple. Creates a controlled component. */ value: PropTypes.oneOfType([ PropTypes.string, @@ -1193,23 +1196,24 @@ export default class Dropdown extends Component { button, className, compact, + disabled, + error, fluid, floating, icon, inline, item, labeled, + loading, multiple, pointing, search, selection, - simple, - loading, - error, - disabled, scrolling, + simple, tabIndex, trigger, + upward, } = this.props // Classes @@ -1237,6 +1241,7 @@ export default class Dropdown extends Component { useKeyOnly(selection, 'selection'), useKeyOnly(simple, 'simple'), useKeyOnly(scrolling, 'scrolling'), + useKeyOnly(upward, 'upward'), useKeyOrValueAndKey(pointing, 'pointing'), className, diff --git a/test/specs/modules/Dropdown/Dropdown-test.js b/test/specs/modules/Dropdown/Dropdown-test.js index 83e6db42e4..28f94c47ba 100644 --- a/test/specs/modules/Dropdown/Dropdown-test.js +++ b/test/specs/modules/Dropdown/Dropdown-test.js @@ -95,6 +95,7 @@ describe('Dropdown', () => { common.propKeyOnlyToClassName(Dropdown, 'selection') common.propKeyOnlyToClassName(Dropdown, 'simple') common.propKeyOnlyToClassName(Dropdown, 'scrolling') + common.propKeyOnlyToClassName(Dropdown, 'upward') common.propKeyOrValueAndKeyToClassName(Dropdown, 'pointing', [ 'left', 'right', 'top', 'top left', 'top right', 'bottom', 'bottom left', 'bottom right',