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

[EuiSelectable] Enable CodeSandbox links and misc documentation improvements #6074

Merged
merged 13 commits into from
Jul 27, 2022

Conversation

cee-chen
Copy link
Member

@cee-chen cee-chen commented Jul 22, 2022

Summary

Because our EuiSelectable demos/examples used a shared data.ts object, CodeSandbox links could not be generated for the demos. This was particularly annoying when attempting to whip up a quick boilerplate for debugging/testing purposes.

I removed the shared data.ts file and simply copied and pasted the options object across examples. I also did a pass on the docs while I was here, simplifying any non-relevant logic and other misc cleanup. I recommend following along by commit.

Checklist

@cee-chen cee-chen added documentation Issues or PRs that only affect documentation - will not need changelog entries skip-changelog labels Jul 22, 2022
@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_6074/

- The local import was preventing CodeSandbox demos from being generated, and DRYness is not as much a concern here as much as having useful demos/code that people can quickly modify

- .TSX source change is required for `<>` typing additions
- rename to Sizing since it's not just a popover example

- move example all the way down the page - it's a more complex example and doesn't honestly feel like it makes sense where it is, and it's a

- remove data store, just use more moon names

- clean up unnecessary const declarations, preferring inline JS

- remove need for generated IDs - this is a one time demo

- remove unnecessary array sorting - it's not relevant to what's being demo'd
- remove need for data store dependency, copy countries array

- default to custom content being shown

- inline more code, simplify conditional props to ternaries

- make secondary text display smaller

- Fix `showIcons` type error: it should be passed by the list, not to individual options
- It was confusing having it amongst the EuiSelectable docs when it's its own completely separate page/documentation

- gave it its own subdir with the same name that it lives in in src/components

- renamed its file names to be clearer and less generic

+ fix onWindowKeyDown  useEffect cleanup removing the wrong event

+ optimize window keyup/keydown fns to not re-init on every rerender
- allow consumers to toggle between `always` and `true` to observe functional difference
- Remove props that are not specifically relevant to the documentation section

- Move ending bracket on newline & other misc prettier syntax cleanup
- prefer to display all props, as there are links within EuiSelectable that no longer do anything if all child props aren't displayed
- Fix broken link
- Remove random documentation copy that doesn't look like it belongs
- Fix import statement
@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_6074/

@cee-chen
Copy link
Member Author

jenkins test this

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_6074/

@cee-chen cee-chen requested a review from cchaos July 25, 2022 14:51
Copy link
Contributor

@cchaos cchaos left a comment

Choose a reason for hiding this comment

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

💟 Thank you for taking this on! We really need a general guidance/tool for creating fake data. This process seemed very manual. I also personally hate this Greek(?) data.

I started out with mostly suggestions, but then found a few issues too, so there's a mix of optional and necessary changes in my review.

src-docs/src/views/selectable/selectable.tsx Outdated Show resolved Hide resolved
src-docs/src/views/selectable/selectable_example.js Outdated Show resolved Hide resolved
src-docs/src/views/selectable/selectable_example.js Outdated Show resolved Hide resolved
src-docs/src/views/selectable/selectable_example.js Outdated Show resolved Hide resolved
src-docs/src/views/selectable/selectable_example.js Outdated Show resolved Hide resolved
src-docs/src/views/selectable/selectable_example.js Outdated Show resolved Hide resolved
},
],
props,
snippet: `<EuiSelectable
Copy link
Contributor

Choose a reason for hiding this comment

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

Then we could have targeted snippets for each type too.

@import './selectable/search';
@import './selectable/selectable_templates/sitewide';
Copy link
Contributor

Choose a reason for hiding this comment

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

Optional:

Should we move these styles to Emotion so they render in the code sandbox?

Copy link
Member Author

@cee-chen cee-chen Jul 25, 2022

Choose a reason for hiding this comment

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

I gave this a shot but unfortunately there are a few limitations:

  • The styles being set are using EUI theme variables, meaning I have to call useEuiTheme(), meaning I can't just pass a static css prop into the list of searchData array variables
  • Because the options are being rendered in a popover, I can't pass the css={} prop into <EuiSelectableTemplateSitewide> directly, I have to pass it into listProps={{}}
  • listProps={{ css: css`...` }} works in actual UI, but Typescript complains about the css prop not existing on our types, which is odd. We may need to add css in our CommonProps declaration. Which I'm fine to do, but I was really hoping to keep this PR as src-doc changes only, so I'll check in with Greg about the implications of that and then tackle it in another PR, if that's cool!

Copy link
Contributor

Choose a reason for hiding this comment

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

Yep, that's fine. 👍

@cee-chen
Copy link
Member Author

cee-chen commented Jul 25, 2022

We really need a general guidance/tool for creating fake data. This process seemed very manual.

I agree especially for complex examples like our tables (which I was hoping to look at soon 🤞), but for smaller examples like these I don't mind repeating static arrays of data personally. I think it's easier to follow and for consumers to understand when explicitly laid out strings at times.

I also personally hate this Greek(?) data

Haha FWIW It's the name of different planets' moons that just happened to be named after different Greek/Roman mythical figures! 🌝 So really, the blame here lies with astronomers

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_6074/

@cee-chen cee-chen requested a review from cchaos July 27, 2022 17:56
Copy link
Contributor

@cchaos cchaos left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks @constancecchen!

@cee-chen cee-chen merged commit e95d31b into elastic:main Jul 27, 2022
@cee-chen cee-chen deleted the selectable-demos branch July 27, 2022 18:52
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.

3 participants