Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@sheriffmoose/storybook-ngx
Advanced tools
Storybook addon to add extra configurations for Angular applications.
Storybook addon that adds few features to the original Angular Storybook integration.
I am such a huge fan of Storybook, and I have been using it for quite some time now. Since Storybook is purely based on React, I thought of this addon as the best way to appeal to more Angular developers. I really hope this will be a good addon to use alongside Storybook for Angular projects, maybe someday integrate these features into official Storybook libraries. I will be working on new features all the time. Your feedback is much appreciated.
For this addon, I am aiming for it to be:
must-have
features for Storybook
on Angular
.nice-to-have
features as possible.yarn add @sheriffmoose/storybook-ngx -D
// .storybook/main.js
module.exports = {
...
"addons": [
"@sheriffmoose/storybook-ngx",
...
],
...
}
Find the published demo storybook on chromatic here
These particular features I found to be helpful when integrating Storybook into existing projects. Feel free to request any more features that you may find a must or even just nice-to-have 😊.
Credits to JS Devtools
for their amazing coverage istanbul loader
. This addon simply imports @jsdevtools/coverage-istanbul-loader
into webpack configuration to enable the coverage instrumentation.
Read more about the coverage instrumentation in the official Test Runner documentation here.
Simply running test-storybook --coverage
will show you test results coverage in the terminal and also will save the coverage results into coverage/storybook.
@storybook/angular
implementation.APP_INITIALIZER
which runs before the Angular
application starts.parameters.providers
which you can retrieve in the play function like so:const meta: Meta = {
title: 'Services/AppService',
decorators: [
moduleMetadata({
imports: [AppModule, CommonModule],
providers: [AppService],
}),
]
};
export default meta;
export const Primary: StoryObj = {
play: async ({ parameters: { providers } }) => {
const appService: AppService = providers.AppService;
expect(appService).toBeTruthy();
},
};
node-fetch
to load the documentation.json
file during runtime, specifically in the preview iframe before the load of each story.Here is a simple example of the first scenario:
compodoc -e json -d dist/docs
// .storybook/main.js
module.exports = {
staticDirs: [{ from: '<DOCS_DIR_PATH>', to: '/<DOCS_SERVE_DIR>' }],
};
preview.js
file like so:export const parameters = {
...
docs: {
inlineStories: true,
...
lazyLoad: true,
url: '<DOCS_SERVE_DIR>/documentation.json'
}
}
The url property here can be a full url like http://example.com/storybook/docs/documentation.json
or a relative path to the current storybook instance like ../dist/docs/documentation.json
.
You can also provide data
property to be something like require('<DOCS_DIR_PATH>/documentation.json')
, this way you don't need to call setCompodocJson
method, it will be called automatically on your behalf, and the docs will be stored in memory for later usage.
compodoc
to display the source code of the components and/or services that exists in the moduleMetadata
.declarations
section of moduleMetadata
, it will be added directly.declarations
or providers
, along with templates & styles for the components if they exist.parameters: {
sourceCode: {
disable: true
}
}
componentWrapperDecorator
from the official @storybook/angular
to render wrapper elements dynamically around stories.Configuration
@storybook/addon-backgrounds
addon.In preview.js
or preview.ts
:
export const parameters = {
wrappers: {
disable: false,
default: 'None',
values: [
{ name: 'None', value: '' },
{ name: 'Container', value: 'app-container' },
{ name: 'Root', value: 'app-root' },
],
},
};
In a story file like button.stories.ts
:
import { type StoryObj, type Meta } from '@storybook/angular';
import Button from './button.component';
const meta: Meta<Button> = {
title: 'Example/Button',
component: Button,
parameters: {
wrappers: {
default: 'None',
values: [
{ name: 'None', value: '' },
{
name: 'Button Container',
value: 'btn-container',
options: {
class: 'small',
style: 'padding:5px;',
},
},
{ name: 'Container', value: 'app-container' },
{ name: 'Root', value: 'app-root' },
],
},
},
};
export default meta;
The wrapper item can also contain an options
property which will be translated into HTML attributes for the wrapper. For example; the configuration above will render the following if Button Container
is selected:
<btn-container class="small" style="padding:5px;"></btn-container>
These features currently residing within this addon might be moved to another addon in the future for separation of concerns purposes.
Actions
panel from @storybook/addon-actions
to display the console output.preview.js
like so:export const parameters = {
console: {
disable: false,
patterns: [/^dev$/],
omitFirst: true,
},
};
Currently, the patterns property is used to match the first argument of the console
methods debug
, log
, info
, warn
& error
. This allows developers to use special context for their app logs. For example: console.log('dev', data);
will be matched using the /^dev$/
pattern, and will trigger an action that shows up in the Actions
panel. You can use the omitFirst
property to make sure the dev
item does not show, only other arguments will show up.
This feature, I personally wanted to make available for all frameworks not just Angular
. Therefore, I created another Markdown Docs
addon which is now available for integration with zero-config. Huge thanks to the Storybook
team and specially @shilman
for the support and amazing feedback.
This is enabled and ignores .component.html
files by default, you can pass an option to disable it like so:
// .storybook/main.js
module.exports = {
addons: [
{
name: '@sheriffmoose/storybook-ngx',
options: {
disableMarkdown: true
}
}
]
}
OpenAPI (formly Swagger) is a popular specification for the management of RESTful APIs. Usually OpenAPI produces a openapi.yml
or openapi.json
file that can be used to integrate/visualize the APIs configured on the backend server.
Swagger UI
is a popular framework for the visualization of the openapi.yml|json
files that allow comprehensive documentation + testing for the backend API services.
Thanks to the pre available swagger-ui-react
, this feature simply integrates SwaggerUI
component into one .mdx
file and make it available on demand if the user decides to populate the openapiURL
option when configuring the addon like so:
// .storybook/main.js
module.exports = {
addons: [
{
name: '@sheriffmoose/storybook-ngx',
options: {
openapiURL: 'https://petstore3.swagger.io/api/v3/openapi.json'
}
}
]
}
JS Devtools
for their amazing coverage istanbul loader
, we are also working on integration this instrumentation into @storybook/addon-coverage
.@storybook/addon-backgrounds
for the inspiration for the wrappers selector
feature.@storybook/angular
framework.Storybook Addon Kit
specially @winkerVSbecks
for the amazing work they put into this kit that was very helpful for generating this addon.Please feel free to request features, I will try to add them as soon as humanly possible. Currently the following features are in my pipeline:
v1.0.42 (Mon Jan 23 2023)
master
FAQs
Storybook addon to add extra configurations for Angular applications.
The npm package @sheriffmoose/storybook-ngx receives a total of 2 weekly downloads. As such, @sheriffmoose/storybook-ngx popularity was classified as not popular.
We found that @sheriffmoose/storybook-ngx demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.