Skip to content

Commit

Permalink
[Emotion] Convert EuiHeader and EuiHeaderLogo (#6878)
Browse files Browse the repository at this point in the history
* Combine global and Amsterdam and Sass vars

- makes it easier to work with and the distinction isn't necessary at this point

* Set up `header.styles.ts`

* Set up `euiHeaderVariables` and convert more shared CSS

- see `src/global_styling/variables/_header.scss` for variable definitions
- NOTE: not removing the Sass variables for now as they're used by other Sass files and also by Kibana

* Convert position styles to Emotion

- remove modifier map

+ remove `border-top` override - unnecessary since the header already has a `bottom-border`, and unused since I don't see this pattern anywhere in EUI or Kibana

+ fix incorrect logical mapping - horizontal is `inline` and vertical is `block` 🤦

* Convert default and dark theme styles to Emotion

* [EuiHeader] Convert tests to RTL

* Remove unused `euiHeaderProfile` Sass

- Only used in `src-docs/` and can be totally replaced by `panelPaddingSize` 🤷

- not used anywhere in Kibana

* [EuiHeaderLogo] Clean up CSS

- Merge Amsterdam overrides and default CSS

- Remove unused `@include euiLink` mixin - it's basically not doing anything whatsoever since the hover/focus states are being unset later

- remove unused icon size override - XL icons aren't being used anyway and the modifier map was removed in the Emotion conversion

* [EuiHeaderLogo] Convert to Emotion

+ opinionated change - tweak padding-left on logo text to match other padding on `xs` breakpoint

+ remove unused `vertical-align: middle` CSS - flex handles alignment instead

* [EuiHeaderLogo] Update tests

- convert to RTL from Enyzme + add a test for `euiHeaderLogo__text`

* [EuiHeaderLogo] Reorganize files into its own subdirectory

- to match other subcomponents

* Add storybook stories

* Delete Sass files

* changelog
  • Loading branch information
cee-chen authored Jul 3, 2023
1 parent a4103fe commit 4fade52
Show file tree
Hide file tree
Showing 30 changed files with 446 additions and 298 deletions.
2 changes: 1 addition & 1 deletion src-docs/src/components/guide_page/_guide_page.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
.euiBody--headerIsFixed--double {
@include euiHeaderAffordForFixed($euiHeaderHeightCompensation * 2);

.euiHeader:not(.euiHeader--fixed) {
.euiHeader:not([data-fixed-header]) {
// Force headers below the fullscreen.
// This shouldn't be necessary in consuming applications because headers should always be at the top of the page
z-index: 0;
Expand Down
10 changes: 3 additions & 7 deletions src-docs/src/views/header/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,10 @@ const HeaderUserMenu = () => {
isOpen={isOpen}
anchorPosition="downRight"
closePopover={closeMenu}
panelPaddingSize="none"
panelPaddingSize="m"
>
<div style={{ width: 320 }}>
<EuiFlexGroup
gutterSize="m"
className="euiHeaderProfile"
responsive={false}
>
<div style={{ width: 300 }}>
<EuiFlexGroup gutterSize="m" responsive={false}>
<EuiFlexItem grow={false}>
<EuiAvatar name="John Username" size="xl" />
</EuiFlexItem>
Expand Down
10 changes: 3 additions & 7 deletions src-docs/src/views/header/header_alert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -278,14 +278,10 @@ const HeaderUserMenu = () => {
isOpen={isOpen}
anchorPosition="downRight"
closePopover={closeMenu}
panelPaddingSize="none"
panelPaddingSize="m"
>
<div style={{ width: 320 }}>
<EuiFlexGroup
gutterSize="m"
className="euiHeaderProfile"
responsive={false}
>
<div style={{ width: 300 }}>
<EuiFlexGroup gutterSize="m" responsive={false}>
<EuiFlexItem grow={false}>
<EuiAvatar name="John Username" size="xl" />
</EuiFlexItem>
Expand Down
2 changes: 1 addition & 1 deletion src/components/flyout/__snapshots__/flyout.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1093,7 +1093,7 @@ exports[`EuiFlyout renders extra screen reader instructions when fixed EuiHeader
>
<div>
<div
class="euiHeader euiHeader--default euiHeader--fixed"
class="euiHeader emotion-euiHeader-fixed-default"
data-fixed-header="true"
/>
<div>
Expand Down
17 changes: 9 additions & 8 deletions src/components/header/__snapshots__/header.test.tsx.snap
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`EuiHeader is rendered 1`] = `
exports[`EuiHeader renders 1`] = `
<div
aria-label="aria-label"
class="euiHeader euiHeader--default euiHeader--static testClass1 testClass2 emotion-euiTestCss"
class="euiHeader testClass1 testClass2 emotion-euiHeader-static-default-euiTestCss"
data-test-subj="test subject string"
/>
`;

exports[`EuiHeader renders children 1`] = `
<div
class="euiHeader euiHeader--default euiHeader--static"
class="euiHeader emotion-euiHeader-static-default"
>
<span>
Hello!
Expand All @@ -20,13 +20,13 @@ exports[`EuiHeader renders children 1`] = `

exports[`EuiHeader renders dark theme 1`] = `
<div
class="euiHeader euiHeader--dark euiHeader--static"
class="euiHeader emotion-euiHeader-static-dark"
/>
`;

exports[`EuiHeader renders in fixed position 1`] = `
<div
class="euiHeader euiHeader--default euiHeader--fixed"
class="euiHeader emotion-euiHeader-fixed-default"
data-fixed-header="true"
>
<span>
Expand All @@ -37,7 +37,7 @@ exports[`EuiHeader renders in fixed position 1`] = `

exports[`EuiHeader sections render breadcrumbs and props 1`] = `
<div
class="euiHeader euiHeader--default euiHeader--static"
class="euiHeader emotion-euiHeader-static-default"
>
<nav
aria-label="Breadcrumbs"
Expand All @@ -53,6 +53,7 @@ exports[`EuiHeader sections render breadcrumbs and props 1`] = `
<span
aria-current="page"
class="euiBreadcrumb__content emotion-euiBreadcrumb__content-application-isTruncatedLast-onlyChild-euiTextColor-default"
title="Breadcrumb"
>
Breadcrumb
</span>
Expand All @@ -64,7 +65,7 @@ exports[`EuiHeader sections render breadcrumbs and props 1`] = `

exports[`EuiHeader sections render simple items and borders 1`] = `
<div
class="euiHeader euiHeader--default euiHeader--static"
class="euiHeader emotion-euiHeader-static-default"
>
<div
class="euiHeaderSection euiHeaderSection--dontGrow euiHeaderSection--left"
Expand Down Expand Up @@ -99,7 +100,7 @@ exports[`EuiHeader sections render simple items and borders 1`] = `

exports[`EuiHeader throws a warning if both children and sections were passed 1`] = `
<div
class="euiHeader euiHeader--default euiHeader--static"
class="euiHeader emotion-euiHeader-static-default"
>
<div
class="euiHeaderSection euiHeaderSection--dontGrow euiHeaderSection--left"
Expand Down
29 changes: 0 additions & 29 deletions src/components/header/_header.scss

This file was deleted.

40 changes: 0 additions & 40 deletions src/components/header/_header_logo.scss

This file was deleted.

3 changes: 0 additions & 3 deletions src/components/header/_header_profile.scss

This file was deleted.

6 changes: 0 additions & 6 deletions src/components/header/_index.scss
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
// Components
@import 'mixins';

@import 'header';
@import 'header_profile';
@import 'header_links/index';
@import 'header_logo';
@import 'header_alert/index';
@import 'header_section/index';
36 changes: 0 additions & 36 deletions src/components/header/_mixins.scss

This file was deleted.

26 changes: 26 additions & 0 deletions src/components/header/header.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* 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 type { Meta, StoryObj } from '@storybook/react';

import { EuiHeader, EuiHeaderProps } from './header';

const meta: Meta<EuiHeaderProps> = {
title: 'EuiHeader',
component: EuiHeader,
};

export default meta;
type Story = StoryObj<EuiHeaderProps>;

export const Playground: Story = {
args: {
position: 'static',
theme: 'default',
},
};
Loading

0 comments on commit 4fade52

Please sign in to comment.