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

Convert Component playground(s) to use playground library #817

Merged
merged 26 commits into from
Jan 6, 2024

Conversation

joebochill
Copy link
Collaborator

@joebochill joebochill commented Nov 6, 2023

Changes proposed in this Pull Request:

  • Convert following components' playground to use the library components from https://github.com/etn-ccis/blui-react-documentation-components
    • AppBar
    • ChannelValue
    • Drawer
    • DrawerHeader
    • DrawerSubheader
    • DrawerNavGroup
    • DrawerNavItem
    • DrawerRailItem
    • DrawerFooter
    • EmptyState
    • Hero
    • InfoListItem
    • ListItemTag
    • ScoreCard
    • ThreeLiner
    • ToolbarMenu
    • UserMenu
  • Remove unused files and redux state

Screenshots / Screen Recording (if applicable)

image

To Test:

  • yarn start:docs
  • go to updated playground pages and play around with the props
  • See if anything is broken (other than missing copy button)

Any specific feedback you are looking for?

  • What did we miss in the shared library?

Known Issues (fixes in progress):

  • Support for object-style props is a little weak (e.g., ChannelValueProps in Hero)
  • Large component snippets do not scroll

@github-actions github-actions bot added the brightlayer-ui Used to identify Brightlayer UI platform issues for easy filtering label Nov 6, 2023
@joebochill joebochill added next-release Work for the next release, not the current one brightlayer-ui Used to identify Brightlayer UI platform issues for easy filtering and removed brightlayer-ui Used to identify Brightlayer UI platform issues for easy filtering labels Nov 6, 2023
@joebochill
Copy link
Collaborator Author

This is a low-priority item — don't feel compelled to review this right now unless you've already been through everything else that's part of the current sprint.

Copy link

github-actions bot commented Nov 6, 2023

Visit the preview URL for this PR (updated for commit 38bea0b):

https://blui-react-docs--pr817-feature-docs-convert-svc2b61q.web.app

