Skip to content

Commit e4bbfac

Browse files
committed
PD-4788
1 parent 260207b commit e4bbfac

6 files changed

Lines changed: 173 additions & 4 deletions

File tree

‎src/app/cdk/panel/panels/panels.component.html‎

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,12 @@ <h3 class="activity-header orc-font-body-large">
120120
</mat-icon>
121121
<ng-container *ngIf="!isMobile" i18n="@@shared.add"> Add </ng-container>
122122
</button>
123-
<mat-menu #menuAdd="matMenu">
123+
<mat-menu
124+
#menuAdd="matMenu"
125+
[class.works-add-menu-panel]="
126+
type === 'works' && useNewWorksAddMenuStyle
127+
"
128+
>
124129
<ng-container *ngIf="type === 'education' || type === 'qualification'">
125130
<button mat-menu-item (click)="add('education')">
126131
<ng-container i18n="@@shared.addEducation"
@@ -202,7 +207,34 @@ <h3 class="activity-header orc-font-body-large">
202207
>
203208
</button>
204209
</ng-container>
205-
<ng-container *ngIf="type === 'works'">
210+
<ng-container *ngIf="type === 'works' && useNewWorksAddMenuStyle">
211+
<button
212+
mat-menu-item
213+
class="works-add-menu-item"
214+
[class.works-add-menu-divider]="option.id === 'cy-add-work-doi'"
215+
*ngFor="let option of addMenuOptions"
216+
(click)="add('works', option.action)"
217+
id="{{ option.id }}"
218+
>
219+
<div class="works-add-menu-text">
220+
<span
221+
class="works-add-menu-title"
222+
[class.works-add-menu-title-italic]="
223+
option.id === 'cy-add-work-manually'
224+
"
225+
>
226+
{{ option.label }}
227+
</span>
228+
<span
229+
class="works-add-menu-description"
230+
*ngIf="option.description"
231+
>
232+
{{ option.description }}
233+
</span>
234+
</div>
235+
</button>
236+
</ng-container>
237+
<ng-container *ngIf="type === 'works' && !useNewWorksAddMenuStyle">
206238
<button
207239
mat-menu-item
208240
*ngFor="let option of addMenuOptions"

