Skip to content
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

fix(docusaurus-theme): fill Codesandbox icon with currentColor #8127

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

weronikaolejniczak
Copy link
Contributor

@weronikaolejniczak weronikaolejniczak commented Nov 8, 2024

Summary

The Codesandbox icon in the footer of each example in EUI+ doesn't change the color depending on the theme (dark / light mode).

QA

  1. Open the new docs.
  2. Navigate to any component page (e.g. Accordion).
  3. Notice the component preview. In the footer, there's a Codesandbox icon.
  4. Switch themes using the toggle in the top right of the page.
  5. Verify that the Codesandbox icon is visible. In light mode it should be black, in dark mode white.
Screen.Recording.2024-11-08.at.19.34.42.mov

@weronikaolejniczak weronikaolejniczak requested a review from a team as a code owner November 8, 2024 18:36
@weronikaolejniczak weronikaolejniczak added documentation Issues or PRs that only affect documentation - will not need changelog entries skip-changelog labels Nov 8, 2024
@mgadewoll
Copy link
Contributor

mgadewoll commented Nov 11, 2024

@weronikaolejniczak

Nothing is applicable... 👀

A general fyi for the "QA" section:
We have the general QA checklist but besides that you can add your own QA instructions.
E.g. something like this:

- open EUI+ docs (example link here)
- toggle the color mode switch in the page header
- [ ] verify that the codesandbox icon on code examples updates its color accordingly on color mode change

There is no expected pattern for this, just in general some instructions to follow for people to know what to look at and verify considering someone might see it and not fully know what it's about (this PR is simple but more as a common approach)

@weronikaolejniczak
Copy link
Contributor Author

@mgadewoll that's a good point 👌🏻 I updated the description with proper QA instructions.

viewBox="-20 0 296 296">
<path
d="M115.498 261.088v-106.61L23.814 101.73v60.773l41.996 24.347v45.7l49.688 28.54Zm23.814.627 50.605-29.151V185.78l42.269-24.495v-60.011l-92.874 53.621v106.82Zm80.66-180.887-48.817-28.289-42.863 24.872-43.188-24.897-49.252 28.667 91.914 52.882 92.206-53.235ZM0 222.212V74.495L127.987 0 256 74.182v147.797l-128.016 73.744L0 222.212Z" />
<svg
Copy link
Contributor

@mgadewoll mgadewoll Nov 11, 2024

Choose a reason for hiding this comment

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

This solution works but I think we might be able to make it even better 🙂
The icon is passed to EuiButtonIcon (here) which then passes icons to EuiIcon (here) and EuiIcon returns the icon component with added props here.

If we want the icon to behave like an EuiIcon - and not only update color - the only thing missing here is making sure that we spread the props to this custom svg. This will then also ensure other props e.g. className or a11y props like role, aria-hidden or aria-label are passed along.

// since it's not actually an EuiIcon component but the return of that component that's not 
// specifically defined and it could be used in other places, I'd think `any` type is fine here
const CodeSandboxIcon = (props: any) => (
  <svg {...props}
   ...
   />

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually let's use HTMLAttributes<SVGElement> as type for props to have some limitations at least.

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 thanks for the suggestion! 🙌🏻 I implemented the changes and re-tested, and added one more commit with a typo fix. Could you review again?

@kibanamachine
Copy link

Preview staging links for this PR:

@elasticmachine
Copy link
Collaborator

💚 Build Succeeded

History

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Issues or PRs that only affect documentation - will not need changelog entries skip-changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants