Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

weronikaolejniczak
Copy link
Contributor

@weronikaolejniczak weronikaolejniczak commented Jun 20, 2025

Summary

On this PR, I prepare docusaurus-theme to be released and consumed by other teams at Elastic.

Changes

  • removed eui-docgen dependency
  • made VersionSwitcher
  • refactor VersionSwitcher usage
  • made PropsTable reusable
  • extend the theme PropsTable
  • removed incorrect @elastic/eui imports from severity pattern
  • updated broken documentation links
    • fixed links in the data grid container constraints
  • added license headers to all relevant files
  • added license field and files
  • package.json to be ready for package release

I recommend going commit by commit.

Tip

You can read more about Swizzling component here.

Why are we making this change?

https://github.com/elastic/eui-private/issues/150 - we want to publish packages/docusaurus-theme so it can be consumed by other teams at Elastic, e.g. Kibana.

Screenshots

Incorrect links

Screenshot 2025-06-20 at 15 15 13

Incorrect imports

Screenshot 2025-06-20 at 15 33 02

Much better...

Screenshot 2025-08-01 at 12 26 13

Impact to users

🟢 This is not a breaking change. The documentation website behavior should remain the same.

QA

  1. Checkout this branch: gh pr checkout 8814
  2. Install dependencies: yarn
  3. Build documentation page workspaces: yarn workspace @elastic/eui-website build:workspaces
  4. Start the documentation page: yarn workspace @elastic/eui-website start

Checklist:

  • Version switcher works as expected
  • Prop tables render as expected
  • The links in prop tables work
  • Example demos work as expected
  • Codesandbox functionality works as expected
  • Color mode toggles as expected

Optionally:

  • Verify that there are no broken link warnings when running the dev server
  • Build packages/docusaurus-theme and use in a Docusaurus scaffolding (Refer to README.md for instructions)