‎src/app/cdk/panel/panels/panels.component.scss‎

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,61 @@
9393
transform: translate(-50%, -50%);
9494
}
9595
}
96+
97+
::ng-deep .works-add-menu-panel {
98+
max-width: 384px;
99+
}
100+
101+
::ng-deep .works-add-menu-panel .mat-mdc-menu-content {
102+
padding-top: 0;
103+
padding-bottom: 0;
104+
}
105+
106+
button.mat-mdc-menu-item.works-add-menu-item {
107+
align-items: flex-start;
108+
min-height: 0;
109+
height: auto;
110+
margin: 0;
111+
padding: 0;
112+
white-space: normal;
113+
}
114+
115+
.works-add-menu-text {
116+
display: flex;
117+
flex-direction: column;
118+
gap: var(--orcid-space-1, 4px);
119+
width: 100%;
120+
max-width: 384px;
121+
padding: var(--orcid-space-4, 16px);
122+
}
123+
124+
.works-add-menu-title {
125+
font-family: var(--orcid-font-family-sans);
126+
font-size: var(--orcid-font-size-body-small, 14px);
127+
font-weight: var(--orcid-font-weight-normal, 400);
128+
line-height: 21px;
129+
letter-spacing: var(--orcid-letter-spacing-body-small, 0.25px);
130+
}
131+
132+
/* Match Material's hover selector so title bold applies in overlay (same state as background) */
133+
::ng-deep .mat-mdc-menu-item.works-add-menu-item:not([disabled]):hover .works-add-menu-title,
134+
::ng-deep .mat-mdc-menu-item.works-add-menu-item:not([disabled]).cdk-keyboard-focused .works-add-menu-title,
135+
::ng-deep .mat-mdc-menu-item.works-add-menu-item:not([disabled]).cdk-mouse-focused .cdk-focused .works-add-menu-title {
136+
font-weight: var(--orcid-font-weight-bold, 700);
137+
}
138+
139+
.works-add-menu-title-italic {
140+
font-style: italic;
141+
}
142+
143+
.works-add-menu-description {
144+
font-family: var(--orcid-font-family-sans);
145+
font-size: var(--orcid-font-size-small-print, 12px);
146+
font-weight: var(--orcid-font-weight-normal, 400);
147+
line-height: 18px;
148+
letter-spacing: var(--orcid-letter-spacing-small-print, 0.5px);
149+
}
150+
151+
button.mat-mdc-menu-item.works-add-menu-item.works-add-menu-divider {
152+
border-top: 1px solid var(--orcid-ui-background-light, #eeeeee);
153+
}

‎src/app/cdk/panel/panels/panels.component.scss-theme.scss‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,34 @@
5656
color: $orcid-dark-primary-text;
5757
}
5858
}
59+
60+
::ng-deep .works-add-menu-panel .mat-mdc-menu-item {
61+
background-color: mat.m2-get-color-from-palette(
62+
$background,
63+
ui-background-lightest
64+
);
65+
color: mat.m2-get-color-from-palette($foreground, text-dark-high);
66+
}
67+
68+
::ng-deep .works-add-menu-panel .mat-mdc-menu-item:hover,
69+
::ng-deep .works-add-menu-panel .mat-mdc-menu-item.cdk-keyboard-focused,
70+
::ng-deep .works-add-menu-panel .mat-mdc-menu-item.cdk-mouse-focused {
71+
background-color: mat.m2-get-color-from-palette($background, ui-background);
72+
color: mat.m2-get-color-from-palette($foreground, text-dark-high);
73+
74+
.works-add-menu-title,
75+
.works-add-menu-description {
76+
color: mat.m2-get-color-from-palette($foreground, text-dark-high);
77+
}
78+
79+
.works-add-menu-title {
80+
font-weight: 700;
81+
}
82+
}
83+
84+
::ng-deep .works-add-menu-panel {
85+
border: 1px solid var(--orcid-ui-background, #bdbdbd);
86+
}
5987
}
6088

6189
@include stack-container-header-theme($orcid-app-theme);

