New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@crazyfactory/storybook-props-mock-addon

Package Overview
Dependencies
Maintainers
10
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@crazyfactory/storybook-props-mock-addon

It will generate translation based on `translation` prop's keys.

  • 1.2.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
10
Weekly downloads
 
Created
Source

Only translation can be mocked for now

It will generate translation based on translation prop's keys.

Usage

webpack.config.js

  loader: path.resolve('./node_modules/@crazyfactory/storybook-props-mock-addon/lib/reactTypescriptTranslationLoader.js')

config.js

  import {withMockedTranslation} from "@crazyfactory/storybook-props-mock-addon/lib/withMockedTranslation";
  addDecorator(withMockedTranslation());

story files

  export const Simple = ({mockedTranslation}) => (
    // pass mockedTranslation to translation prop
  );

Example

CustomerInfo.tsx

  import * as React from "react";
  interface IProps {
    firstName: string;
    lastName: string;
    translation: {
      firstName: string;
      lastName: string;
    }
  }
  export class CustomerInfo extends React.Component<IProps> {
    public render(): JSX.Element {
      const {firstName, lastName, translation} = this.props;
      return (
        <div>
          <div>
            {translation.firstName}: {firstName}
          </div>
          <div>
            {translation.lastName}: {lastName}
          </div>
        </div>
      );
    }
  }

CustomerInfo.stories.tsx

  import * as React from "react";
  import {CustomerInfo} from "./CustomerInfo";
  
  export default {
    component: CustomerInfo,
    title: "CustomerInfo"
  }
  
  export const Simple = ({mockedTranslation}) => (
    <CustomerInfo firstName={"John"} lastName={"Lee"} translation={mockedTranslation}/>
  );

Then run storybook, the addon will generate translation for you by pascalizing translation keys image

FAQs

Package last updated on 14 Nov 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc