Let's explore some more Nx plugins by generating and running a storybook configuration for our shared store header.
- Explore other Nx plugins to create a storybook configuration
App Screenshot
No change in how the app looks!-
Install
@nx/storybook
-
Use the
@nx/angular:storybook-configuration
generator to generate a storybook configuration for thestore-ui-shared
project⚠️ Answer YES to all questions -
Inside
libs/store/ui-shared/src/lib/header/header.component.stories.ts
:- Import the
MatToolbarModule
🐳 Hint
//IMPORT TOOLBAR MODULE import { MatToolbarModule } from '@angular/material/toolbar'; //...... export default { title: 'HeaderComponent', component: HeaderComponent, decorators: [ moduleMetadata({ imports: [MatToolbarModule], // <-- import the module }), //... ], } as Meta<HeaderComponent>;
- Import the
-
Inside
libs/store/ui-shared/project.json
:- Add the Material stylesheet to the
build-storybook
target
🐳 Hint
"build-storybook": { "executor": "@storybook/angular:build-storybook", "outputs": ["{options.outputDir}"], "options": { "outputDir": "dist/storybook/store-ui-shared", "configDir": "libs/store/ui-shared/.storybook", "browserTarget": "store:build", "compodoc": false, "styles": [ "./node_modules/@angular/material/prebuilt-themes/deeppurple-amber.css" ] } }
- Add the Material stylesheet to the
-
Serve storybook!
🐳 Hint
nx storybook store-ui-shared
-
Start typing in different titles and see how they appear in the header
-
Inspect what changed from the last time you committed, then commit your changes
🎓If you get stuck, check out the solution