(expires Fri, 29 Dec 2023 22:33:50 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 34d39fa5aab0ea0cf95074e8e76f68829e7a8c65

Copy link
Contributor

@huayunh huayunh left a comment

Choose a reason for hiding this comment

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

wow

docs/src/shared/ComponentPreviewTabs.tsx Outdated Show resolved Hide resolved
Comment on lines 140 to 144
${
data.icon && data.icon !== 'undefined'
? `icon={${(data.icon as string).replace('/>', '')}fontSize={'inherit'}${
data.htmlColor && data.htmlColor !== 'undefined' ? ` htmlColor={'${data.htmlColor as string}'}` : ''
} />}`
Copy link
Contributor

Choose a reason for hiding this comment

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

undefined is a fairly common thing in our react components, given that we often want to test the component behavior when an optional prop is not given. Is it possible to incorporate this into the package? Like, for all required: false prop data, add an extra field undefinedOption: true or something like that?

Copy link
Collaborator Author

@joebochill joebochill Nov 8, 2023

Choose a reason for hiding this comment

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

I think what you are describing is achievable already. Each parameter that you define to show in the sidebar has the following core values configurable:
image

initialValue is the value to prepopulate in the sidebar input, defaultValue is the default value of the component prop if it's not defined (we use this to automatically remove values from the snippet that are the same as the default)

The 'undefined' string being used here is because this parameter renders as a select/dropdown and there is an explicit option in there for 'undefined' (without the option, there is no way to unselect an item once you've selected one). The select input type requires option values to be number | string — this could probably be extended to support a value of undefined as well if we want to be able to do a comparison like data.icon !== undefined instead. That might complicate the typings a little bit (probably why I didn't do it initially)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Now I think I remember — allowing undefined as a value in the dropdown would throw an error:

Warning: A component is changing an uncontrolled input to be controlled. This is likely caused by the value changing from undefined to a defined value, which should not happen. Decide between using a controlled or uncontrolled input element for the lifetime of the component

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I had considered providing the ability to do a value mapping from string (label in dropdown) to anything (actual value you want to parameter to have, e.g. undefined or <Component />), like options: [{label: 'undefined', value: undefined}], but that seemed to overcomplicate things for minimal gain. But we could revisit that if we want to. It might help when defining the preview component so the user doesn't have to do the mapping/lookup themselves.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it can help with both

  • our testing (passing in the supposed default value vs. actually passing in undefined) and
  • simplify this generateSnippet function that our adopters will write, like what you said there

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I took another look at it, and I think we'll leave it as-is for now. With the mapping capability, the user would still be stuck — e.g., In the case of the ChannelValue example, when picking an icon, the actual icon element they would pass as the value in the mapping would need to also know the value of the htmlColor input to render properly. Since the config object is static, they wouldn't be able to access that variable, so I don't think there's any real gain. That may not have made a lot of sense, but I can show you what I mean if you want to dig deeper.

@joebochill joebochill changed the title Convert ChannelValue playground to use playground library Convert Component playground(s) to use playground library Dec 12, 2023
Copy link
Contributor

@huayunh huayunh left a comment

Choose a reason for hiding this comment

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

The style of this code. It should not start a new line
image

Suspicious amount of spacing on the bottom
image

Dark theme mobile, incorrect bottom drawer color when collapsed (looks fine when expanded)
image

Dark theme accordion has weird background colors:
image

@joebochill
Copy link
Collaborator Author

joebochill commented Dec 13, 2023

Suspicious amount of spacing on the bottom

This was intentional to allow users to edit field 'in their workspace' rather than trying to edit fields at the very bottom of the sidebar. This is a common feature of code/text editors where users are able to 'overscroll' past the last line of text to bring it up to the middle/top of the editor.

Dark theme accordion has weird background colors

These are unstyled accordions (i.e., default style from the theme) — what color do you want them to be, same as the background?

@huayunh
Copy link
Contributor

huayunh commented Dec 14, 2023

what color do you want them to be, same as the background?

the paper color should be fine.

@joebochill joebochill removed the next-release Work for the next release, not the current one label Dec 14, 2023
@joebochill
Copy link
Collaborator Author

Everything has been migrated to the new components now...this is ready for more scrutiny

Copy link
Contributor

@huayunh huayunh left a comment

Choose a reason for hiding this comment

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

This * feels weird (Drawer / Drawer playground)
image

Dark theme, need to make the accordion and the background the same color (I don't care you set which to what, as long as the background color is the same)
image

Drawer header playground, the generated code snippet yields a mix of tabs and spaces.

A few generated code snippet shows the closing > on a new line when no props are present, making my prettier head twitch. This is drawer subheader's playground, with its default configuration:
image

Empty state, selecting <Router> for the icon prop will cause the icon to disappear (it exists as a MUI Icon and a Material Design icon)
image

@joebochill
Copy link
Collaborator Author

joebochill commented Jan 4, 2024

Can we log these as bugs so we can avoid pushing changes into a 130+ file PR and make a few smaller, easier-to-review ones?

This * feels weird (Drawer / Drawer playground)

Dark theme, need to make the accordion and the background the same color (I don't care you set which to what, as long as the background color is the same)

These can be logged as issues in the playground library.

Drawer header playground, the generated code snippet yields a mix of tabs and spaces.

A few generated code snippet shows the closing > on a new line when no props are present, making my prettier head twitch. This is drawer subheader's playground, with its default configuration:

Empty state, selecting <Router> for the icon prop will cause the icon to disappear (it exists as a MUI Icon and a Material Design icon)

These can be logged as issues in the dev-docs

@huayunh huayunh merged commit 82255ff into dev Jan 6, 2024
4 checks passed
@huayunh huayunh deleted the feature/docs-convert-channelvalue branch January 6, 2024 05:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
brightlayer-ui Used to identify Brightlayer UI platform issues for easy filtering
Development

Successfully merging this pull request may close these issues.

2 participants