Skip to content
This repository has been archived by the owner on May 2, 2023. It is now read-only.

Commit

Permalink
refactor(demo): Breadcrumb harmonised, optional/mandatory knobs - FRO…
Browse files Browse the repository at this point in the history
…NT-1017 (#405)
  • Loading branch information
planctus authored Apr 8, 2020
1 parent 9bc3ecc commit 9b4074d
Showing 1 changed file with 35 additions and 25 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import merge from 'deepmerge';
/* eslint-disable no-param-reassign */
import { storiesOf } from '@storybook/html';
import { withNotes } from '@ecl-twig/storybook-addon-notes';
import withCode from '@ecl-twig/storybook-addon-code';
import { withKnobs, text, select } from '@storybook/addon-knobs';
import { getExtraKnobs, tabLabels, getLinkKnobs } from '@ecl-twig/story-utils';

import defaultSprite from '@ecl/ec-resources-icons/dist/sprites/icons.svg';
import dataSimple from './demo/data--simple';
Expand All @@ -10,30 +12,38 @@ import dataLong from './demo/data';
import breadcrumb from './ecl-breadcrumb-harmonised.html.twig';
import notes from './README.md';

const prepareBreadcrumbHarmonised = data => {
data.icon_file_path = select(
'icon_file_path',
[defaultSprite],
defaultSprite,
tabLabels.required
);
data.navigation_text = text(
'navigation_text',
data.navigation_text,
tabLabels.required
);
data.ellipsis_label = text(
'ellipsis_label',
data.ellipsis_label,
tabLabels.required
);

getLinkKnobs(data);

getExtraKnobs(data);

return data;
};

storiesOf('Components/Navigation/Breadcrumbs/Breadcrumb Harmonised', module)
.addDecorator(withNotes)
.addDecorator(withCode)
.add(
'simple',
() =>
breadcrumb(
merge(dataSimple, {
icon_file_path: defaultSprite,
})
),
{
notes: { markdown: notes, json: dataSimple },
}
)
.add(
'long',
() =>
breadcrumb(
merge(dataLong, {
icon_file_path: defaultSprite,
})
),
{
notes: { markdown: notes, json: dataLong },
}
);
.addDecorator(withKnobs)
.add('simple', () => breadcrumb(prepareBreadcrumbHarmonised(dataSimple)), {
notes: { markdown: notes, json: dataSimple },
})
.add('long', () => breadcrumb(prepareBreadcrumbHarmonised(dataLong)), {
notes: { markdown: notes, json: dataLong },
});

0 comments on commit 9b4074d

Please sign in to comment.