-
Notifications
You must be signed in to change notification settings - Fork 841
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Emotion] Convert EuiTreeView (#7513)
Co-authored-by: Trevor Pierce <1Copenut@users.noreply.github.com>
- Loading branch information
Showing
14 changed files
with
592 additions
and
421 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
**Bug fixes** | ||
|
||
- Fixed an `EuiTreeView` bug where `aria-expanded` was being applied to items without expandable children | ||
|
||
**CSS-in-JS conversions** | ||
|
||
- Converted `EuiTreeView` to Emotion. Updates as part of the conversion: | ||
- Removed `.euiTreeView__wrapper` div node | ||
- Enforced consistent `icon` size based on `display` size |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
/* | ||
* 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, transparentize } from '../../services'; | ||
import { euiFocusRing, logicalCSS, mathWithUnits } from '../../global_styling'; | ||
|
||
export const euiTreeViewItemStyles = (euiThemeContext: UseEuiTheme) => { | ||
const { euiTheme } = euiThemeContext; | ||
|
||
const defaultSize = euiTheme.size.xl; | ||
const compressedSize = euiTheme.size.l; | ||
|
||
return { | ||
li: { | ||
euiTreeView__node: css``, | ||
default: css` | ||
${logicalCSS('max-height', defaultSize)} | ||
line-height: ${defaultSize}; | ||
`, | ||
compressed: css` | ||
${logicalCSS('max-height', compressedSize)} | ||
line-height: ${compressedSize}; | ||
`, | ||
expanded: css` | ||
${logicalCSS('max-height', '100vh')} | ||
`, | ||
}, | ||
|
||
button: { | ||
euiTreeView__nodeInner: css` | ||
${logicalCSS('width', '100%')} | ||
${logicalCSS('padding-left', euiTheme.size.s)} | ||
${logicalCSS('padding-right', euiTheme.size.xxs)} | ||
display: flex; | ||
align-items: center; | ||
&:focus { | ||
${euiFocusRing(euiThemeContext, 'inset')} | ||
} | ||
&:hover, | ||
&:active, | ||
&:focus { | ||
background-color: ${transparentize( | ||
euiTheme.colors.text, | ||
euiTheme.focus.transparency | ||
)}; | ||
} | ||
`, | ||
default: css` | ||
${logicalCSS('height', defaultSize)} | ||
gap: ${euiTheme.size.s}; | ||
border-radius: ${euiTheme.border.radius.medium}; | ||
`, | ||
compressed: css` | ||
${logicalCSS('height', compressedSize)} | ||
gap: ${euiTheme.size.xs}; | ||
border-radius: ${euiTheme.border.radius.small}; | ||
`, | ||
}, | ||
|
||
icon: { | ||
euiTreeView__iconWrapper: css` | ||
flex-shrink: 0; | ||
line-height: 0; /* Vertically centers the icon */ | ||
/* Handle smaller icons in compressed mode */ | ||
& > * { | ||
${logicalCSS('max-width', '100%')} | ||
} | ||
& > .euiToken { | ||
${logicalCSS('max-height', '100%')} | ||
${logicalCSS('height', 'auto')} | ||
svg { | ||
${logicalCSS('width', '100%')} | ||
} | ||
} | ||
`, | ||
default: css` | ||
${logicalCSS( | ||
'width', | ||
mathWithUnits(defaultSize, (x) => x / 2) | ||
)} | ||
`, | ||
compressed: css` | ||
${logicalCSS( | ||
'width', | ||
mathWithUnits(compressedSize, (x) => x / 2) | ||
)} | ||
`, | ||
}, | ||
}; | ||
}; |
Oops, something went wrong.