mirror of https://github.com/grafana/grafana
GrafanaUI: Fix styles for invalid selects & DataSourcePicker (#53476)
* GrafanaUI: fix styles for invalid select & DataSourcePicker * Apply suggestions from code review Co-authored-by: Dominik Prokop <dominik.prokop@grafana.com> * fix focus issues & tests * remove unused import * TypeScript work in progress * Move react select props to types.ts Co-authored-by: Dominik Prokop <dominik.prokop@grafana.com> Co-authored-by: eledobleefe <laura.fernandez@grafana.com> Co-authored-by: joshhunt <josh@trtr.co>pull/54330/head
parent
a58edc9f5e
commit
26524e3ff1
@ -1,59 +0,0 @@ |
||||
import { css, cx } from '@emotion/css'; |
||||
import React from 'react'; |
||||
import { components, ContainerProps, GroupBase } from 'react-select'; |
||||
|
||||
import { GrafanaTheme2 } from '@grafana/data'; |
||||
|
||||
import { stylesFactory } from '../../themes'; |
||||
import { useTheme2 } from '../../themes/ThemeContext'; |
||||
import { focusCss } from '../../themes/mixins'; |
||||
import { sharedInputStyle } from '../Forms/commonStyles'; |
||||
import { getInputStyles } from '../Input/Input'; |
||||
|
||||
export const SelectContainer = <Option, isMulti extends boolean, Group extends GroupBase<Option>>( |
||||
props: ContainerProps<Option, isMulti, Group> & { isFocused: boolean } |
||||
) => { |
||||
const { isDisabled, isFocused, children } = props; |
||||
|
||||
const theme = useTheme2(); |
||||
const styles = getSelectContainerStyles(theme, isFocused, isDisabled); |
||||
|
||||
return ( |
||||
<components.SelectContainer {...props} className={cx(styles.wrapper, props.className)}> |
||||
{children} |
||||
</components.SelectContainer> |
||||
); |
||||
}; |
||||
|
||||
const getSelectContainerStyles = stylesFactory((theme: GrafanaTheme2, focused: boolean, disabled: boolean) => { |
||||
const styles = getInputStyles({ theme, invalid: false }); |
||||
|
||||
return { |
||||
wrapper: cx( |
||||
styles.wrapper, |
||||
sharedInputStyle(theme, false), |
||||
focused && |
||||
css` |
||||
${focusCss(theme.v1)} |
||||
`,
|
||||
disabled && styles.inputDisabled, |
||||
css` |
||||
position: relative; |
||||
box-sizing: border-box; |
||||
display: flex; |
||||
flex-direction: row; |
||||
flex-wrap: wrap; |
||||
align-items: center; |
||||
justify-content: space-between; |
||||
|
||||
min-height: 32px; |
||||
height: auto; |
||||
max-width: 100%; |
||||
|
||||
/* Input padding is applied to the InputControl so the menu is aligned correctly */ |
||||
padding: 0; |
||||
cursor: ${disabled ? 'not-allowed' : 'pointer'}; |
||||
` |
||||
), |
||||
}; |
||||
}); |
Loading…
Reference in new issue