patternfly / patternfly-org

Home of patternfly.org
https://www.patternfly.org
MIT License
70 stars 137 forks source link

[Redesign] Support example knobs #1796

Closed redallen closed 1 month ago

redallen commented 4 years ago

Per #1785, some examples would like to be able to have knobs to quickly toggle parts of the example code:

image

This is problematic with our current examples. It could be supported through a templating system:

```js knobVariant=link
import { Button } from '@patternfly/react-core';

BasicButton = <Button variant={knobVariant} />


and then in Example.js at runtime:
1. Take `knobVariant=link` and look at Button's `variant` type which is `'primary' | 'secondary' | 'tertiary' | 'danger' | 'link' | 'plain' | 'control'` to render a `<select>` dropdown with those options and `link` selected (probably better than radio in the design...)
2. Transform every occurrence of `{knobVariant}` to `"link"`

@mcarrano @rachael-phillips Should the React code change with the variant they select? This seems intuitive to me.
mcarrano commented 4 years ago

Yes. The code should always reflect what's previewed in the example. That's what I've seen in other systems that use knobs.

redallen commented 4 years ago

Once we have listed which of our 100s of examples we want to add knobs to and some methodology of which knobs to display I think this issue can be picked back up.

mcarrano commented 4 years ago

@redallen @evwilkin When we first started down this path. I did spend some time going through the examples and thinking about what props could be turned into knobs in order to reduce the number of unique examples. You can see that in this spreadsheet on the Components definition tab: https://docs.google.com/spreadsheets/d/164a_7itUer1_HOBhI49XUZ-77genlVWBH1Da0F_glxc/edit?usp=sharing

I agree that we need more discussion about this, and would probably want to start with some proof of concept to figure out how we can approach this. @rachael-phillips any further thoughts?

dlabaj commented 1 month ago

No plan to fix. Currently closing issue.