mirror of
https://github.com/storybookjs/storybook.git
synced 2025-03-31 05:03:21 +08:00
Add regExpStringify
This commit is contained in:
parent
b2ee1c154c
commit
2e590bfa9f
@ -7,14 +7,26 @@ export function init() {
|
|||||||
// NOTE nothing to do here
|
// NOTE nothing to do here
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function regExpStringify(exp) {
|
||||||
|
if (!exp) return null;
|
||||||
|
if (Object.prototype.toString.call(exp) === '[object String]') return exp;
|
||||||
|
if (Object.prototype.toString.call(exp) !== '[object RegExp]') return null;
|
||||||
|
return exp.source;
|
||||||
|
}
|
||||||
|
|
||||||
// setOptions function will send Storybook UI options when the channel is
|
// setOptions function will send Storybook UI options when the channel is
|
||||||
// ready. If called before, options will be cached until it can be sent.
|
// ready. If called before, options will be cached until it can be sent.
|
||||||
export function setOptions(options) {
|
export function setOptions(newOptions) {
|
||||||
const channel = addons.getChannel();
|
const channel = addons.getChannel();
|
||||||
if (!channel) {
|
if (!channel) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
'Failed to find addon channel. This may be due to https://github.com/storybooks/storybook/issues/1192.'
|
'Failed to find addon channel. This may be due to https://github.com/storybooks/storybook/issues/1192.'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
const options = {
|
||||||
|
...newOptions,
|
||||||
|
hierarchySeparator: regExpStringify(newOptions.hierarchySeparator),
|
||||||
|
};
|
||||||
|
|
||||||
channel.emit(EVENT_ID, { options });
|
channel.emit(EVENT_ID, { options });
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ setOptions({
|
|||||||
showSearchBox: false,
|
showSearchBox: false,
|
||||||
downPanelInRight: true,
|
downPanelInRight: true,
|
||||||
sortStoriesByKind: false,
|
sortStoriesByKind: false,
|
||||||
hierarchySeparator: '\\/|\\.|¯\\\\_\\(ツ\\)_\\/¯'
|
hierarchySeparator: /\/|\./,
|
||||||
});
|
});
|
||||||
|
|
||||||
setAddon(infoAddon);
|
setAddon(infoAddon);
|
||||||
|
@ -266,7 +266,7 @@ storiesOf('component.Button', module)
|
|||||||
|
|
||||||
// Atomic
|
// Atomic
|
||||||
|
|
||||||
storiesOf('Cells¯\\_(ツ)_/¯Molecules.Atoms/simple', module)
|
storiesOf('Cells/Molecules.Atoms/simple', module)
|
||||||
.addDecorator(withKnobs)
|
.addDecorator(withKnobs)
|
||||||
.add('with text', () =>
|
.add('with text', () =>
|
||||||
<Button>
|
<Button>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user