Widgets are common components that are reused across all A10 applications. This widget library is an extension of our a10-gui-framework that facilitates the A10 GUI development process. With the sharable widgets under the same framework, different apps can utilize the same structure and codebase. This promotes the maximization of consistency, modularity, and maintainability of A10 applications.
There are two ways to import the css of a10-gui-widget in your code.
By Less
NOTE ~ means importing the less file from node_modules
By css
NOTE: ~ means importing the less file from node_modules
How to use
Widget contribution
1. Create a widget
First, create a widget package in src, for example:
IMPORTANT When partially importing some widgets from our a10-gui-widgets library, please DO NOT import the styles/index.less of the widget in index.tsx. We have a script (npm build) to collect all less files of all widgets into the root index.less ('~a10-gui-widgets/dist/index.less').
NOTE: Please write your code in alphabetical order.
2. Export widget component and props in src/index.tsx
These widgets are maintained by A10 devs. PRs are welcomed.
Create a component
Wrap the component up with the HOC createWidget from a10-gui-framework
For example, a simple widget:
3. Compile Typescript into JavaScript (ES5)
NOTE: Please write the code in alphabetical order.
4. Write storybook for the widget
Add NewWidget folder in stories, and create index.story.js file in NewWidget folder
NOTE: The code of storybook is created by JavaScript (ES6) instead of TypeScript.
Import the new story book in stories/index.stories.js
Run the storybook npm run storybook and you will see it at http://localhost:6006. __
NOTE: Please write the code in alphabetical order.
5. Git Push and create a PR.
That's it! Please bear in mind to call npm build before submitting your code, and then create a PR for code review at a10-gui-widgets.
src/
+-- NewWidget/
+-- styles/
+-- index.less // the less style file
+-- NewWidget.tsx // your source code
+-- index.tsx // the output definition file
+-- README.md // the README of this widget for using in Storybook
import * as React from 'react'
import { A10Component, createWidget } from 'a10-gui-framework'
class IconButton extends A10Component {
render() {
return <div>test</div>
}
}
export default createWidget(IconButton)
export * from './NewWidget'
stories/
+-- NewWidget/
+-- index.story.js
import * as React from 'react'
import { withReadme } from 'storybook-readme'
import { Code, CodeComponent, CodeCard } from '../utils'
import { A10NewWidget } from '../../src'
const A10NewWidgetReadme = require('../../src/NewWidget/README.md')
const Example = () => {
return (
<CodeComponent>
<CodeCard
title="A10NewWidget example title"
desc="A10NewWidget example description"
code={<Code string={'code string'} />}
>
<A10NewWidget />
</CodeCard>
</CodeComponent>
)
}
export default story => {
story.add('A10NewWidget', withReadme(A10NewWidgetReadme, Example))
}
import createNewWidgetStory from './NewWidget/index.story'
createNewWidgetStory(widgetStory)