-
Notifications
You must be signed in to change notification settings - Fork 844
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[EuiSuperDatePicker] Convert quick select styles to Emotion #7909
Changes from 1 commit
12b03e3
1f87a27
c00dd28
025bb21
b9e4d46
5ff0fd1
26814bd
5c6a55e
4f8dab2
23661a1
25bf162
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { css } from '@emotion/react'; | ||
|
||
import { UseEuiTheme } from '../../../../services'; | ||
import { | ||
euiScrollBarStyles, | ||
logicalCSS, | ||
logicalCSSWithFallback, | ||
mathWithUnits, | ||
} from '../../../../global_styling'; | ||
|
||
export const euiQuickSelectPanelStyles = (euiThemeContext: UseEuiTheme) => { | ||
const { euiTheme } = euiThemeContext; | ||
|
||
return { | ||
euiQuickSelectPanel: css` | ||
&:not(:first-child) { | ||
${logicalCSS('border-top', euiTheme.border.thin)} | ||
${logicalCSS('padding-top', euiTheme.size.m)} | ||
${logicalCSS('margin-top', euiTheme.size.m)} | ||
} | ||
`, | ||
euiQuickSelectPanel__title: css` | ||
float: left; /* Required for fieldset/legend elements */ | ||
${logicalCSS('margin-bottom', euiTheme.size.m)} | ||
`, | ||
euiQuickSelectPanel__section: css` | ||
clear: both; /* Required for fieldset/legend elements */ | ||
${logicalCSS('margin-top', euiTheme.size.s)} | ||
${logicalCSS( | ||
'max-height', | ||
mathWithUnits(euiTheme.size.m, (x) => x * 12) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just wanted to highlight |
||
)} | ||
overflow: hidden; | ||
${logicalCSSWithFallback('overflow-y', 'auto')} | ||
${euiScrollBarStyles(euiThemeContext)} | ||
`, | ||
}; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import React, { FunctionComponent, ReactNode } from 'react'; | ||
|
||
import { useEuiMemoizedStyles } from '../../../../services'; | ||
import { EuiTitle } from '../../../title'; | ||
import type { CommonProps } from '../../../common'; | ||
|
||
import { euiQuickSelectPanelStyles } from './quick_select_panel.styles'; | ||
|
||
type EuiQuickSelectPanelProps = CommonProps & { | ||
component?: 'div' | 'fieldset'; | ||
title?: ReactNode; | ||
titleId?: string; | ||
children?: ReactNode; | ||
}; | ||
|
||
export const EuiQuickSelectPanel: FunctionComponent< | ||
EuiQuickSelectPanelProps | ||
> = ({ component: Component = 'div', title, titleId, children, ...rest }) => { | ||
const isFieldset = Component === 'fieldset'; | ||
const TitleComponent = isFieldset ? 'legend' : 'span'; | ||
|
||
const styles = useEuiMemoizedStyles(euiQuickSelectPanelStyles); | ||
|
||
return ( | ||
<Component css={styles.euiQuickSelectPanel} {...rest}> | ||
{title ? ( | ||
<> | ||
<EuiTitle size="xxxs"> | ||
<TitleComponent | ||
id={titleId} | ||
css={styles.euiQuickSelectPanel__title} | ||
> | ||
{title} | ||
</TitleComponent> | ||
</EuiTitle> | ||
<div css={styles.euiQuickSelectPanel__section}>{children}</div> | ||
</> | ||
) : ( | ||
children | ||
)} | ||
</Component> | ||
); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This float is now added to span as well as legend and I see this causes some differences in spacing:
Screen.Recording.2024-07-26.at.09.06.51.mov
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new version is actually more correct - we want the
<span>
to render more like a display block, whichfloat
automatically does. It looks like production was missing that