-
Notifications
You must be signed in to change notification settings - Fork 114
/
Copy pathgetKnobs.js
58 lines (52 loc) · 1.75 KB
/
getKnobs.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import { action } from "@storybook/addon-actions";
import { boolean, select, text } from "@storybook/addon-knobs/react";
import { makeSelectOptions } from "@hig/storybook/utils";
import { targets, types, widths } from "../constants";
const targetOptions = makeSelectOptions(targets);
const typeOptions = makeSelectOptions(types);
const widthOptions = makeSelectOptions(widths);
const knobGroupIds = {
basic: "Basic",
linkOptions: "Link Options"
};
const knobLabels = {
disabled: "Disabled",
link: "Link",
onBlur: "onBlur",
onClick: "onClick",
onFocus: "onFocus",
onHover: "onHover",
onMouseDown: "onMouseDown",
onMouseEnter: "onMouseEnter",
onMouseLeave: "onMouseLeave",
onMouseUp: "onMouseUp",
target: "Target",
title: "Title",
type: "Variant",
width: "Width"
};
export default function getKnobs(props) {
const { disabled, link, target, title, type, width, ...otherProps } = props;
return {
...otherProps,
disabled: boolean(knobLabels.disabled, disabled, knobGroupIds.basic),
link: text(knobLabels.link, link, knobGroupIds.linkOptions),
onBlur: action(knobLabels.onBlur),
onClick: action(knobLabels.onClick),
onFocus: action(knobLabels.onFocus),
onHover: action(knobLabels.onHover),
onMouseDown: action(knobLabels.onMouseDown),
onMouseEnter: action(knobLabels.onMouseEnter),
onMouseLeave: action(knobLabels.onMouseLeave),
onMouseUp: action(knobLabels.onMouseUp),
target: select(
knobLabels.target,
targetOptions,
target,
knobGroupIds.linkOptions
),
title: text(knobLabels.title, title, knobGroupIds.basic),
type: select(knobLabels.type, typeOptions, type, knobGroupIds.basic),
width: select(knobLabels.width, widthOptions, width, knobGroupIds.basic)
};
}