Fix ClearAdonment for light theme
This commit is contained in:
@@ -103,7 +103,7 @@ class TitleBar extends React.Component<Props, {}> {
|
|||||||
value={topicFilter}
|
value={topicFilter}
|
||||||
onChange={this.onFilterChange}
|
onChange={this.onFilterChange}
|
||||||
placeholder="Search…"
|
placeholder="Search…"
|
||||||
endAdornment={<div style={{ width: '24px', paddingRight: '8px' }}><ClearAdornment action={this.clearFilter} value={topicFilter} /></div>}
|
endAdornment={<div style={{ width: '24px', paddingRight: '8px' }}><ClearAdornment variant="primary" action={this.clearFilter} value={topicFilter} /></div>}
|
||||||
classes={{ root: classes.inputRoot, input: classes.inputInput }}
|
classes={{ root: classes.inputRoot, input: classes.inputInput }}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,28 +1,30 @@
|
|||||||
import * as React from 'react'
|
import * as React from 'react'
|
||||||
import Clear from '@material-ui/icons/Clear'
|
import Clear from '@material-ui/icons/Clear'
|
||||||
import { IconButton } from '@material-ui/core'
|
import { IconButton, Theme } from '@material-ui/core'
|
||||||
|
import { withTheme } from '@material-ui/core/styles'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
value?: string
|
value?: string
|
||||||
action: any
|
action: any
|
||||||
style?: React.CSSProperties
|
style?: React.CSSProperties
|
||||||
|
variant?: 'primary'
|
||||||
|
theme: Theme
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear button for text input fields
|
* Clear button for text input fields
|
||||||
*/
|
*/
|
||||||
class ClearAdornment extends React.Component<Props, {}> {
|
function ClearAdornment(props: Props) {
|
||||||
public render() {
|
if (!props.value) {
|
||||||
if (this.props.value) {
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
const color = props.variant === 'primary' ? props.theme.palette.primary.contrastText : undefined
|
||||||
return (
|
return (
|
||||||
<IconButton style={{ ...this.props.style, padding: '1px' }} onClick={this.props.action}>
|
<IconButton style={{ ...props.style, padding: '1px' }} onClick={props.action}>
|
||||||
<Clear style={{ fontSize: '16px' }} />
|
<Clear style={{ color, fontSize: '16px' }} />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return null
|
export default withTheme(ClearAdornment)
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default ClearAdornment
|
|
||||||
|
|||||||
Reference in New Issue
Block a user