@@ -12,8 +12,18 @@ import {
1212const MiqTableCell = ( {
1313 cell, onCellClick, row, truncate,
1414} ) => {
15- const truncateText = < span title = { cell . value } className = "bx--front-line" > { cell . value } </ span > ;
16- const truncateClass = ( ( cell . value ) . length > 40 ) && truncate ? 'truncate_cell' : '' ;
15+ const longText = truncate && ( ( cell . value ) . length > 40 ) ;
16+ const veryLongText = truncate && ( ( cell . value ) . length > 300 ) ;
17+
18+ const truncateClass = longText ? 'truncate_cell' : '' ;
19+ const wrapClass = longText ? 'white_space_normal' : '' ;
20+ const longerTextClass = veryLongText ? 'truncate_longer_text' : '' ;
21+
22+ const truncateText = (
23+ < span title = { cell . value } className = { classNames ( 'bx--front-line' , wrapClass , longerTextClass ) } >
24+ { cell . value }
25+ </ span >
26+ ) ;
1727 const cellClass = classNames ( 'cell' , truncateClass , cell . data . style_class ) ;
1828 const cellText = ( ) => (
1929 < div className = { cellClass } >
@@ -60,16 +70,21 @@ const MiqTableCell = ({
6070 } ;
6171
6272 /** Fuction to render icon(s) in cell. */
63- const renderIcon = ( icon , style , showText ) => (
64- < div className = { cellClass } >
65- {
66- typeof ( icon ) === 'string'
67- ? < i className = { classNames ( 'fa-lg' , 'icon' , icon ) } style = { style } />
68- : icon . map ( ( i , index ) => < i className = { classNames ( 'fa-lg' , 'icon' , i ) } key = { index . toString ( ) } /> )
69- }
70- { showText && truncateText }
71- </ div >
72- ) ;
73+ const renderIcon = ( icon , style , showText ) => {
74+ const hasBackground = Object . keys ( style ) . includes ( 'background' ) ;
75+ const styledIconClass = hasBackground ? 'styled_icon' : '' ;
76+ const longerTextClass = hasBackground && veryLongText ? 'styled_icon_margin' : '' ;
77+ return (
78+ < div className = { cellClass } >
79+ {
80+ typeof ( icon ) === 'string'
81+ ? < i className = { classNames ( 'fa-lg' , 'icon' , icon , styledIconClass , longerTextClass ) } style = { style } />
82+ : icon . map ( ( i , index ) => < i className = { classNames ( 'fa-lg' , 'icon' , i ) } key = { index . toString ( ) } /> )
83+ }
84+ { showText && truncateText }
85+ </ div >
86+ ) ;
87+ } ;
7388
7489 /** Fuction to render an icon in cell based on the 'type' in 'item'. */
7590 const cellIcon = ( item , showText ) => {
@@ -101,9 +116,9 @@ const MiqTableCell = ({
101116 const cellButton = ( item ) => (
102117 < div className = { cellClass } >
103118 < Button
104- onClick = { ( e ) => cellButtonEvent ( item , e ) }
119+ onClick = { ( e ) => cellButtonEvent ( item , e ) }
105120 disabled = { item . disabled }
106- onKeyPress = { ( e ) => cellButtonEvent ( item , e ) }
121+ onKeyPress = { ( e ) => cellButtonEvent ( item , e ) }
107122 tabIndex = { 0 }
108123 title = { item . title ? item . title : truncateText }
109124 kind = { item . kind ? item . kind : 'primary' }
@@ -115,7 +130,6 @@ const MiqTableCell = ({
115130 ) ;
116131
117132 /** Function to render a Text Box inside cell. */
118- /* eslint-disable no-eval */
119133 const cellTextInput = ( item , id ) => (
120134 < div className = { cellClass } >
121135 < TextInput
@@ -136,7 +150,6 @@ const MiqTableCell = ({
136150 ) ;
137151
138152 /** Function to render a Toggle inside cell. */
139- /* eslint-disable no-eval */
140153 const cellToggle = ( item , id ) => (
141154 < div className = { cellClass } >
142155 < Toggle
@@ -153,12 +166,9 @@ const MiqTableCell = ({
153166 ) ;
154167
155168 /** Function to render a Link inside cell. */
156- /* eslint-disable no-eval */
157- const cellLink = ( item , id ) => (
169+ const cellLink = ( item , _id ) => (
158170 < div className = { cellClass } >
159- < Link
160- href = { item . href }
161- >
171+ < Link href = { item . href } >
162172 { item . label }
163173 </ Link >
164174 </ div >
0 commit comments