Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kuwait Theme: Add Background Image to Display Group #2589

Open
wants to merge 31 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
76eefa3
feat: background image and position
FaithDaka Dec 3, 2024
92ff80a
styling
FaithDaka Dec 3, 2024
66f1512
display group styling
FaithDaka Dec 3, 2024
78a6058
Merge branch 'master' of https://github.com/IDEMSInternational/open-a…
FaithDaka Dec 3, 2024
0423d23
Merge branch 'master' of https://github.com/IDEMSInternational/open-a…
FaithDaka Dec 3, 2024
bf79b68
Merge branch 'master' into feature-add-image-attribute-to-display-group
esmeetewinkel Dec 4, 2024
b85ab6f
Merge branch 'master' of https://github.com/IDEMSInternational/open-a…
FaithDaka Dec 6, 2024
ff5e1ef
chore: remove display-group box variants styling changes from this br…
jfmcquade Dec 6, 2024
0af1c2d
Merge branch 'master' into feature-add-image-attribute-to-display-group
jfmcquade Dec 6, 2024
f7c6ecf
chore: add 'inline-padding' variant; add 'sticky_background' param
jfmcquade Dec 6, 2024
23c58a4
Merge branch 'master' of https://github.com/IDEMSInternational/open-a…
FaithDaka Dec 9, 2024
e73865a
Merge branch 'feature-add-image-attribute-to-display-group' of https:…
FaithDaka Dec 9, 2024
5bce78a
review: 2589 tidying
chrismclarke Dec 9, 2024
35f4c74
chore: display group inline_padding variant width
jfmcquade Dec 10, 2024
bde0659
Merge branch 'feature-add-image-attribute-to-display-group' into revi…
jfmcquade Dec 10, 2024
bbad7f7
Merge branch 'master' into feature-add-image-attribute-to-display-group
jfmcquade Dec 10, 2024
8b00bae
Merge branch 'feature-add-image-attribute-to-display-group' into revi…
jfmcquade Dec 10, 2024
283a8cc
chore: expose 'style: background-transparent' param on display group
jfmcquade Dec 10, 2024
076a0af
chore: remove background colour override for sticky display group, re…
jfmcquade Dec 11, 2024
07562e6
chore: correct mis-named css var
jfmcquade Dec 11, 2024
a5a4b39
chore: code tidying
chrismclarke Dec 11, 2024
1f5a46a
refactor: background-image contain and standalone function
chrismclarke Dec 11, 2024
6c23069
chore: update background_solid style
chrismclarke Dec 12, 2024
f5a306b
Merge pull request #2612 from IDEMSInternational/review/2589
chrismclarke Dec 12, 2024
01d4481
Merge branch 'master' into feature-add-image-attribute-to-display-group
chrismclarke Dec 12, 2024
992b2ea
Merge branch 'master' into feature-add-image-attribute-to-display-group
esmeetewinkel Dec 16, 2024
518c125
Merge branch 'master' into feature-add-image-attribute-to-display-group
esmeetewinkel Dec 17, 2024
14821a1
Merge branch 'master' into feature-add-image-attribute-to-display-group
esmeetewinkel Dec 18, 2024
740f4be
Merge branch 'master' of https://github.com/IDEMSInternational/open-a…
FaithDaka Dec 22, 2024
9c1e6c9
Merge branch 'master' into feature-add-image-attribute-to-display-group
esmeetewinkel Dec 30, 2024
f27841b
Merge branch 'master' into feature-add-image-attribute-to-display-group
esmeetewinkel Dec 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ ion-modal.nav-stack-modal {
}

