Skip to content

Commit

Permalink
fix(ui): prevent variable dropdown from clipping
Browse files Browse the repository at this point in the history
Closes #14075
  • Loading branch information
chnn committed Jun 19, 2019
1 parent 54fba2e commit 097867b
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
### UI Improvements

1. [14157](https://github.com/influxdata/influxdb/pull/14157): Remove rendering bottleneck when streaming Flux responses
1. [14165](https://github.com/influxdata/influxdb/pull/14165): Prevent variable dropdown from clipping

## v2.0.0-alpha.13 [2019-06-13]

Expand Down
5 changes: 5 additions & 0 deletions ui/src/clockface/components/dropdowns/Dropdown.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@
z-index: 500;
border-radius: $radius;
box-shadow: 0 2px 5px 0.6px fade-out($g0-obsidian, 0.7);

.dropdown--above & {
top: 0;
transform: translateY(-100%);
}
}

.dropdown--menu {
Expand Down
7 changes: 6 additions & 1 deletion ui/src/clockface/components/dropdowns/Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
ComponentSize,
IconFont,
} from '@influxdata/clockface'
import {DropdownMenuColors} from 'src/clockface/types'
import {DropdownMenuColors, DropdownMenuPosition} from 'src/clockface/types'
import {ErrorHandling} from 'src/shared/decorators/errors'

export enum DropdownMode {
Expand Down Expand Up @@ -52,6 +52,7 @@ export interface DefaultProps {
wrapMenuText?: boolean
testID?: string
buttonTestID?: string
menuPosition?: DropdownMenuPosition
}

export type Props = PassedProps & DefaultProps
Expand All @@ -73,6 +74,7 @@ class Dropdown extends Component<Props, State> {
wrapMenuText: false,
testID: 'dropdown',
buttonTestID: 'dropdown-button',
menuPosition: DropdownMenuPosition.Below,
}

public static Button = DropdownButton
Expand Down Expand Up @@ -119,6 +121,7 @@ class Dropdown extends Component<Props, State> {
mode,
wrapMenuText,
selectedID,
menuPosition,
} = this.props

return classnames(
Expand All @@ -130,6 +133,8 @@ class Dropdown extends Component<Props, State> {
[customClass]: customClass,
'dropdown--radio': mode === DropdownMode.Radio,
'dropdown--action': mode === DropdownMode.ActionList && !selectedID,
'dropdown--below': menuPosition === DropdownMenuPosition.Below,
'dropdown--above': menuPosition === DropdownMenuPosition.Above,
}
)
}
Expand Down
6 changes: 5 additions & 1 deletion ui/src/clockface/components/dropdowns/DropdownButton.scss
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,13 @@
font-size: 0.9em;
transition: transform 0.25s ease;

.active & {
.dropdown--below .active &, .dropdown--above & {
transform: translateY(-50%) rotate(-180deg);
}

.dropdown--above .active & {
transform: translateY(-50%);
}
}

/* Button Size Modifiers */
Expand Down
2 changes: 2 additions & 0 deletions ui/src/clockface/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
ComponentSize,
ComponentStatus,
DropdownMenuColors,
DropdownMenuPosition,
DropdownChild,
ButtonShape,
Greys,
Expand Down Expand Up @@ -54,6 +55,7 @@ export {
Dropdown,
DropdownChild,
DropdownMenuColors,
DropdownMenuPosition,
DropdownMode,
Form,
FormElement,
Expand Down
5 changes: 5 additions & 0 deletions ui/src/clockface/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ export enum DropdownMenuColors {
Onyx = 'onyx',
}

export enum DropdownMenuPosition {
Above = 'above',
Below = 'below',
}

export type DropdownChild =
| Array<string | JSX.Element | Element>
| string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {get} from 'lodash'

// Components
import {Form} from '@influxdata/clockface'
import {Dropdown} from 'src/clockface'
import {Dropdown, DropdownMenuPosition} from 'src/clockface'

// Actions
import {
Expand Down Expand Up @@ -66,6 +66,7 @@ const VariableTooltipContents: FunctionComponent<Props> = ({
status={toComponentStatus(valuesStatus)}
titleText={values ? 'No Results' : 'None Selected'}
widthPixels={200}
menuPosition={DropdownMenuPosition.Above}
onChange={value => onSelectVariableValue(variableID, value)}
>
{dropdownItems.map(value => (
Expand Down

0 comments on commit 097867b

Please sign in to comment.