Skip to content
Snippets Groups Projects
Commit 27b284c7 authored by rhenck's avatar rhenck
Browse files

Add fixedSize styling to most elements

Elements are supposed to be centred when this setting is used. Since it 
is the same CSS for almost all element components it is put into global 
styles.

Missing components: video, spelling.
parent 480e0779
No related branches found
No related tags found
No related merge requests found
Showing
with 134 additions and 95 deletions
...@@ -5,8 +5,10 @@ import { MediaPlayerElementComponent } from '../../directives/media-player-eleme ...@@ -5,8 +5,10 @@ import { MediaPlayerElementComponent } from '../../directives/media-player-eleme
@Component({ @Component({
selector: 'app-audio', selector: 'app-audio',
template: ` template: `
<div [style.width.%]="100" <div [style.width]="elementModel.positionProps.fixedSize ? elementModel.width + 'px' : '100%'"
[style.height.%]="100"> [style.height]="elementModel.positionProps.fixedSize ? elementModel.height + 'px' : '100%'"
[class.center-content]="elementModel.positionProps.dynamicPositioning &&
elementModel.positionProps.fixedSize">
<audio #player <audio #player
(playing)="onMediaPlayStatusChanged.emit(this.elementModel.id)" (playing)="onMediaPlayStatusChanged.emit(this.elementModel.id)"
(pause)="onMediaPlayStatusChanged.emit(null)" (pause)="onMediaPlayStatusChanged.emit(null)"
......
...@@ -39,7 +39,6 @@ import { ButtonElement } from './button-element'; ...@@ -39,7 +39,6 @@ import { ButtonElement } from './button-element';
styles: [ styles: [
'.dynamic-image {width: 100%; height: fit-content;}', '.dynamic-image {width: 100%; height: fit-content;}',
'.static-image {max-width: 100%; max-height: 100%; display: grid;}', // grid: to prevent scrollbars '.static-image {max-width: 100%; max-height: 100%; display: grid;}', // grid: to prevent scrollbars
'.center-content {display: block; margin: auto; top: 50%; transform: translateY(-50%);}',
'.fixed-size-dynamic-image {position: relative; object-fit: scale-down;}' '.fixed-size-dynamic-image {position: relative; object-fit: scale-down;}'
] ]
}) })
......
...@@ -7,8 +7,10 @@ import { CheckboxElement } from './checkbox-element'; ...@@ -7,8 +7,10 @@ import { CheckboxElement } from './checkbox-element';
selector: 'app-checkbox', selector: 'app-checkbox',
template: ` template: `
<div class="mat-form-field" <div class="mat-form-field"
[style.width.%]="100" [style.width]="elementModel.positionProps.fixedSize ? elementModel.width + 'px' : '100%'"
[style.height.%]="100" [style.height]="elementModel.positionProps.fixedSize ? elementModel.height + 'px' : '100%'"
[class.center-content]="elementModel.positionProps.dynamicPositioning &&
elementModel.positionProps.fixedSize"
[style.background-color]="elementModel.surfaceProps.backgroundColor"> [style.background-color]="elementModel.surfaceProps.backgroundColor">
<mat-checkbox #checkbox class="example-margin" <mat-checkbox #checkbox class="example-margin"
[formControl]="elementFormControl" [formControl]="elementFormControl"
......
...@@ -9,81 +9,86 @@ import { FormElementComponent } from '../../directives/form-element-component.di ...@@ -9,81 +9,86 @@ import { FormElementComponent } from '../../directives/form-element-component.di
@Component({ @Component({
selector: 'app-cloze', selector: 'app-cloze',
template: ` template: `
<p *ngFor="let paragraph of elementModel.parts; let i = index" <div [class.center-content]="elementModel.positionProps.dynamicPositioning &&
[style.line-height.%]="elementModel.fontProps.lineHeight" elementModel.positionProps.fixedSize"
[style.color]="elementModel.fontProps.fontColor" [style.width]="elementModel.positionProps.fixedSize ? elementModel.width + 'px' : '100%'"
[style.font-family]="elementModel.fontProps.font" [style.height]="elementModel.positionProps.fixedSize ? elementModel.height + 'px' : 'auto'">
[style.font-size.px]="elementModel.fontProps.fontSize" <p *ngFor="let paragraph of elementModel.parts; let i = index"
[style.font-weight]="elementModel.fontProps.bold ? 'bold' : ''" [style.line-height.%]="elementModel.fontProps.lineHeight"
[style.font-style]="elementModel.fontProps.italic ? 'italic' : ''" [style.color]="elementModel.fontProps.fontColor"
[style.text-decoration]="elementModel.fontProps.underline ? 'underline' : ''"> [style.font-family]="elementModel.fontProps.font"
<ng-container *ngFor="let part of paragraph; let j = index"> [style.font-size.px]="elementModel.fontProps.fontSize"
[style.font-weight]="elementModel.fontProps.bold ? 'bold' : ''"
[style.font-style]="elementModel.fontProps.italic ? 'italic' : ''"
[style.text-decoration]="elementModel.fontProps.underline ? 'underline' : ''">
<ng-container *ngFor="let part of paragraph; let j = index">
<span *ngIf="part.type === 'p'" <span *ngIf="part.type === 'p'"
[innerHTML]="part.value" [innerHTML]="part.value"
[style]="part.style"> [style]="part.style">
</span> </span>
<h1 *ngIf="part.type === 'h1'" <h1 *ngIf="part.type === 'h1'"
[innerHTML]="part.value" [innerHTML]="part.value"
[style.display]="'inline'" [style.display]="'inline'"
[style]="part.style"> [style]="part.style">
</h1> </h1>
<h2 *ngIf="part.type === 'h2'" <h2 *ngIf="part.type === 'h2'"
[innerHTML]="part.value" [innerHTML]="part.value"
[style.display]="'inline'" [style.display]="'inline'"
[style]="part.style"> [style]="part.style">
</h2> </h2>
<h3 *ngIf="part.type === 'h3'" <h3 *ngIf="part.type === 'h3'"
[innerHTML]="part.value" [innerHTML]="part.value"
[style.display]="'inline'" [style.display]="'inline'"
[style]="part.style"> [style]="part.style">
</h3> </h3>
<h4 *ngIf="part.type === 'h4'" <h4 *ngIf="part.type === 'h4'"
[innerHTML]="part.value" [innerHTML]="part.value"
[style.display]="'inline'" [style.display]="'inline'"
[style]="part.style"> [style]="part.style">
</h4> </h4>
<span (click)="allowClickThrough || selectElement($any(part.value), $event)"> <span (click)="allowClickThrough || selectElement($any(part.value), $event)">
<app-dropdown *ngIf="part.type === 'dropdown'" #drowdownComponent <app-dropdown *ngIf="part.type === 'dropdown'" #drowdownComponent
[parentForm]="parentForm"
[style.display]="'inline-block'"
[style.pointerEvents]="allowClickThrough ? 'auto' : 'none'"
[elementModel]="$any(part.value)"
(elementValueChanged)="elementValueChanged.emit($event)">
</app-dropdown>
<app-text-field-simple *ngIf="part.type === 'text-field'" #textfieldComponent
[parentForm]="parentForm" [parentForm]="parentForm"
[style.display]="'inline-block'" [style.display]="'inline-block'"
[style.pointerEvents]="allowClickThrough ? 'auto' : 'none'" [style.pointerEvents]="allowClickThrough ? 'auto' : 'none'"
[elementModel]="$any(part.value)" [elementModel]="$any(part.value)"
(elementValueChanged)="elementValueChanged.emit($event)"> (elementValueChanged)="elementValueChanged.emit($event)">
</app-text-field-simple> </app-dropdown>
<app-text-field-simple *ngIf="part.type === 'text-field'" #textfieldComponent
[parentForm]="parentForm"
[style.display]="'inline-block'"
[style.pointerEvents]="allowClickThrough ? 'auto' : 'none'"
[elementModel]="$any(part.value)"
(elementValueChanged)="elementValueChanged.emit($event)">
</app-text-field-simple>
<app-toggle-button *ngIf="part.type === 'toggle-button'" #radioComponent <app-toggle-button *ngIf="part.type === 'toggle-button'" #radioComponent
[parentForm]="parentForm" [parentForm]="parentForm"
[style.display]="'inline-block'" [style.display]="'inline-block'"
[style.pointerEvents]="allowClickThrough ? 'auto' : 'none'" [style.pointerEvents]="allowClickThrough ? 'auto' : 'none'"
[elementModel]="$any(part.value)" [elementModel]="$any(part.value)"
(elementValueChanged)="elementValueChanged.emit($event)"> (elementValueChanged)="elementValueChanged.emit($event)">
</app-toggle-button> </app-toggle-button>
<div *ngIf="part.type === 'drop-list'" <div *ngIf="part.type === 'drop-list'"
[style.display]="'inline-block'" [style.display]="'inline-block'"
[style.pointerEvents]="allowClickThrough ? 'auto' : 'none'" [style.pointerEvents]="allowClickThrough ? 'auto' : 'none'"
[style.vertical-align]="'middle'" [style.vertical-align]="'middle'"
[style.width.px]="$any(part.value).width" [style.width.px]="$any(part.value).width"
[style.height.px]="$any(part.value).height"> [style.height.px]="$any(part.value).height">
<app-drop-list-simple #droplistComponent <app-drop-list-simple #droplistComponent
[parentForm]="parentForm" [parentForm]="parentForm"
(elementValueChanged)="elementValueChanged.emit($event)" (elementValueChanged)="elementValueChanged.emit($event)"
[elementModel]="$any(part.value)"> [elementModel]="$any(part.value)">
</app-drop-list-simple> </app-drop-list-simple>
</div> </div>
</span> </span>
</ng-container> </ng-container>
</p> </p>
</div>
`, `,
styles: [ styles: [
':host ::ng-deep app-text-field {vertical-align: middle}', ':host ::ng-deep app-text-field {vertical-align: middle}',
......
...@@ -86,7 +86,7 @@ import { DragNDropValueObject } from '../../models/uI-element'; ...@@ -86,7 +86,7 @@ import { DragNDropValueObject } from '../../models/uI-element';
'.dropList-highlight.cdk-drop-list-dragging {outline: solid;}', '.dropList-highlight.cdk-drop-list-dragging {outline: solid;}',
'.align-flex {flex: 1 1 auto; flex-flow: row wrap; display: flex; place-content: center space-around; gap: 10px}', '.align-flex {flex: 1 1 auto; flex-flow: row wrap; display: flex; place-content: center space-around; gap: 10px}',
'.center-content {position: relative; top: 0; bottom: 0; left: 0;right: 0; margin: auto;}' '.center-content {top: unset; transform: unset;}'
] ]
}) })
export class DropListComponent extends FormElementComponent { export class DropListComponent extends FormElementComponent {
......
...@@ -6,8 +6,10 @@ import { DropdownElement } from './dropdown-element'; ...@@ -6,8 +6,10 @@ import { DropdownElement } from './dropdown-element';
selector: 'app-dropdown', selector: 'app-dropdown',
template: ` template: `
<mat-form-field appearance="fill" <mat-form-field appearance="fill"
[style.width.%]="100" [style.width]="elementModel.positionProps.fixedSize ? elementModel.width + 'px' : '100%'"
[style.height.%]="100" [style.height]="elementModel.positionProps.fixedSize ? elementModel.height + 'px' : '100%'"
[class.center-content]="elementModel.positionProps.dynamicPositioning &&
elementModel.positionProps.fixedSize"
appInputBackgroundColor [backgroundColor]="elementModel.surfaceProps.backgroundColor"> appInputBackgroundColor [backgroundColor]="elementModel.surfaceProps.backgroundColor">
<mat-label [style.color]="elementModel.fontProps.fontColor" <mat-label [style.color]="elementModel.fontProps.fontColor"
[style.font-family]="elementModel.fontProps.font" [style.font-family]="elementModel.fontProps.font"
......
...@@ -5,14 +5,16 @@ import { ElementComponent } from '../../directives/element-component.directive'; ...@@ -5,14 +5,16 @@ import { ElementComponent } from '../../directives/element-component.directive';
@Component({ @Component({
selector: 'app-frame', selector: 'app-frame',
template: ` template: `
<div [style.width]="elementModel.borderStyle !== 'hidden' ? <div [class.center-content]="elementModel.positionProps.dynamicPositioning &&
'calc(100% - ' + (elementModel.borderWidth * 2) + 'px)' : elementModel.positionProps.fixedSize"
'100%'" [style.width]="elementModel.positionProps.fixedSize ?
[style.height]="elementModel.borderStyle !== 'hidden' ? elementModel.width + 'px' :
'calc(100% - ' + (elementModel.borderWidth * 2) + 'px)' : 'calc(100% - ' + (elementModel.borderWidth * 2) + 'px)'"
'100%'" [style.height]="elementModel.positionProps.fixedSize ?
elementModel.height + 'px' :
'calc(100% - ' + (elementModel.borderWidth * 2) + 'px)'"
[style.border-style]="elementModel.borderStyle" [style.border-style]="elementModel.borderStyle"
[style.border-width.px]="elementModel.borderStyle !== 'hidden' ? elementModel.borderWidth : ''" [style.border-width.px]="elementModel.borderWidth"
[style.border-color]="elementModel.borderColor" [style.border-color]="elementModel.borderColor"
[style.border-radius.px]="elementModel.borderRadius" [style.border-radius.px]="elementModel.borderRadius"
[style.background-color]="elementModel.surfaceProps.backgroundColor"> [style.background-color]="elementModel.surfaceProps.backgroundColor">
......
...@@ -10,7 +10,10 @@ import { ValueChangeElement } from '../../models/uI-element'; ...@@ -10,7 +10,10 @@ import { ValueChangeElement } from '../../models/uI-element';
template: ` template: `
<!-- Display Flex ensures that the image container is centered and <!-- Display Flex ensures that the image container is centered and
that image and magnifier are displayed properly.--> that image and magnifier are displayed properly.-->
<div [style.width.%]="100" <div [style.width]="elementModel.positionProps.fixedSize ? elementModel.width + 'px' : '100%'"
[style.height]="elementModel.positionProps.fixedSize ? elementModel.height + 'px' : '100%'"
[class.center-content]="elementModel.positionProps.dynamicPositioning &&
elementModel.positionProps.fixedSize"
class="image-container" class="image-container"
(mouseover)="magnifierVisible = true" (mouseover)="magnifierVisible = true"
(mouseenter)="magnifierVisible = true" (mouseenter)="magnifierVisible = true"
...@@ -30,9 +33,10 @@ import { ValueChangeElement } from '../../models/uI-element'; ...@@ -30,9 +33,10 @@ import { ValueChangeElement } from '../../models/uI-element';
</div> </div>
`, `,
styles: [ styles: [
'.image-container{ position: relative }', '.image-container {position: relative}',
'.max-size-image{ max-width: 100%; max-height: 100% }', '.max-size-image {max-width: 100%; max-height: 100%}',
'.fit-image{ width: 100%; height: 100%; object-fit: contain}' '.center-content .max-size-image { width: 100%; height: 100%}',
'.fit-image {width: 100%; height: 100%; object-fit: contain}'
] ]
}) })
export class ImageComponent extends ElementComponent { export class ImageComponent extends ElementComponent {
......
...@@ -9,6 +9,10 @@ import { CompoundElementComponent } from '../../directives/compound-element.dire ...@@ -9,6 +9,10 @@ import { CompoundElementComponent } from '../../directives/compound-element.dire
@Component({ @Component({
selector: 'app-likert', selector: 'app-likert',
template: ` template: `
<div [class.center-content]="elementModel.positionProps.dynamicPositioning &&
elementModel.positionProps.fixedSize"
[style.width]="elementModel.positionProps.fixedSize ? elementModel.width + 'px' : '100%'"
[style.height]="elementModel.positionProps.fixedSize ? elementModel.height + 'px' : '100%'">
<div class="mat-typography" <div class="mat-typography"
[style.display]="'grid'" [style.display]="'grid'"
[style.grid-template-columns]="elementModel.firstColumnSizeRatio + 'fr ' + [style.grid-template-columns]="elementModel.firstColumnSizeRatio + 'fr ' +
...@@ -51,6 +55,7 @@ import { CompoundElementComponent } from '../../directives/compound-element.dire ...@@ -51,6 +55,7 @@ import { CompoundElementComponent } from '../../directives/compound-element.dire
</app-likert-radio-button-group> </app-likert-radio-button-group>
</ng-container> </ng-container>
</div> </div>
</div>
`, `,
styles: [ styles: [
'img {object-fit: contain; max-height: 100%; max-width: 100%; margin: 10px}', 'img {object-fit: contain; max-height: 100%; max-width: 100%; margin: 10px}',
......
...@@ -5,9 +5,11 @@ import { FormElementComponent } from '../../directives/form-element-component.di ...@@ -5,9 +5,11 @@ import { FormElementComponent } from '../../directives/form-element-component.di
@Component({ @Component({
selector: 'app-radio-group-images', selector: 'app-radio-group-images',
template: ` template: `
<div [style.width.%]="100" <div [style.width]="elementModel.positionProps.fixedSize ? elementModel.width + 'px' : '100%'"
[style.height.%]="100" [style.height]="elementModel.positionProps.fixedSize ? elementModel.height + 'px' : '100%'"
[style.display]="'grid'" [class.center-content]="elementModel.positionProps.dynamicPositioning &&
elementModel.positionProps.fixedSize"
[style.display]="'grid !important'"
[style.grid-template-columns]="'1fr '.repeat(elementModel.columns.length)" [style.grid-template-columns]="'1fr '.repeat(elementModel.columns.length)"
[style.background-color]="elementModel.surfaceProps.backgroundColor" [style.background-color]="elementModel.surfaceProps.backgroundColor"
[style.color]="elementModel.fontProps.fontColor" [style.color]="elementModel.fontProps.fontColor"
......
...@@ -6,8 +6,10 @@ import { RadioButtonGroupElement } from './radio-button-group-element'; ...@@ -6,8 +6,10 @@ import { RadioButtonGroupElement } from './radio-button-group-element';
selector: 'app-radio-button-group', selector: 'app-radio-button-group',
template: ` template: `
<div class="mat-form-field" <div class="mat-form-field"
[style.width.%]="100" [style.width]="elementModel.positionProps.fixedSize ? elementModel.width + 'px' : '100%'"
[style.height.%]="100" [style.height]="elementModel.positionProps.fixedSize ? elementModel.height + 'px' : '100%'"
[class.center-content]="elementModel.positionProps.dynamicPositioning &&
elementModel.positionProps.fixedSize"
[style.background-color]="elementModel.surfaceProps.backgroundColor" [style.background-color]="elementModel.surfaceProps.backgroundColor"
[style.color]="elementModel.fontProps.fontColor" [style.color]="elementModel.fontProps.fontColor"
[style.font-family]="elementModel.fontProps.font" [style.font-family]="elementModel.fontProps.font"
......
...@@ -9,8 +9,10 @@ import { FormElementComponent } from '../../directives/form-element-component.di ...@@ -9,8 +9,10 @@ import { FormElementComponent } from '../../directives/form-element-component.di
template: ` template: `
<div fxLayout="column" <div fxLayout="column"
[style.background-color]="elementModel.surfaceProps.backgroundColor" [style.background-color]="elementModel.surfaceProps.backgroundColor"
[style.width.%]="100" [style.width]="elementModel.positionProps.fixedSize ? elementModel.width + 'px' : '100%'"
[style.height.%]="100"> [style.height]="elementModel.positionProps.fixedSize ? elementModel.height + 'px' : '100%'"
[class.center-content]="elementModel.positionProps.dynamicPositioning &&
elementModel.positionProps.fixedSize">
<div *ngIf="elementModel.label" <div *ngIf="elementModel.label"
[style.color]="elementModel.fontProps.fontColor" [style.color]="elementModel.fontProps.fontColor"
[style.font-family]="elementModel.fontProps.font" [style.font-family]="elementModel.fontProps.font"
......
...@@ -6,8 +6,10 @@ import { TextAreaElement } from './text-area-element'; ...@@ -6,8 +6,10 @@ import { TextAreaElement } from './text-area-element';
selector: 'app-text-area', selector: 'app-text-area',
template: ` template: `
<mat-form-field [ngClass]="{ 'no-label' : !elementModel.label}" <mat-form-field [ngClass]="{ 'no-label' : !elementModel.label}"
[style.width.%]="100" [style.width]="elementModel.positionProps.fixedSize ? elementModel.width + 'px' : '100%'"
[style.min-height.%]="100" [style.min-height]="elementModel.positionProps.fixedSize ? elementModel.height + 'px' : '100%'"
[class.center-content]="elementModel.positionProps.dynamicPositioning &&
elementModel.positionProps.fixedSize"
appInputBackgroundColor [backgroundColor]="elementModel.surfaceProps.backgroundColor" appInputBackgroundColor [backgroundColor]="elementModel.surfaceProps.backgroundColor"
[style.color]="elementModel.fontProps.fontColor" [style.color]="elementModel.fontProps.fontColor"
[style.font-family]="elementModel.fontProps.font" [style.font-family]="elementModel.fontProps.font"
......
...@@ -8,8 +8,10 @@ import { ValueChangeElement } from '../../models/uI-element'; ...@@ -8,8 +8,10 @@ import { ValueChangeElement } from '../../models/uI-element';
@Component({ @Component({
selector: 'app-text', selector: 'app-text',
template: ` template: `
<div [style.width.%]="100" <div [class.center-content]="elementModel.positionProps.dynamicPositioning &&
[style.height]="'auto'"> elementModel.positionProps.fixedSize"
[style.width]="elementModel.positionProps.fixedSize ? elementModel.width + 'px' : '100%'"
[style.height]="elementModel.positionProps.fixedSize ? elementModel.height + 'px' : 'auto'">
<div *ngIf="elementModel.highlightableYellow || <div *ngIf="elementModel.highlightableYellow ||
elementModel.highlightableTurquoise || elementModel.highlightableTurquoise ||
elementModel.highlightableOrange" elementModel.highlightableOrange"
......
...@@ -63,3 +63,11 @@ blockquote:after { ...@@ -63,3 +63,11 @@ blockquote:after {
blockquote p { blockquote p {
display: inline; display: inline;
} }
.center-content {
position: relative;
display: block !important;
margin: auto !important;
top: 50%;
transform: translateY(-50%);
}
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