Add example storybook
This commit is contained in:
		
							parent
							
								
									d4f6d95f32
								
							
						
					
					
						commit
						0b02f64693
					
				
					 2 changed files with 41 additions and 7 deletions
				
			
		|  | @ -1,9 +1,28 @@ | |||
| module.exports = { | ||||
|   stories: ['../stories/**/*.stories.js'], | ||||
|   addons: ['@storybook/addon-actions', '@storybook/addon-links'], | ||||
|   webpackFinal: async config => { | ||||
|     // do mutation to the config
 | ||||
| // License: LGPL-3.0-or-later
 | ||||
| // Based on https://github.com/rails/webpacker/issues/1004#issuecomment-628377930
 | ||||
| process.env.NODE_ENV = "development"; | ||||
| const railsWebpackEnv = require("../config/webpack/environment"); | ||||
| 
 | ||||
|     return config; | ||||
| module.exports = { | ||||
|   stories: ["../app/javascript/stories/*.[tj]s?(x)"], | ||||
|   addons: ['@storybook/addon-actions', '@storybook/addon-links'], | ||||
|   webpackFinal: (config) => ({ | ||||
|     // do mutation to the config
 | ||||
|     ...config, | ||||
|     resolve: { | ||||
|       ...config.resolve, | ||||
|       ...railsWebpackEnv.config.resolve, | ||||
|       modules: railsWebpackEnv.resolvedModules.map((i) => i.value), | ||||
|     }, | ||||
|     module: { | ||||
|       ...config.module, | ||||
|       rules: railsWebpackEnv.loaders | ||||
|         .filter((i) => i.key !== "nodeModules") | ||||
|         .map((i) => i.value), | ||||
|     }, | ||||
|     plugins: [ | ||||
|       ...config.plugins, | ||||
|       ...railsWebpackEnv.plugins.map((i) => i.value), | ||||
|     ], | ||||
|   }), | ||||
| }; | ||||
|  |  | |||
							
								
								
									
										15
									
								
								app/javascript/stories/index.jsx
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								app/javascript/stories/index.jsx
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,15 @@ | |||
| // License: LGPL-3.0-or-later | ||||
| import React from 'react'; | ||||
| import { Button } from '@storybook/react/demo'; | ||||
| 
 | ||||
| export default { title: 'Button' }; | ||||
| 
 | ||||
| export const withText = () => <Button>Hello Button</Button>; | ||||
| 
 | ||||
| export const withEmoji = () => ( | ||||
|   <Button> | ||||
|     <span role="img" aria-label="so cool"> | ||||
|       😀 😎 👍 💯 | ||||
|     </span> | ||||
|   </Button> | ||||
| ); | ||||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 Eric
						Eric