@weronikaolejniczak weronikaolejniczak self-assigned this Jun 20, 2025
@weronikaolejniczak weronikaolejniczak added the skip-changelog Use on PRs to skip changelog requirement (Don't delete - used for automation) label Jun 20, 2025
@weronikaolejniczak weronikaolejniczak changed the title chore(website): move PropsTable to website from docusaurus-theme [WIP] chore(website): move PropsTable to website from docusaurus-theme Jun 27, 2025
@weronikaolejniczak weronikaolejniczak force-pushed the chore/prepare-docusaurus-theme branch from 3e5d133 to fe1f7ec Compare July 7, 2025 10:13
@weronikaolejniczak weronikaolejniczak force-pushed the chore/prepare-docusaurus-theme branch 2 times, most recently from 6eb6ff5 to 8c28777 Compare August 4, 2025 10:05
@weronikaolejniczak weronikaolejniczak changed the title [WIP] chore(website): move PropsTable to website from docusaurus-theme chore(website): move PropsTable to website from docusaurus-theme Aug 4, 2025
@weronikaolejniczak weronikaolejniczak changed the title chore(website): move PropsTable to website from docusaurus-theme Docusaurus theme updates for release Aug 4, 2025
@weronikaolejniczak weronikaolejniczak marked this pull request as ready for review August 4, 2025 10:46
@weronikaolejniczak weronikaolejniczak requested a review from a team as a code owner August 4, 2025 10:46
@weronikaolejniczak weronikaolejniczak force-pushed the chore/prepare-docusaurus-theme branch from fed59ab to ff9ed67 Compare August 4, 2025 10:47
@mgadewoll
Copy link
Contributor

ℹ️ The commit links in the description would need an update, they change when force pushing 😅

Screenshot 2025-08-27 at 09 24 12

@mgadewoll
Copy link
Contributor

Build packages/docusaurus-theme and use in a Docusaurus scaffolding

💭 Providing steps would make QA more clear and streamlined here. What's required to configure the theme setup? What other dependencies would need to be installed? etc.

@weronikaolejniczak
Copy link
Contributor Author

💭 Providing steps would make QA more clear and streamlined here.

The reason why I didn't provide them is because we've discussed this topic with @tkajtoch and I was expecting a review from him. So I made a mental shortcut in the QA section because he'd know exactly how to test this.

Now that you want to test it, which I'm grateful for, I can spend some time on writing a more detailed description. That being said, I'll ask you for your patience because this PR is of lesser priority like we discussed, and I have some other high priorities I need to handle at the moment.

I will just ping you whenever you can review the PR again 😄 Thanks!

@weronikaolejniczak
Copy link
Contributor Author

Now I noticed the footer isn't rendering correctly (not sure why but locally it showed up correctly for me after the change). Working on it.

Screenshot 2025-09-09 at 15 22 55

@mgadewoll
Copy link
Contributor

@weronikaolejniczak The additional added changes make sense and look good to me. Thanks for adding them!
Let me know if you'll add any further changes (colorMode, footer) or if the existing changes are the full set and I'll review or approve accordingly. 👍

@elasticmachine
Copy link
Collaborator

💚 Build Succeeded

History

cc @weronikaolejniczak

@weronikaolejniczak
Copy link
Contributor Author

@mgadewoll the PR is ready to be re-reviewed. Everything should be working as expected in our documentation website.

@elasticmachine
Copy link
Collaborator

💚 Build Succeeded

History

cc @weronikaolejniczak

<EuiText textAlign="center" size="s" css={styles.text}>
{footer?.copyright}
</EuiText>
<EuiText
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Looking at this, the color contrast is rather bad. That's because it uses light mode colors. We could rather use a EuiThemeProvider with locked dark color mode.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mgadewoll the EuiThemeProvider and forced dark mode is 👇🏻

Or do you propose something else?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah right, sorry I missed it. 🤦‍♀️
But I see the issue now: The links are not using the MDX components anymore, meaning they don't get the EUI styles that would automatically update. Might be due to the dangerouslySetInnerHTML usage.

prod pr
Screenshot 2025-10-07 at 12 47 55 Screenshot 2025-10-07 at 12 50 52
Screenshot 2025-10-07 at 12 52 32 Screenshot 2025-10-07 at 12 52 39

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, that's a great catch! 🤔 Previously, the copyright was put directly into the Footer theme component and links were wrapped with EuiLink. Moving it to the config and using dangerouslySetInnerHTML required to use plain HTML (that's what the original Docusaurus footer does btw).

What we could do to make it better is take the euiLinkStyles and apply it to a on the footer element. What do you think? (packages/eui/src/components/link/link.styles.ts)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think that's a fair enough solution for this case 👍

*/
const getSystemColorMode = (): EuiThemeColorMode => {
if (typeof window !== 'undefined' && window.matchMedia) {
return window.matchMedia('(prefers-color-scheme: dark)').matches
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocking: Removing this means that the page doesn't listen to the user OS level preference anymore. We should support it as fallback: if no colorMode is set yet, listen to the OS setting.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mgadewoll this doesn't work. It always fallbacks to light. That's why I removed it because it's redundant logic and would have to be rewritten to be server-side friendly. Preferably, hook into the Docusaurus existing theming mechanism. The issue is, when I did it, the styles broke in production mode.

There should be no regression to color mode. I tested both in our documentation page and in a fresh Docusaurus. Do you see a regression? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is prod:

Kapture.2025-10-07.at.12.13.43.mp4

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, I don't see it working in prod either. Looks like the colorMode wasn't properly saved before 🫠
In any case, I do think we should listen to the OS level setting as fallback. But we can also do that separately, I don't think it's blocking.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mgadewoll I agree with you, we should 👍🏻 I played around with several approaches and the only way I was able to make it work is hook up to Docusaurus theming mechanism and let it handle both the OS and local storage, while adjusting the EuiThemeProvider on our side. Worked well locally but when server-side came into the picture in production build, on refresh the styling was broken.

Thanks for being alert 💚 I'll create an issue for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip-changelog Use on PRs to skip changelog requirement (Don't delete - used for automation)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants