Skip to content
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

[EuiTab] Fix prepend/append elements not inheriting selected colors + misc CSS cleanup #6938

Merged
merged 5 commits into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ exports[`EuiPageHeader props page content props are passed down is rendered 1`]
type="button"
>
<span
class="euiTab__content emotion-euiTab__content-l-selected"
class="euiTab__content emotion-euiTab__content-l"
>
Tab 1
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ exports[`EuiPageHeaderContent props children is rendered even if content props a
type="button"
>
<span
class="euiTab__content emotion-euiTab__content-l-selected"
class="euiTab__content emotion-euiTab__content-l"
>
Tab 1
</span>
Expand Down Expand Up @@ -586,7 +586,7 @@ exports[`EuiPageHeaderContent props tabs is rendered 1`] = `
type="button"
>
<span
class="euiTab__content emotion-euiTab__content-xl-selected"
class="euiTab__content emotion-euiTab__content-xl"
>
Tab 1
</span>
Expand Down Expand Up @@ -637,7 +637,7 @@ exports[`EuiPageHeaderContent props tabs is rendered with tabsProps 1`] = `
type="button"
>
<span
class="euiTab__content emotion-euiTab__content-xl-selected"
class="euiTab__content emotion-euiTab__content-xl"
>
Tab 1
</span>
Expand Down
6 changes: 3 additions & 3 deletions src/components/tabs/__snapshots__/tab.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ exports[`EuiTab props disabled and selected 1`] = `
type="button"
>
<span
class="euiTab__content emotion-euiTab__content-m-selected-disabled"
class="euiTab__content emotion-euiTab__content-m"
>
Click Me
</span>
Expand All @@ -45,7 +45,7 @@ exports[`EuiTab props disabled is rendered 1`] = `
type="button"
>
<span
class="euiTab__content emotion-euiTab__content-m-disabled"
class="euiTab__content emotion-euiTab__content-m"
>
Click Me
</span>
Expand Down Expand Up @@ -78,7 +78,7 @@ exports[`EuiTab props isSelected is rendered 1`] = `
type="button"
>
<span
class="euiTab__content emotion-euiTab__content-m-selected"
class="euiTab__content emotion-euiTab__content-m"
>
children
</span>
Expand Down
29 changes: 11 additions & 18 deletions src/components/tabs/tab.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
*/

import { css } from '@emotion/react';
import { logicalCSS, mathWithUnits } from '../../global_styling';
import { logicalCSS, mathWithUnits, euiFontSize } from '../../global_styling';
import { UseEuiTheme } from '../../services';
import { euiTitle } from '../title/title.styles';

export const euiTabStyles = ({ euiTheme }: UseEuiTheme) => {
return {
Expand All @@ -18,13 +17,15 @@ export const euiTabStyles = ({ euiTheme }: UseEuiTheme) => {
cursor: pointer;
flex-direction: row;
align-items: center;
font-weight: ${euiTheme.font.weight.semiBold};
gap: ${euiTheme.size.s};
${logicalCSS('padding-vertical', 0)}
${logicalCSS('padding-horizontal', euiTheme.size.xs)}

/* Font-weight used by append/prepend nodes - the tab title receives a heavier weight */
font-weight: ${euiTheme.font.weight.semiBold};
color: ${euiTheme.colors.title};

&:focus {
background-color: transparent;
outline-offset: -${euiTheme.focus.width};
}
`,
Expand All @@ -36,6 +37,7 @@ export const euiTabStyles = ({ euiTheme }: UseEuiTheme) => {
`,
selected: css`
box-shadow: inset 0 -${euiTheme.border.width.thick} 0 ${euiTheme.colors.primary};
color: ${euiTheme.colors.primaryText};
`,
disabled: {
disabled: css`
Expand All @@ -54,39 +56,30 @@ export const euiTabContentStyles = (euiThemeContext: UseEuiTheme) => {

return {
euiTab__content: css`
&:hover {
text-decoration: none;
}
font-weight: ${euiTheme.font.weight[euiTheme.font.title.weight]};
`,
// sizes
s: css`
${euiTitle(euiThemeContext, 'xxxs')}
font-size: ${euiFontSize(euiThemeContext, 'xs').fontSize};
line-height: ${euiTheme.size.xl};
`,
m: css`
${euiTitle(euiThemeContext, 'xxs')}
font-size: ${euiFontSize(euiThemeContext, 's').fontSize};
line-height: ${euiTheme.size.xxl};
`,
l: css`
${euiTitle(euiThemeContext, 'xs')}
font-size: ${euiFontSize(euiThemeContext, 'm').fontSize};
line-height: ${mathWithUnits(
[euiTheme.size.xl, euiTheme.size.s],
(x, y) => x + y
)};
`,
xl: css`
${euiTitle(euiThemeContext, 's')}
font-size: ${euiFontSize(euiThemeContext, 'l').fontSize};
line-height: ${mathWithUnits(
[euiTheme.size.xxxl, euiTheme.size.s],
(x, y) => x + y
)};
`,
// variations
selected: css`
color: ${euiTheme.colors.primaryText};
`,
disabled: css`
color: ${euiTheme.colors.disabledText};
`,
};
};
2 changes: 0 additions & 2 deletions src/components/tabs/tab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ export const EuiTab: FunctionComponent<Props> = ({
const cssTabContentStyles = [
tabContentStyles.euiTab__content,
size && tabContentStyles[size],
isSelected && tabContentStyles.selected,
disabled && tabContentStyles.disabled,
];

const prependNode = prepend && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ exports[`EuiTabbedContent behavior when selected tab state isn't controlled by t
type="button"
>
<span
class="euiTab__content emotion-euiTab__content-m-selected"
class="euiTab__content emotion-euiTab__content-m"
>
Elasticsearch
</span>
Expand Down Expand Up @@ -95,7 +95,7 @@ exports[`EuiTabbedContent behavior when uncontrolled, the selected tab should up
prepend
</span>
<span
class="euiTab__content emotion-euiTab__content-m-selected"
class="euiTab__content emotion-euiTab__content-m"
>
<strong>
Kibana
Expand Down Expand Up @@ -139,7 +139,7 @@ exports[`EuiTabbedContent is rendered with required props and tabs 1`] = `
type="button"
>
<span
class="euiTab__content emotion-euiTab__content-m-selected"
class="euiTab__content emotion-euiTab__content-m"
>
Elasticsearch
</span>
Expand Down Expand Up @@ -199,7 +199,7 @@ exports[`EuiTabbedContent props autoFocus initial is rendered 1`] = `
type="button"
>
<span
class="euiTab__content emotion-euiTab__content-m-selected"
class="euiTab__content emotion-euiTab__content-m"
>
Elasticsearch
</span>
Expand Down Expand Up @@ -259,7 +259,7 @@ exports[`EuiTabbedContent props autoFocus selected is rendered 1`] = `
type="button"
>
<span
class="euiTab__content emotion-euiTab__content-m-selected"
class="euiTab__content emotion-euiTab__content-m"
>
Elasticsearch
</span>
Expand Down Expand Up @@ -339,7 +339,7 @@ exports[`EuiTabbedContent props initialSelectedTab renders a selected tab 1`] =
prepend
</span>
<span
class="euiTab__content emotion-euiTab__content-m-selected"
class="euiTab__content emotion-euiTab__content-m"
>
<strong>
Kibana
Expand Down Expand Up @@ -399,7 +399,7 @@ exports[`EuiTabbedContent props selectedTab renders a selected tab 1`] = `
prepend
</span>
<span
class="euiTab__content emotion-euiTab__content-m-selected"
class="euiTab__content emotion-euiTab__content-m"
>
<strong>
Kibana
Expand Down Expand Up @@ -439,7 +439,7 @@ exports[`EuiTabbedContent props size can be small 1`] = `
type="button"
>
<span
class="euiTab__content emotion-euiTab__content-s-selected"
class="euiTab__content emotion-euiTab__content-s"
>
Elasticsearch
</span>
Expand Down
4 changes: 4 additions & 0 deletions upcoming_changelogs/6938.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
**Bug fixes**

- Fixed `EuiTab` not correctly passing selection color state to `prepend` and `append` children

Loading