Skip to content

Commit 8ed6f83

Browse files
committed
feat(form): add ux form and form-row utility
add ux-form component add form row layout class
1 parent 88b3d54 commit 8ed6f83

File tree

5 files changed

+85
-11
lines changed

5 files changed

+85
-11
lines changed

src/form/ux-form-theme.css

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
styles.form {
2+
display: flex;
3+
flex-direction: column;
4+
width: 100%;
5+
}
6+
7+
styles.form .form-row {
8+
display: flex;
9+
flex-direction: row;
10+
}
11+
12+
styles.form .form-row>* {
13+
margin: 0 8px;
14+
}
15+
16+
styles.form .form-row>*:last-child {
17+
margin-right: 0;
18+
}
19+
20+
styles.form .form-row>*:first-child {
21+
margin-left: 0;
22+
}

src/form/ux-form-theme.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { styles } from '../styles/decorators';
2+
3+
@styles()
4+
export class UxFormTheme {
5+
public background: string = 'transparent';
6+
public foreground: string;
7+
8+
public formPadding: 8;
9+
}

src/form/ux-form.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<template role="form" styles.form>
2+
<require from="./ux-form-theme"></require>
3+
4+
<slot></slot>
5+
</template>

src/form/ux-form.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { customElement, bindable, ViewResources, View, processAttributes } from 'aurelia-templating';
2+
import { inject } from 'aurelia-dependency-injection';
3+
import { StyleEngine } from '../styles/style-engine';
4+
import { Themable } from '../styles/themable';
5+
import { processDesignAttributes } from '../designs/design-attributes';
6+
7+
@inject(ViewResources, StyleEngine)
8+
@customElement('ux-form')
9+
@processAttributes(processDesignAttributes)
10+
11+
export class UxForm implements Themable {
12+
@bindable public theme = null;
13+
14+
public view: View;
15+
16+
constructor(public resources: ViewResources, private styleEngine: StyleEngine) { }
17+
18+
public created(_: any, myView: View) {
19+
this.view = myView;
20+
}
21+
22+
public bind() {
23+
if (this.theme) {
24+
this.styleEngine.applyTheme(this, this.theme);
25+
}
26+
}
27+
28+
// public attached() { }
29+
30+
// public detached() { }
31+
32+
33+
public themeChanged(newValue: any) {
34+
this.styleEngine.applyTheme(this, newValue);
35+
}
36+
}

src/index.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
1-
import {FrameworkConfiguration} from 'aurelia-framework';
2-
import {AureliaUX} from './aurelia-ux';
1+
import { FrameworkConfiguration } from 'aurelia-framework';
2+
import { AureliaUX } from './aurelia-ux';
33

4-
export {swatches} from './colors/swatches';
5-
export {shadows} from './colors/shadows';
6-
export {UxButtonTheme} from './button/ux-button-theme';
7-
export {UxInputTheme} from './input/ux-input-theme';
8-
export {UxInputInfoTheme} from './input-info/ux-input-info-theme';
9-
export {UxTextareaTheme} from './textarea/ux-textarea-theme';
4+
export { swatches } from './colors/swatches';
5+
export { shadows } from './colors/shadows';
6+
export { UxButtonTheme } from './button/ux-button-theme';
7+
export { UxInputTheme } from './input/ux-input-theme';
8+
export { UxInputInfoTheme } from './input-info/ux-input-info-theme';
9+
export { UxTextareaTheme } from './textarea/ux-textarea-theme';
10+
export { UxFormTheme } from './form/ux-form-theme';
1011
export * from './styles/decorators';
11-
export {AureliaUX} from './aurelia-ux';
12-
export {UXConfiguration} from './ux-configuration';
12+
export { AureliaUX } from './aurelia-ux';
13+
export { UXConfiguration } from './ux-configuration';
1314

1415
export function configure(config: FrameworkConfiguration, callback?: (config: AureliaUX) => Promise<any>) {
1516
config.globalResources([
1617
'./button/ux-button',
1718
'./input/ux-input',
1819
'./input-info/ux-input-info',
19-
'./textarea/ux-textarea'
20+
'./textarea/ux-textarea',
21+
'./form/ux-form'
2022
]);
2123

2224
const ux = config.container.get(AureliaUX) as AureliaUX;

0 commit comments

Comments
 (0)