Skip to content
This repository was archived by the owner on Mar 4, 2020. It is now read-only.

feat(Knobs): improve useRangeKnob() and add LogInspector/useLogKnob()#1876

Merged
layershifter merged 9 commits intomasterfrom
feat/knobs
Sep 6, 2019
Merged

feat(Knobs): improve useRangeKnob() and add LogInspector/useLogKnob()#1876
layershifter merged 9 commits intomasterfrom
feat/knobs

Conversation

@layershifter
Copy link
Member

@layershifter layershifter commented Sep 2, 2019

useLogKnob() and LogInspector

This PR adds and knob and component, this drastically simplifies examples and allows to log callbacks. There are two examples of useLogKnob(): PortalExampleOpen.tsx and DialogExampleCallbacks.shorthand.tsx.

Second is more advanced as contains custom output formatter:

callback-example

useRangeKnob()

Was improved to support min, max and step props. Logic with parsing values was moved out from KnobRange so it will be easier to integrate custom components.

@DustyTheBot
Copy link
Collaborator

DustyTheBot commented Sep 2, 2019

Warnings
⚠️ There are no updates provided to CHANGELOG. Ensure there are no publicly visible changes introduced by this PR.
⚠️ Package (or peer) dependencies changed. Make sure you have approval before merging!

Changed dependencies are detected.

Changed peerDependencies in packages/docs-components/package.json

package before after
prettier - ^1.18.2

Generated by 🚫 dangerJS

@codecov
Copy link

codecov bot commented Sep 2, 2019

Codecov Report

Merging #1876 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@          Coverage Diff           @@
##           master   #1876   +/-   ##
======================================
  Coverage    69.9%   69.9%           
======================================
  Files         888     888           
  Lines        7775    7775           
  Branches     2244    2244           
======================================
  Hits         5435    5435           
  Misses       2330    2330           
  Partials       10      10

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c826c3a...6009fe8. Read the comment docs.

"main": "dist/commonjs/index.js",
"module": "dist/es/index.js",
"peerDependencies": {
"prettier": "^1.18.2",
Copy link
Member Author

Choose a reason for hiding this comment

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

We are using it under packages/docs-components/src/CodeSnippet/formatCode.ts.

@layershifter layershifter changed the title feat(Knobs): improve useRangeKnob() and add LogInspector/useCallbackLog() feat(Knobs): improve useRangeKnob() and add LogInspector/useLogKnob() Sep 5, 2019
const useLogKnob = <T = (...args: any[]) => any>(
name: string,
callback?: T,
formatter: Function = defaultFormatter,
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we specify the formatter type, instead of using a general Function? For instance, it would be nice to specify that the function should return string.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done 👍

@layershifter layershifter merged commit 0347c18 into master Sep 6, 2019
@delete-merged-branch delete-merged-branch bot deleted the feat/knobs branch September 6, 2019 11:45
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants