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

Ability to create RTL variants of specific/all stories of a kind as substories #2453

Merged
merged 14 commits into from
Oct 23, 2019

Conversation

jroebu14
Copy link
Contributor

@jroebu14 jroebu14 commented Oct 21, 2019

Resolves #1673

Overall change: Changes buildRTLSubstories to create RTL variants of all stories of a specific kind or specific stories of specific kind. Previously buildRTLSubstories would create RTL variants of all stories which was considered not a good approach because this would double the length of time it takes for ChromaticQA to run in the CI pipeline which is something we are actively trying to reduce.

The original plan was to do this with a new decorator that we could decorate individual or many stories with however it's not possible to create new substories this way.

Examples of use:

create RTL variants of all stories of a kind

import { buildRTLSubstories } from '@bbc/psammead-storybook-helpers';

buildRTLSubstories('Components|Paragraph');

create RTL variants of specific stories of a kind

import { buildRTLSubstories } from '@bbc/psammead-storybook-helpers';

buildRTLSubstories('Components|Paragraph', {
  include: ['containing an inline link'],
});

This would produce new substories in Storybook:

Screenshot 2019-10-22 at 11 10 18

This new substory is then automatically added to ChromaticQA as the RTL example of the original story.

Code changes:

  • updates buildRTLSubstories.js API and tests.
  • updates changelog with new examples
  • bumps major version number

  • I have assigned myself to this PR and the corresponding issues
  • Automated jest tests added (for new features) or updated (for existing features)
  • This PR requires manual testing

@jroebu14 jroebu14 marked this pull request as ready for review October 22, 2019 10:03
@jroebu14 jroebu14 self-assigned this Oct 22, 2019
@jroebu14 jroebu14 changed the title build all or some rtl variant substories Ability to create RTL variants of specific/all stories of a kind as substories Oct 22, 2019
const matchesStoryName = name => story => story.name === name;

const buildRTLSubstory = (kind, name, storyFn) => {
const arabicServiceDecorator = withServicesKnob({ defaultService: 'arabic' });
Copy link
Contributor

@thekp thekp Oct 22, 2019

Choose a reason for hiding this comment

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

is it worth adding change this to:

  const rtlServiceDecorator = withServicesKnob({ defaultService: 'arabic', services:['arabic', 'persian', 'urdu', 'pashto'] });

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh nice idea!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

is that all the rtl services?

Copy link
Contributor

Choose a reason for hiding this comment

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

yup, I just confirmed on slack.

Copy link
Contributor

@thekp thekp left a comment

Choose a reason for hiding this comment

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

Great work, you just need to create follow up issues to apply these changes across our repos. 👍

@jroebu14
Copy link
Contributor Author

@thekp I guess for Psammead we are still working on this issue #1673 although it doesn't detail which stories we should have rtl variants for. My guess is we should do them for components where the layout changes such as consent banner.

@thekp
Copy link
Contributor

thekp commented Oct 23, 2019

do them for components where the layout changes such as consent banner.

This sounds right to me 👍

Copy link
Contributor

@j-pendlebury j-pendlebury left a comment

Choose a reason for hiding this comment

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

LGTM

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.

Chromatic QA checks with different storybook knob values
5 participants