ion-toolbar {
--background: var(--ion-color-background);
--background: var(--ion-background-color);
--color: var(--ion-color-primary);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
[style.marginBottom.px]="params.offset"
[ngSwitch]="type"
[style]="_row.style_list | styleList"
[ngStyle]="backgroundImageStyles"
>
<!-- Default Layout -->
<ng-container *ngSwitchDefault>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
.display-group-wrapper {
display: flex;
align-items: center;
background-repeat: no-repeat;
height: auto;
}
/// In flex box components should try to fill height, but not width (leave to flex property)
.display-group-wrapper > plh-template-component {
Expand All @@ -21,6 +23,10 @@
.display-group-wrapper[data-param-style~="wrap"] {
flex-wrap: wrap;
}
// assign default background colour to the display group wrapper (useful in sticky group)
.display-group-wrapper[data-param-style~="background_solid"] {
background-color: var(--ion-background-color);
}

// Default spacing within display groups. Adapted from `template-component.scss`
.display-group-wrapper[data-param-style~="row"] > plh-template-component:not([data-hidden="true"]) {
Expand All @@ -42,6 +48,12 @@
margin: 1em 0 0 0;
}

.display-group-wrapper[data-variant~="inline_padding"] {
width: 100%;
padding-left: var(--padding-start);
padding-right: var(--padding-end);
}

.display-group-wrapper {
&[data-variant~="box_gray"],
&[data-variant~="box_primary"],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
import { Component, OnInit } from "@angular/core";
import { TemplateBaseComponent } from "../../base";
import { getNumberParamFromTemplateRow, getStringParamFromTemplateRow } from "../../../../../utils";
import { NgStyle } from "@angular/common";
import { TemplateAssetService } from "../../../services/template-asset.service";

interface IDisplayGroupParams {
/** TEMPLATE PARAMETER: "variant" */
variant: "box_gray" | "box_primary" | "box_secondary" | "box_white" | "dashed_box";
variant:
| "box_gray"
| "box_primary"
| "box_secondary"
| "box_white"
| "dashed_box"
| "inline_padding";
/** TEMPLATE PARAMETER: "style". TODO: Various additional legacy styles, review and convert some to variants */
style: "form" | "default" | string | null;
/** TEMPLATE PARAMETER: "offset". Add a custom bottom margin */
offset: number;
/** TEMPLATE PARAMETER: "background_image_asset". Add a background to the display group */
backgroundImageAsset: string;
/** TEMPLATE PARAMETER: "background_image_position". Add a position to the background image */
backgroundImagePosition: string;
/** TEMPLATE PARAMETER: "sticky". Set to "top" or "bottom" to make the display group a sticky inline header/footer */
sticky: "top" | "bottom" | null;
}
Expand All @@ -23,6 +35,12 @@ export class TmplDisplayGroupComponent extends TemplateBaseComponent implements
bgColor: string;
type: "form" | "dashed_box" | "default";

public backgroundImageStyles: NgStyle["ngStyle"] = {};

constructor(private templateAssetService: TemplateAssetService) {
super();
}

ngOnInit() {
this.getParams();
}
Expand All @@ -40,6 +58,7 @@ export class TmplDisplayGroupComponent extends TemplateBaseComponent implements
.concat(" " + this.params.style) as IDisplayGroupParams["variant"];
this.params.sticky = getStringParamFromTemplateRow(this._row, "sticky", null) as any;
this.type = this.getTypeFromStyles();
this.backgroundImageStyles = this.getBackgroundImageStyles();
}

private getTypeFromStyles() {
Expand All @@ -48,4 +67,21 @@ export class TmplDisplayGroupComponent extends TemplateBaseComponent implements
return "dashed_box";
return "default";
}

private getBackgroundImageStyles() {
// only generate background image styles if asset included
const backgroundImageAsset = getStringParamFromTemplateRow(this._row, "background_image_asset");
if (!backgroundImageAsset) return {};
// retrieve the image asset url in the same way plh_asset pipe does
// assign background position and size styles and return
const url = this.templateAssetService.getTranslatedAssetPath(backgroundImageAsset);
const backgroundImage = `url(${url})`;
const backgroundPosition = getStringParamFromTemplateRow(
this._row,
"background_image_position",
"top"
);
const backgroundSize = "contain";
return { backgroundImage, backgroundPosition, backgroundSize };
}
}
2 changes: 1 addition & 1 deletion src/app/shared/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ export function getParamFromTemplateRow(
export function getStringParamFromTemplateRow(
row: FlowTypes.TemplateRow,
name: string,
_default: string
_default: string = ""
): string {
const paramValue = getParamFromTemplateRow(row, name, _default) as string;
return paramValue ? `${paramValue}` : paramValue;
Expand Down
Loading