-
Notifications
You must be signed in to change notification settings - Fork 842
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
[Emotion] Add @emotion/css
as a dev and peer dependency
#6288
Changes from all commits
bc1be72
3399bdf
41e4ac5
88ac73a
d08a00b
04a81c6
ff5aaed
817e387
14fdc19
516fe7b
9531573
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import React, { useEffect, useState, useMemo } from 'react'; | ||
import { createPortal } from 'react-dom'; | ||
import { useLocation } from 'react-router-dom'; | ||
import { ClassNames } from '@emotion/react'; | ||
import { css } from '@emotion/css'; | ||
|
||
import { EuiButtonIcon, useEuiTheme, logicalCSS } from '../../../../src'; | ||
|
||
|
@@ -33,43 +33,39 @@ export const useHeadingAnchorLinks = () => { | |
// to quickly get/copy the heading anchor link | ||
const anchorLinks = useMemo( | ||
() => ( | ||
<ClassNames> | ||
{({ css }) => ( | ||
<> | ||
{headingNodes.map((heading) => { | ||
const headingCss = css` | ||
&:hover [data-anchor-link] { | ||
opacity: 1; | ||
} | ||
`; | ||
const linkCss = css` | ||
opacity: 0; | ||
${logicalCSS('margin-left', euiTheme.size.s)} | ||
<> | ||
{headingNodes.map((heading) => { | ||
const headingCss = css` | ||
&:hover [data-anchor-link] { | ||
opacity: 1; | ||
} | ||
`; | ||
const linkCss = css` | ||
opacity: 0; | ||
${logicalCSS('margin-left', euiTheme.size.s)} | ||
Comment on lines
+38
to
+45
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. 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. Oh, super interesting. Thanks for catching that! It looks like we'd need to use a custom I do agree their uses are generally relatively limited, so it may not have to be something we worry about anytime soon. |
||
|
||
&:hover, | ||
&:hover, | ||
&:focus { | ||
opacity: 1; | ||
} | ||
`; | ||
opacity: 1; | ||
} | ||
`; | ||
|
||
heading.classList.add(headingCss); | ||
heading.classList.add(headingCss); | ||
|
||
return createPortal( | ||
<EuiButtonIcon | ||
data-anchor-link | ||
iconType="link" | ||
color="text" | ||
size="xs" | ||
css={linkCss} | ||
aria-label="Go to heading anchor link" | ||
href={`#${pathname}#${heading.id}`} | ||
/>, | ||
heading | ||
); | ||
})} | ||
</> | ||
)} | ||
</ClassNames> | ||
return createPortal( | ||
<EuiButtonIcon | ||
data-anchor-link | ||
iconType="link" | ||
color="text" | ||
size="xs" | ||
className={linkCss} | ||
aria-label="Go to heading anchor link" | ||
href={`#${pathname}#${heading.id}`} | ||
/>, | ||
heading | ||
); | ||
})} | ||
</> | ||
), | ||
[headingNodes] // eslint-disable-line react-hooks/exhaustive-deps | ||
); | ||
|
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.
@thompsongl would love your opinion on this (removing
@emotion/cache
from our required peer dependencies now that we can use@emotion/css
instead - see 88ac73a, d08a00b). I don't feel incredibly strongly about it but I do feel it's a nice to have.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.
Yeah that's probably the right call. We're making a breaking change with adding
@emotion/css
, so might as well be thorough.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.
We still use @emotion/cache in a few
src
locations and need to keep the dependency aroundThere 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.
I cannot read file paths. Only one usage remains (cache_provider.tsx) which is only a type but still maintains that dependency.
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.
Are you sure? We had
EmotionCache
defined as a type before we declared it as a peer dependency:https://github.com/elastic/eui/pull/6126/files#diff-a1648a5c54676d1ae54abfef57822d0dd31c82d6109e9b3bd789b2626cc06756
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.
If it ends up in eui.d.ts it needs to be a dependency, otherwise the consuming app's typescript will fail to resolve it
from yesterday's build:
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.
I can change this to reference the typeof
cache
from@emotion/css
... but@emotion/css
's create-instance.d.ts is calling@emotion/cache
's EmotionCache type def anyway:https://github.com/emotion-js/emotion/blob/main/packages/css/types/create-instance.d.ts
so there's probably some underlying sub-dependency magic going on here.
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.
516fe7b
the above commit in meme form:
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.
Thank you for the scooby doo change! I understand it ultimately ends up being the same, it does make the housekeeping a little cleaner.
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.
For sure!!