Created
July 22, 2019 22:09
-
-
Save backlineint/6b6e2b016b98f956e78b548be4515e5a to your computer and use it in GitHub Desktop.
Twig In React Storybook
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { storiesOf } from '@storybook/react'; | |
import { action } from '@storybook/addon-actions'; | |
import { text } from '@storybook/addon-knobs'; | |
import template from './TestTwig.twig'; | |
import chip from '~../../../twig-assets/e-chip.twig'; | |
const templateTwig = ( | |
chip({ | |
description: 'Description', | |
designer: 'Designer', | |
price: '$400' | |
}) | |
) | |
storiesOf('Core', module).add( | |
'Test Twig', | |
() => ( | |
<div dangerouslySetInnerHTML={{__html: templateTwig}}></div> | |
), | |
{ notes } | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// in .storybook directory | |
// Export a function. Accept the base config as the only param. | |
module.exports = async ({ config, mode }) => { | |
// `mode` has a value of 'DEVELOPMENT' or 'PRODUCTION' | |
// You can change the configuration based on that. | |
// 'PRODUCTION' is used when building the static version of storybook. | |
// Make whatever fine-grained changes you need | |
config.module.rules.push({ | |
test: /\.twig$/, | |
loader: "twig-loader", | |
options: { | |
// See options section below | |
}, | |
}); | |
// Return the altered config | |
return config; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment