Browse Source

fix(device-selection): convert trigger element to a div

AtlasKit Dropdown was recently updated to support fitting the
width of its container. However, AtlasKit Button, the trigger
element currently used for the dropdowns, does not fit the width
of AtlasKit Dropdown and stll has text overflowing out of its
button when there is an iconBefore prop passed in. Instead of
using AtlasKit Button, use a div and mimic the button look. This
allows the "button" to fit the container width and can display
ellipsized text within itself.
master
Leonard Kim 8 years ago
parent
commit
17fc28b020

+ 27
- 6
css/modals/device-selection/_device-selection.scss View File

@@ -4,12 +4,6 @@
4 4
     .device-selectors {
5 5
         font-size: 14px;
6 6
 
7
-        /* ensure all child components do not exceed parent width */
8
-        button,
9
-        div {
10
-            max-width: 100%;
11
-        }
12
-
13 7
         > div {
14 8
             display: block;
15 9
             margin-bottom: 10px;
@@ -20,8 +14,35 @@
20 14
         }
21 15
 
22 16
         .device-selector-icon {
17
+            align-self: center;
23 18
             color: inherit;
24 19
             font-size: 20px;
20
+            margin-left: 3px;
21
+        }
22
+
23
+        /* device-selector-trigger stylings attempt to mimic AtlasKit button */
24
+        .device-selector-trigger {
25
+            background-color: rgba(9, 30, 66, 0.04);
26
+            border-radius: 3px;
27
+            color: #505f79;
28
+            display: flex;
29
+            height: 2.3em;
30
+            justify-content: space-between;
31
+            line-height: 2.3em;
32
+            overflow: hidden;
33
+            padding: 0 8px;
34
+
35
+            &:hover {
36
+                background-color: rgba(9,30,66,.08);
37
+            }
38
+        }
39
+
40
+        .device-selector-trigger-text {
41
+            overflow: hidden;
42
+            margin-left: 8px;
43
+            text-overflow: ellipsis;
44
+            white-space: nowrap;
45
+            width: 100%;
25 46
         }
26 47
     }
27 48
 

+ 1
- 1
package.json View File

@@ -18,7 +18,7 @@
18 18
   "dependencies": {
19 19
     "@atlaskit/button": "1.0.3",
20 20
     "@atlaskit/button-group": "1.0.0",
21
-    "@atlaskit/dropdown-menu": "1.1.12",
21
+    "@atlaskit/dropdown-menu": "1.4.0",
22 22
     "@atlaskit/field-text": "2.0.3",
23 23
     "@atlaskit/icon": "6.0.0",
24 24
     "@atlaskit/modal-dialog": "1.2.4",

+ 15
- 23
react/features/device-selection/components/DeviceSelector.js View File

@@ -1,4 +1,3 @@
1
-import AKButton from '@atlaskit/button';
2 1
 import AKDropdownMenu from '@atlaskit/dropdown-menu';
3 2
 import ExpandIcon from '@atlaskit/icon/glyph/expand';
4 3
 import React, { Component } from 'react';
@@ -102,32 +101,24 @@ class DeviceSelector extends Component {
102 101
     }
103 102
 
104 103
     /**
105
-     * Creates an AtlasKit Button.
104
+     * Creates a React Element for displaying the passed in text surrounded by
105
+     * two icons. The left icon is the icon class passed in through props and
106
+     * the right icon is AtlasKit ExpandIcon.
106 107
      *
107
-     * @param {string} buttonText - The text to display within the button.
108
+     * @param {string} triggerText - The text to display within the element.
108 109
      * @private
109 110
      * @returns {ReactElement}
110 111
      */
111
-    _createDropdownTrigger(buttonText) {
112
+    _createDropdownTrigger(triggerText) {
112 113
         return (
113
-            <AKButton
114
-                className = 'device-selector-trigger'
115
-                iconAfter = { EXPAND_ICON }
116
-                iconBefore = { this._createDropdownIcon() }>
117
-                { buttonText }
118
-            </AKButton>
119
-        );
120
-    }
121
-
122
-    /**
123
-     * Creates a ReactComponent for displaying an icon.
124
-     *
125
-     * @private
126
-     * @returns {ReactElement}
127
-     */
128
-    _createDropdownIcon() {
129
-        return (
130
-            <span className = { `device-selector-icon ${this.props.icon}` } />
114
+            <div className = 'device-selector-trigger'>
115
+                <span
116
+                    className = { `device-selector-icon ${this.props.icon}` } />
117
+                <span className = 'device-selector-trigger-text'>
118
+                    { triggerText }
119
+                </span>
120
+                { EXPAND_ICON }
121
+            </div>
131 122
         );
132 123
     }
133 124
 
@@ -171,7 +162,8 @@ class DeviceSelector extends Component {
171 162
                 items = { [ { items: options.items || [] } ] }
172 163
                 noMatchesFound
173 164
                     = { this.props.t('deviceSelection.noOtherDevices') }
174
-                onItemActivated = { this._onSelect }>
165
+                onItemActivated = { this._onSelect }
166
+                shouldFitContainer = { true }>
175 167
                 { this._createDropdownTrigger(triggerText) }
176 168
             </AKDropdownMenu>
177 169
         );

Loading…
Cancel
Save