README
Angular wonka-ui - UI component library using Bulma CSS framework styles
wonka-ui is a front-end/user interface framework written in Angular and Typescript, aimed towards making front-end components and code re-usable within SINTEF Connect.
Versions
Angular | wonka-ui |
---|---|
>=8.0.0 <9.0.0 | v1.x |
Table of contents
- Chart
- Form
- Info
- Key-value-unit list
- List
- Navigation bar
- Table
- Cards
- Getting started
- Demo application
- License
- Local consumption in other projects
Chart
Line chart
Chart.js wrapper for showing 2D line charts.
Include component in html template:
<lib-chart
[lineChartItem]="lineChart"
[id]="'line-1'"
[class]="'style-class'"
[header]="'Line chart example'">
</lib-chart>
Define chart parameter with dataset(s) in ts file:
const lineChartDataSets = [{
data: [101, 104, 120, 145, 172, 191, 192],
label: 'Series A', lineTension: 0
}, {
data: [91, 101, 99, 95, 85, 74, 73],
label: 'Series B', lineTension: 0
}, {
data: [22, 24, 27, 32, 40, 55, 73],
label: 'Series C', lineTension: 0
}, {
data: [13, 15, 18, 22, 27, 32, 37],
label: 'Series D', lineTension: 0
}, {
data: [137, 92, 57, 29, 18, 15, 13],
label: 'Series E', lineTension: 0
}, {
data: [150, 140, 130, 120, 110, 100, 90],
label: 'Series F', lineTension: 0
}];
const lineChartLabels =
['January', 'February', 'March', 'April', 'May', 'June', 'July'];
this.lineChart = {
chartDataSets: lineChartDataSets,
chartLabels: lineChartLabels
};
`;
Pie chart
Chart.js wrapper for showing 2D pie charts.
Include component in html template:
<lib-chart
[pieChartItem]="pieChart"
[id]="'pie-1'"
[class]="'style-class'">
</lib-chart>
Define chart parameter with dataset(s) in ts file:
const pieChartDataSets = [105, 100, 95, 90, 85, 80, 75, 70, 65];
const pieChartLabels = [
'Part 1', 'Part 2', 'Part 3', 'Part 4',
'Part 5', 'Part 6', 'Part 7', 'Part 8',
'Part 9'];
this.pieChart = {
chartData: pieChartDataSets,
chartLabels: pieChartLabels
};
`;
Scatter chart
Chart.js wrapper for showing 2D scatter charts.
Include component in html template:
<lib-chart
[scatterChartItem]="scatterChart"
[id]="'scatter-1'"
[class]="'style-class'">
</lib-chart>
Define chart parameter with dataset(s) in ts file:
const scatterChartData = [
{
data: [
{ x: 1, y: 1 },
{ x: 2, y: 3 },
{ x: 3, y: -2 },
{ x: 4, y: 4 },
{ x: 4, y: 4.3 },
{ x: 4, y: 4.6 },
{ x: 4.2, y: 4.1 },
{ x: 4.4, y: 3.8 },
{ x: 5, y: 3.7 },
{ x: 6, y: 1.5 },
{ x: 7, y: 3 },
{ x: 8, y: -2 },
{ x: 9, y: 4 },
{ x: 10, y: -3 },
],
label: 'Series A',
pointRadius: 5,
},
];
this.scatterChart = {
chartData: scatterChartData
};
`;
Form
Simple generic reactive form example
Include component in html template:
<lib-form
[form]="form1"
[class]="'style-class'"
(formSubmitted)="onSubmit($event)"
(formAborted)="onAbortForm()">
</lib-form>
Define form item and onSubmit function in ts file:
form = {
name: 'Example form with minimum input ',
fields: [
{
label: 'Main category',
name: 'simpleCategory',
type: 'select',
options: ['Category 1'],
}, {
label: 'Name',
name: 'simpleName',
}
] as FormFieldItem[]
} as FormItem;
onSubmit(formGroup: FormGroup) {
const values = [];
Object.keys(formGroup.controls).forEach(key => {
values.push(key + ': ' + formGroup.controls[key].value);
});
alert('Form submitted: ' + JSON.stringify(values, null, 2));
}
Advanced generic form example
Include component in html template:
<lib-form
[form]="form"
[class]="'style-class'"
[showConfirmation]="showConfirmation"
[showAbortButton]="showAbortButton"
(formSubmitted)="onSubmit($event)"
(formAborted)="onAbortForm()">
</lib-form>
Define form item and onSubmit/onButtonClicked functions in ts file:
form = {
showConfirmation = true;
showAbortButton = true;
name: 'Example form with all properties and fields set',
description: 'This is the description of the form.',
confirmation: 'This is the confirmation on form submit.',
submitText: 'Submit form',
resetText: 'Reset form',
buttons: [
{
id: '1',
label: 'Button 1',
class: 'is-primary'
}, {
id: '2',
label: 'Button 2',
class: 'is-warning'
}, {
id: '3',
label: 'Button 3'
}
] as FormButton[],
fields: [
{
label: 'Main category',
name: 'categoryAddNew',
required: true,
type: 'select',
options: ['Category 1', 'Category 2', 'Category 3'],
canCreate: true,
wide: true,
info: 'Required field, list of objects, can create new'
}, {
label: 'Category',
name: 'category',
required: true,
type: 'select',
options: ['Category 4', 'Category 5', 'Category 6'],
canCreate: false,
info: 'Required field, list of objects, can not create new'
}, {
label: 'Name',
name: 'name',
required: true,
type: 'string',
wide: true,
info: 'Required field, text, wide, no restrictions'
}, {
label: 'Amount',
name: 'amountSelectUnits',
required: true,
type: 'select',
options: ['400', '600', '800'],
wide: true,
info: 'Selectable units',
units: ['Kilograms', 'Meters']
}, {
label: 'Depth',
description: 'This is the description of the field.',
name: 'depth',
required: false,
type: 'number',
units: 'mm/sec',
min: 0,
expression: '^[\+\-]?([0-9]+([.][0-9]*)?|[.][0-9]+)