Skip to content

Commit 8081fda

Browse files
[Emotion] Convert EuiCode and EuiCodeBlock (#6263)
* Splitting components and adding styles.ts files * Splitting code block virtualized as a component * Adjusting paddings * Add fullscreen styles * Fixing lint errors. Adding CL * Adding euiCodeSyntaxStyles to emotion global * Uncommenting test * Remove Global Emotion CSS - which removes useLayoutEffect warnings in tests * Fix code block mounted tests - because they're mounted, there's now a million Emotion wrappers with repeated props and we have to specify the non-emotion ones - also remove mounted snapshot * Removed unnecessary Emotion styles * Use `@emotion/css` to flatten euiCodeBlock__line CSS * [Architectural refactor] Move hooks and sub-components to files organized by concept/feature + other misc cleanup * Clean up styles further - went down a bit of a rabbit hole with this, sorry - especially w/ refactoring `mathWithUnits` to accept multiple args (been on my radar for some time) - the major bug that this work fixes is that we *can't* use a dynamic `paddingSize` based on isFullScreen because the fullscreen code block and non-fullscreen code block need separate and non-connected padding sizes - in the end i'm still not 100% convinced the code is less 'ugly' with the new `generatePaddingCss` util but our Emotion styles are now more static at least :/ which, considering perf is already a little questionable with the tokens mixin, I thought was worth the tradeoff * Clean up line CSS further - no need for extra `style` + calculation - just use flex - allows removing static reference to euiSizeS * Fix virtualized code blocks not respecting paddingSize + dry out tabIndex prop * [misc] style logical property * Added `shouldRenderCustomStyles` Co-authored-by: Constance Chen <[email protected]>
1 parent 1e19586 commit 8081fda

33 files changed

+1280
-979
lines changed

src-docs/src/views/code/virtualized_flyout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export default () => {
2525
<h2 id="flyoutTitle">A flyout with just code</h2>
2626
</EuiTitle>
2727
</EuiFlyoutHeader>
28-
<div style={{ height: '100%' }}>
28+
<div style={{ blockSize: '100%' }}>
2929
<EuiCodeBlock
3030
language="json"
3131
overflowHeight={'100%'}

src/components/code/__snapshots__/code.test.tsx.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
exports[`EuiCode renders a code snippet 1`] = `
44
<code
55
aria-label="aria-label"
6-
class="euiCode testClass1 testClass2"
6+
class="euiCode testClass1 testClass2 emotion-euiCode"
77
data-code-language="text"
88
data-test-subj="test subject string"
99
>
@@ -15,7 +15,7 @@ console.log(some);
1515
exports[`EuiCode renders languages 1`] = `
1616
<code
1717
aria-label="aria-label"
18-
class="euiCode testClass1 testClass2"
18+
class="euiCode testClass1 testClass2 emotion-euiCode"
1919
data-code-language="js"
2020
data-test-subj="test subject string"
2121
>
@@ -80,7 +80,7 @@ exports[`EuiCode renders languages 1`] = `
8080
exports[`EuiCode renders transparent backgrounds 1`] = `
8181
<code
8282
aria-label="aria-label"
83-
class="euiCode euiCode--transparentBackground testClass1 testClass2"
83+
class="euiCode testClass1 testClass2 emotion-euiCode-transparentBackground"
8484
data-code-language="text"
8585
data-test-subj="test subject string"
8686
>

0 commit comments

Comments
 (0)