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

Knobs #128

Merged
merged 91 commits into from Apr 20, 2022
Merged

Knobs #128

merged 91 commits into from Apr 20, 2022

Conversation

joshpetit
Copy link
Contributor

@joshpetit joshpetit commented Feb 23, 2022

List of issues which are fixed by the PR

#21

Checklist

  • I signed the [CLA].
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making].
  • All existing and new tests are passing.

@joshpetit joshpetit marked this pull request as draft February 23, 2022 13:24
@joshpetit
Copy link
Contributor Author

One bug I found is that if you change the label of the knob while running and it hot reloads, the previous knob won't clear. But when you hot reload again it'll disappear.

Copy link
Member

@jenshor jenshor left a comment

Choose a reason for hiding this comment

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

Love the implementation. Once completed this will be great 💪🏻 Keep going, Josh 👍🏻

@joshpetit joshpetit marked this pull request as ready for review April 12, 2022 14:20
@joshpetit joshpetit requested a review from jenshor April 12, 2022 14:21
Copy link
Member

@jenshor jenshor left a comment

Choose a reason for hiding this comment

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

Some minor problems i've found:

  • Example does not use description. I think it would be great to showcase this functionality 👍🏻
  • Some UI Elements within the Knobs Panel do not use the color scheme of Widgetbook. It would be great if you could check what's going wrong.

Regarding the design:

  • It's currently hard to determine which knobs are defined since the UI does not clearly separate specific knobs from each other:

image

Code to reproduce the image:

            WidgetbookComponent(
              name: 'MealDetail',
              useCases: [
                WidgetbookUseCase(
                  name: 'Short name',
                  builder: (context) {
                    final randomValue = context.knobs.nullableBoolean(
                      label: 'Nullable - nulls stuff',
                      description: 'A description for a description',
                    );
                    final randomString = context.knobs.nullableText(
                      label: 'Nullable - nulls string stuff',
                      description: 'An amazing description',
                    );
                    return MealDetail(
                      meal: Meal(
                        title: context.knobs.text(
                          label: 'title',
                          description:
                              'Use this to set an amazing title to the $MealDetail widget',
                          initialValue: 'Bacon Burger',
                        ),
                        imagePath: 'assets/burger.jpg',
                        ingredients: [
                          if (context.knobs.boolean(
                            label: 'Tomato',
                            description:
                                'Shows if this can be a tomato (or not)',
                            initialValue: true,
                          ))
                            'tomato',
                          context.knobs
                              .slider(
                                  label: 'Slider value',
                                  description:
                                      'This is a vereeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeery long description',
                                  initialValue: 50,
                                  min: 0,
                                  max: 100,
                                  divisions: 100)
                              .toInt()
                              .toString(),
                          if (randomValue == null)
                            'its null!'
                          else
                            randomValue.toString(),
                          randomString ?? 'string value was null',
                          'onion',
                          '${context.knobs.nullableNumber(
                            label: 'How many apples?',
                          )} apples',
                        ],
                        price: 8.5,
                        weight: 320,
                      ),
                    );
                  },
                ),

I propose this design - left side shows the KnobsPanel, right side shows the PropertyPanel.
The x-ed out area indicates knob specific UI elements.

image

packages/widgetbook/example/main.dart Show resolved Hide resolved
packages/widgetbook/lib/src/knobs/bool_knob.dart Outdated Show resolved Hide resolved
packages/widgetbook/lib/src/knobs/knobs_panel.dart Outdated Show resolved Hide resolved
packages/widgetbook/lib/src/knobs/slider_knob.dart Outdated Show resolved Hide resolved
@joshpetit
Copy link
Contributor Author

@jenshor I love the new design!

@joshpetit joshpetit requested a review from jenshor April 14, 2022 13:04
@jenshor jenshor merged commit fb8d0ec into widgetbook:main Apr 20, 2022
@joshpetit
Copy link
Contributor Author

dope stuff lol

@jenshor jenshor changed the title DRAFT: Knobs Knobs Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants