fix: Adjusting the width of dropdown (#18059)

* fix: Adjusting the width of dropdown

This will make it so the width of the dropdown will adjust to the longest variable name

* fix: Adjusting the width of dropdown

Updating font

* fix: Adjusting the width of dropdown

fix prettier
pull/18109/head
Zoe Steinkamp 2020-05-14 15:30:32 -06:00 committed by GitHub
parent 97037f84d9
commit 17f4cc14f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 0 deletions

View File

@ -93,3 +93,7 @@
cursor: grab !important;
}
}
.variable-dropdown--item {
font-family: $cf-code-font;
}

View File

@ -43,6 +43,14 @@ class VariableDropdown extends PureComponent<Props> {
const dropdownStatus =
values.length === 0 ? ComponentStatus.Disabled : ComponentStatus.Default
const longestItemWidth = Math.floor(
values.reduce(function(a, b) {
return a.length > b.length ? a : b
}, '').length * 8.5
)
const widthLength = Math.max(140, longestItemWidth)
return (
<div className="variable-dropdown">
{/* TODO: Add variable description to title attribute when it is ready */}
@ -62,6 +70,7 @@ class VariableDropdown extends PureComponent<Props> {
)}
menu={onCollapse => (
<Dropdown.Menu
style={{width: `${widthLength}px`}}
onCollapse={onCollapse}
theme={DropdownMenuTheme.Amethyst}
>
@ -74,6 +83,7 @@ class VariableDropdown extends PureComponent<Props> {
onClick={this.handleSelect}
selected={val === selectedValue}
testID="variable-dropdown--item"
className="variable-dropdown--item"
>
{val}
</Dropdown.Item>