Skip to content

Commit 5a97077

Browse files
[DSpace#2719][CST-12825] Extracts new image-page-field component with css variable
1 parent 8f48822 commit 5a97077

10 files changed

Lines changed: 26 additions & 11 deletions

File tree

src/app/entity-groups/research-entities/item-pages/org-unit/org-unit.component.html

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,18 @@
3232
</ds-generic-item-page-field>
3333
</div>
3434
<div class="col-xs-12 col-md-7">
35-
<ds-generic-item-page-field
35+
<ds-item-page-img-field
3636
[fields]="['organization.identifier.ror']"
37-
[img]="'./assets/images/ror-icon.svg'"
37+
[img]="{
38+
URI: './assets/images/ror-icon.svg',
39+
alt: 'item.page.image.alt.ROR',
40+
heightVar: '--ds-item-page-img-field-ror-inline-height'
41+
}"
3842
[item]="object"
3943
[label]="'orgunit.page.ror'"
4044
[urlRegex]="'(.*)ror.org'"
4145
>
42-
</ds-generic-item-page-field>
46+
</ds-item-page-img-field>
4347
<ds-related-items
4448
[parentItem]="object"
4549
[relationType]="'isPublicationOfOrgUnit'"

src/app/item-page/field-components/metadata-values/metadata-values.component.html

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,11 @@
2525

2626
<!-- Render value as a link with icon -->
2727
<ng-template #linkImg let-img="img" let-value="value">
28-
<a [href]="value" class="dont-break-out ds-simple-metadata-link" target="_blank">
29-
<img alt="metadata logo" height="24" src="{{img}}"/>
28+
<a class="link-anchor" [href]="value" class="dont-break-out ds-simple-metadata-link" target="_blank">
29+
<img class="link-logo"
30+
[alt]="img.alt | translate"
31+
[style.height]="'var(' + img.heightVar + ', --ds-item-page-img-field-default-inline-height)'"
32+
[src]="img.URI"/>
3033
{{value}}
3134
</a>
3235
</ng-template>

src/app/item-page/field-components/metadata-values/metadata-values.component.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { APP_CONFIG, AppConfig } from '../../../../config/app-config.interface';
44
import { BrowseDefinition } from '../../../core/shared/browse-definition.model';
55
import { hasValue } from '../../../shared/empty.util';
66
import { VALUE_LIST_BROWSE_DEFINITION } from '../../../core/shared/value-list-browse-definition.resource-type';
7+
import { ImageField } from '../../simple/field-components/specific-field/img/item-page-img-field.component';
78

89
/**
910
* This component renders the configured 'values' into the ds-metadata-field-wrapper component.
@@ -55,7 +56,10 @@ export class MetadataValuesComponent implements OnChanges {
5556

5657
@Input() browseDefinition?: BrowseDefinition;
5758

58-
@Input() img?: string;
59+
/**
60+
* Optional {@code ImageField} reference that represents an image to be displayed inline.
61+
*/
62+
@Input() img?: ImageField;
5963

6064
ngOnChanges(changes: SimpleChanges): void {
6165
this.renderMarkdown = !!this.appConfig.markdown.enabled && this.enableMarkdown;

src/app/item-page/item-shared.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import { RelatedItemsComponent } from './simple/related-items/related-items-comp
3030
import {
3131
ThemedMetadataRepresentationListComponent
3232
} from './simple/metadata-representation-list/themed-metadata-representation-list.component';
33+
import { ItemPageImgFieldComponent } from './simple/field-components/specific-field/img/item-page-img-field.component';
3334

3435
const ENTRY_COMPONENTS = [
3536
ItemVersionsDeleteModalComponent,
@@ -46,6 +47,7 @@ const COMPONENTS = [
4647
MetadataRepresentationListComponent,
4748
ThemedMetadataRepresentationListComponent,
4849
RelatedItemsComponent,
50+
ItemPageImgFieldComponent,
4951
];
5052

5153
@NgModule({

src/app/item-page/simple/field-components/specific-field/generic/generic-item-page-field.component.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,5 @@ export class GenericItemPageFieldComponent extends ItemPageFieldComponent {
4545
*/
4646
@Input() urlRegex?: string;
4747

48-
@Input() img?: string;
49-
5048

5149
}

src/app/item-page/simple/field-components/specific-field/item-page-field.component.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,5 @@
66
[enableMarkdown]="enableMarkdown"
77
[urlRegex]="urlRegex"
88
[browseDefinition]="browseDefinition|async"
9-
[img]="img"
109
></ds-metadata-values>
1110
</div>

src/app/item-page/simple/field-components/specific-field/item-page-field.component.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@ export class ItemPageFieldComponent {
5151
*/
5252
urlRegex?: string;
5353

54-
img?: string;
55-
5654
/**
5755
* Return browse definition that matches any field used in this component if it is configured as a browse
5856
* link in dspace.cfg (webui.browse.link.<n>)

src/assets/i18n/en.json5

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2464,6 +2464,8 @@
24642464

24652465
"item.page.claim.tooltip": "Claim this item as profile",
24662466

2467+
"item.page.image.alt.ROR": "ROR logo",
2468+
24672469
"item.preview.dc.identifier.uri": "Identifier:",
24682470

24692471
"item.preview.dc.contributor.author": "Authors:",

src/styles/_custom_variables.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,4 +101,7 @@
101101
--ds-dso-edit-lang-width: 90px;
102102
--ds-dso-edit-actions-width: 173px;
103103
--ds-dso-edit-virtual-tooltip-min-width: 300px;
104+
105+
--ds-item-page-img-field-default-inline-height: 24px;
106+
104107
}

src/themes/dspace/styles/_theme_css_variable_overrides.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,7 @@
77
--ds-home-news-link-color: #{$green};
88
--ds-home-news-link-hover-color: #{darken($green, 15%)};
99
--ds-header-navbar-border-bottom-color: #{$green};
10+
--ds-item-page-img-field-default-inline-height: 24px;
11+
--ds-item-page-img-field-ror-inline-height: var(--ds-item-page-img-field-default-inline-height);
1012
}
1113

0 commit comments

Comments
 (0)