‎src/app/cdk/panel/panels/panels.component.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,14 @@ export class PanelsComponent implements OnInit {
6464
@Input() addMenuOptions: {
6565
action: ADD_EVENT_ACTION
6666
label: string
67+
description?: string
6768
modal?: ComponentType<any>
6869
type?: EXTERNAL_ID_TYPE_WORK
6970
id?: string
7071
}[] = []
7172

73+
@Input() useNewWorksAddMenuStyle = false
74+
7275
@Input() labelAddButton = $localize`:@@shared.sortItems:Sort Items`
7376
@Input() labelExportButton = $localize`:@@shared.exportItems:Export Items`
7477
@Input() labelSortButton = $localize`:@@shared.addItem:Add Item`

‎src/app/record/components/work-stack-group/work-stack-group.component.html‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
[sortTypes]="sortTypes"
1919
[sortType]="'date'"
2020
[addMenuOptions]="addMenuOptions"
21+
[useNewWorksAddMenuStyle]="useNewWorksAddMenuStyle"
2122
(addEvent)="onAddEvent($event)"
2223
(sort)="sortEvent($event)"
2324
[type]="'works'"

‎src/app/record/components/work-stack-group/work-stack-group.component.ts‎

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,46 @@ export class WorkStackGroupComponent implements OnInit, OnDestroy {
8686

8787
userRecordContext: UserRecordOptions = {}
8888

89-
private _baseAddMenuOptions = [
89+
/** New dropdown: order and copy match Figma (node 177:15217). Used when SEARCH_AND_LINK_WIZARD_WITH_CERTIFIED_AND_FEATURED_LINKS is true. */
90+
private _baseAddMenuOptionsNew = [
91+
{
92+
label: $localize`:@@works.addMenu.importFromServices:Import works from other services`,
93+
description: $localize`:@@works.addMenu.importFromServicesDescription:Connect with services that can help keep your ORCID record up-to-date`,
94+
action: ADD_EVENT_ACTION.searchAndLink,
95+
id: 'cy-add-work-search-link',
96+
},
97+
{
98+
label: $localize`:@@works.addMenu.importBibtex:Import works from a BibTeX file`,
99+
description: $localize`:@@works.addMenu.importBibtexDescription:Import works into your ORCID record using BibTeX`,
100+
action: ADD_EVENT_ACTION.bibText,
101+
modal: WorkBibtexModalComponent,
102+
id: 'cy-add-work-bibtext',
103+
},
104+
{
105+
label: $localize`:@@works.addMenu.addWorkDoi:Add work with a DOI`,
106+
action: ADD_EVENT_ACTION.doi,
107+
modal: WorkExternalIdModalComponent,
108+
type: EXTERNAL_ID_TYPE_WORK.doi,
109+
id: 'cy-add-work-doi',
110+
},
111+
{
112+
label: $localize`:@@works.addMenu.addWorkPubmed:Add work with a PubMed ID`,
113+
action: ADD_EVENT_ACTION.pubMed,
114+
modal: WorkExternalIdModalComponent,
115+
type: EXTERNAL_ID_TYPE_WORK.pubMed,
116+
id: 'cy-add-work-pubmed',
117+
},
118+
{
119+
label: $localize`:@@works.addMenu.addWorkManually:Add work manually`,
120+
description: $localize`:@@works.addMenu.addWorkManuallyDescription:Enter the work details yourself`,
121+
action: ADD_EVENT_ACTION.addManually,
122+
modal: WorkModalComponent,
123+
id: 'cy-add-work-manually',
124+
},
125+
]
126+
127+
/** Legacy dropdown: simple labels, original order. Used when SEARCH_AND_LINK_WIZARD_WITH_CERTIFIED_AND_FEATURED_LINKS is false. */
128+
private _baseAddMenuOptionsLegacy = [
90129
{
91130
label: $localize`:@@shared.searchLink:Search & Link`,
92131
action: ADD_EVENT_ACTION.searchAndLink,
@@ -122,12 +161,16 @@ export class WorkStackGroupComponent implements OnInit, OnDestroy {
122161

123162
addMenuOptions: {
124163
label: string
164+
description?: string
125165
action: ADD_EVENT_ACTION
126166
modal?: ComponentType<any>
127167
type?: EXTERNAL_ID_TYPE_WORK
128168
id?: string
129169
}[] = this._buildAddMenuOptions(false)
130170

171+
/** True when SEARCH_AND_LINK_WIZARD_WITH_CERTIFIED_AND_FEATURED_LINKS is on: show new Figma-style Works add dropdown. */
172+
useNewWorksAddMenuStyle = false
173+
131174
$destroy: Subject<boolean> = new Subject<boolean>()
132175
$loading: Observable<boolean>
133176

@@ -190,12 +233,16 @@ export class WorkStackGroupComponent implements OnInit, OnDestroy {
190233
)
191234
.pipe(take(1), takeUntil(this.$destroy))
192235
.subscribe((useCertifiedAndFeatured) => {
236+
this.useNewWorksAddMenuStyle = useCertifiedAndFeatured
193237
this.addMenuOptions = this._buildAddMenuOptions(useCertifiedAndFeatured)
194238
})
195239
}
196240

197241
private _buildAddMenuOptions(useCertifiedAndFeatured: boolean) {
198-
return this._baseAddMenuOptions.map((opt) => {
242+
const base = useCertifiedAndFeatured
243+
? this._baseAddMenuOptionsNew
244+
: this._baseAddMenuOptionsLegacy
245+
return base.map((opt) => {
199246
if (opt.action === ADD_EVENT_ACTION.searchAndLink) {
200247
return {
201248
...opt,

0 commit comments

Comments
 (0)