Skip to content
Snippets Groups Projects
Commit fddab4f8 authored by jojohoch's avatar jojohoch
Browse files

Add styling interface to math field element

parent 36fb583a
No related branches found
No related tags found
No related merge requests found
...@@ -9,16 +9,25 @@ import { MathFieldElement } from 'common/models/elements/input-elements/math-fie ...@@ -9,16 +9,25 @@ import { MathFieldElement } from 'common/models/elements/input-elements/math-fie
@Component({ @Component({
selector: 'aspect-math-field', selector: 'aspect-math-field',
template: ` template: `
<label>{{elementModel.label}}</label><br> <div [style.line-height.%]="elementModel.styling.lineHeight"
<aspect-mathlive-math-field [value]="$any(elementModel.value) | getValue: elementFormControl.value : parentForm" [style.color]="elementModel.styling.fontColor"
[enableModeSwitch]="elementModel.enableModeSwitch" [style.font-family]="elementModel.styling.font"
(input)="elementFormControl.setValue($any($event.target).value)" [style.font-size.px]="elementModel.styling.fontSize"
(focusout)="elementFormControl.markAsTouched()"> [style.font-weight]="elementModel.styling.bold ? 'bold' : ''"
</aspect-mathlive-math-field> [style.font-style]="elementModel.styling.italic ? 'italic' : ''"
<mat-error *ngIf="elementFormControl.errors && elementFormControl.touched" [style.text-decoration]="elementModel.styling.underline ? 'underline' : ''"
class="error-message"> [style.backgroundColor]="elementModel.styling.backgroundColor">
{{elementFormControl.errors | errorTransform: elementModel}} <label>{{elementModel.label}}</label><br>
</mat-error> <aspect-mathlive-math-field [value]="$any(elementModel.value) | getValue: elementFormControl.value : parentForm"
[enableModeSwitch]="elementModel.enableModeSwitch"
(input)="elementFormControl.setValue($any($event.target).value)"
(focusout)="elementFormControl.markAsTouched()">
</aspect-mathlive-math-field>
<mat-error *ngIf="elementFormControl.errors && elementFormControl.touched"
class="error-message">
{{elementFormControl.errors | errorTransform: elementModel}}
</mat-error>
</div>
`, `,
styles: ['.error-message {font-size: 75%; margin-top: 15px; margin-left: 10px;}'] styles: ['.error-message {font-size: 75%; margin-top: 15px; margin-left: 10px;}']
}) })
......
import { import {
AnswerScheme, InputElement, PositionProperties, UIElement AnswerScheme, BasicStyles, InputElement, PositionProperties, UIElement
} from 'common/models/elements/element'; } from 'common/models/elements/element';
import { Type } from '@angular/core'; import { Type } from '@angular/core';
import { ElementComponent } from 'common/directives/element-component.directive'; import { ElementComponent } from 'common/directives/element-component.directive';
...@@ -8,11 +8,21 @@ import { MathFieldComponent } from 'common/components/input-elements/math-field. ...@@ -8,11 +8,21 @@ import { MathFieldComponent } from 'common/components/input-elements/math-field.
export class MathFieldElement extends InputElement { export class MathFieldElement extends InputElement {
enableModeSwitch: boolean = false; enableModeSwitch: boolean = false;
position: PositionProperties | undefined; position: PositionProperties | undefined;
styling: BasicStyles & {
lineHeight: number;
};
constructor(element: Partial<MathFieldElement>) { constructor(element: Partial<MathFieldElement>) {
super(element); super(element);
if (element.enableModeSwitch !== undefined) this.enableModeSwitch = element.enableModeSwitch; if (element.enableModeSwitch !== undefined) this.enableModeSwitch = element.enableModeSwitch;
this.position = element.position ? UIElement.initPositionProps(element.position) : undefined; this.position = element.position ? UIElement.initPositionProps(element.position) : undefined;
this.styling = {
...UIElement.initStylingProps({
backgroundColor: 'transparent',
lineHeight: 135,
...element.styling
})
};
} }
hasAnswerScheme(): boolean { hasAnswerScheme(): boolean {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment