mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
FormField: migrated sass styling to emotion (#30392)
* merged conflicts * added and utilised useStyle hooks * Fixes snapshot test * FormField: added grow property to component * added a carriage return to index.scss * properly sort props so the required props are at the top * removed the grow props since it's not used * fixes frontend test- I hope
This commit is contained in:
parent
5d029abc42
commit
ffc6eda351
@ -1,7 +1,9 @@
|
||||
import React, { InputHTMLAttributes, FunctionComponent } from 'react';
|
||||
import { cx } from 'emotion';
|
||||
import { css, cx } from 'emotion';
|
||||
import { GrafanaTheme } from '@grafana/data';
|
||||
import { InlineFormLabel } from '../FormLabel/FormLabel';
|
||||
import { PopoverContent } from '../Tooltip/Tooltip';
|
||||
import { useStyles } from '../../themes';
|
||||
|
||||
export interface Props extends InputHTMLAttributes<HTMLInputElement> {
|
||||
label: string;
|
||||
@ -30,8 +32,9 @@ export const FormField: FunctionComponent<Props> = ({
|
||||
className,
|
||||
...inputProps
|
||||
}) => {
|
||||
const styles = useStyles(getStyles);
|
||||
return (
|
||||
<div className={cx('form-field', className)}>
|
||||
<div className={cx(styles.formField, className)}>
|
||||
<InlineFormLabel width={labelWidth} tooltip={tooltip}>
|
||||
{label}
|
||||
</InlineFormLabel>
|
||||
@ -44,3 +47,15 @@ export const FormField: FunctionComponent<Props> = ({
|
||||
|
||||
FormField.displayName = 'FormField';
|
||||
FormField.defaultProps = defaultProps;
|
||||
|
||||
const getStyles = (theme: GrafanaTheme) => {
|
||||
return {
|
||||
formField: css`
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: flex-start;
|
||||
text-align: left;
|
||||
position: relative;
|
||||
`,
|
||||
};
|
||||
};
|
||||
|
@ -1,11 +0,0 @@
|
||||
.form-field {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: flex-start;
|
||||
text-align: left;
|
||||
position: relative;
|
||||
|
||||
&--grow {
|
||||
flex-grow: 1;
|
||||
}
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
|
||||
exports[`FormField should render component with custom inputEl 1`] = `
|
||||
<div
|
||||
className="form-field"
|
||||
className="css-aq4c43"
|
||||
>
|
||||
<FormLabel
|
||||
width={11}
|
||||
@ -20,7 +20,7 @@ exports[`FormField should render component with custom inputEl 1`] = `
|
||||
|
||||
exports[`FormField should render component with default inputEl 1`] = `
|
||||
<div
|
||||
className="form-field"
|
||||
className="css-aq4c43"
|
||||
>
|
||||
<FormLabel
|
||||
width={11}
|
||||
|
@ -1,7 +1,6 @@
|
||||
@import 'ButtonCascader/ButtonCascader';
|
||||
@import 'ColorPicker/ColorPicker';
|
||||
@import 'Drawer/Drawer';
|
||||
@import 'FormField/FormField';
|
||||
@import 'RefreshPicker/RefreshPicker';
|
||||
@import 'Forms/Legacy/Select/Select';
|
||||
@import 'TimePicker/TimeOfDayPicker';
|
||||
|
Loading…
Reference in New Issue
Block a user