@@ -11,6 +11,29 @@ import {
1111} from 'react' ;
1212import { Th , ThProps } from '@patternfly/react-table' ;
1313import { Button , getLanguageDirection } from '@patternfly/react-core' ;
14+ import { createUseStyles } from 'react-jss' ;
15+
16+ import c_table_cell_PaddingBlockEnd from '@patternfly/react-tokens/dist/esm/c_table_cell_PaddingBlockEnd' ;
17+ import c_table_cell_PaddingInlineEnd from '@patternfly/react-tokens/dist/esm/c_table_cell_PaddingInlineEnd' ;
18+ import t_global_font_size_body_default from '@patternfly/react-tokens/dist/esm/t_global_font_size_body_default' ;
19+
20+ const ResizeIcon = ( ) => (
21+ < svg className = "pf-v6-svg" width = "1em" height = "1em" viewBox = "0 0 1024 1024" fill = "currentColor" xmlns = "http://www.w3.org/2000/svg" >
22+ < path fillRule = "evenodd" d = "M52.7,529.8l190.5,161.9c18.6,15.9,50.5,4.7,50.5-17.8v-324c0-22.4-31.8-33.6-50.5-17.8L52.7,494.2c-11.5,9.8-11.5,25.8,0,35.6ZM480.8,12.9h62.4v998.3h-62.4V12.9ZM971.3,529.8l-190.5,161.9c-18.6,15.9-50.5,4.7-50.5-17.8v-324c0-22.4,31.8-33.6,50.5-17.8l190.5,161.9c11.5,9.8,11.5,25.8,0,35.6Z" />
23+ </ svg >
24+ ) ;
25+
26+ const useStyles = createUseStyles ( {
27+ dataViewResizeableTh : {
28+ [ c_table_cell_PaddingInlineEnd . name ] : `calc(${ t_global_font_size_body_default . var } * 2)`
29+ } ,
30+ dataViewResizableButton : {
31+ position : 'absolute' ,
32+ insetInlineEnd : `calc(${ t_global_font_size_body_default . var } / 2)` ,
33+ insetBlockEnd : c_table_cell_PaddingBlockEnd . var ,
34+ cursor : 'grab'
35+ } ,
36+ } ) ;
1437export interface DataViewThResizableProps {
1538 /** Whether the column is resizable */
1639 isResizable ?: boolean ;
@@ -53,13 +76,15 @@ export const DataViewTh: FC<DataViewThProps> = ({
5376 const thRef = useRef < HTMLTableCellElement > ( null ) ;
5477
5578 const [ width , setWidth ] = useState ( resizableProps ?. width ? resizableProps . width : 0 ) ;
79+ const classes = useStyles ( ) ;
5680
5781 const isResizable = resizableProps ?. isResizable || false ;
5882 const increment = resizableProps ?. increment || 5 ;
5983 const shiftIncrement = resizableProps ?. shiftIncrement || 25 ;
6084 const resizeButtonAriaLabel = resizableProps ?. resizeButtonAriaLabel ;
6185 const onResize = resizableProps ?. onResize || undefined ;
6286 const screenReaderText = resizableProps ?. screenReaderText || `Column ${ width . toFixed ( 0 ) } pixels` ;
87+ const dataViewThClassName = isResizable ? classes . dataViewResizeableTh : undefined ;
6388
6489 const resizeButtonRef = useRef < HTMLButtonElement > ( null ) ;
6590 const setInitialVals = useRef ( true ) ;
@@ -260,20 +285,22 @@ export const DataViewTh: FC<DataViewThProps> = ({
260285 } ;
261286
262287 return (
263- < Th { ...thProps } { ...props } style = { width > 0 ? { minWidth : width } : undefined } ref = { thRef } >
264- { content }
288+ < Th { ...thProps } { ...props } style = { width > 0 ? { minWidth : width } : undefined } ref = { thRef } modifier = "truncate" className = { dataViewThClassName } >
289+ < span className = "pf-v6-c-table__text" >
290+ { content }
291+ </ span >
265292 { isResizable && (
266293 < Button
267294 ref = { resizeButtonRef }
268295 variant = "plain"
296+ hasNoPadding
297+ icon = { < ResizeIcon /> }
269298 onMouseDown = { handleMousedown }
270299 onKeyDown = { handleKeys }
271300 onTouchStart = { handleTouchStart }
272- style = { { float : 'inline-end' } }
273301 aria-label = { resizeButtonAriaLabel }
274- >
275- test
276- </ Button >
302+ className = { classes . dataViewResizableButton }
303+ />
277304 ) }
278305 { isResizable && (
279306 < div aria-live = "polite" className = "pf-v6-screen-reader" >
0 commit comments