Skip to content

Commit a6a3122

Browse files
committed
refactor(account): reorganiza formulário sobre o usuário
1 parent 8a8ef88 commit a6a3122

File tree

12 files changed

+139
-32
lines changed

12 files changed

+139
-32
lines changed

packages/account/feature-shell/src/lib/containers/account/account.container.html

+16-2
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,28 @@
66

77
<devmx-account-profile />
88

9-
<devmx-account-skills />
10-
119
<fieldset>
1210
<legend>Informações públicas</legend>
1311

1412
<devmx-account-visibility />
1513
</fieldset>
1614

15+
<devmx-account-skills />
16+
17+
<section formGroupName="profile">
18+
<devmx-markdown-toolbar>
19+
<devmx-markdown-editor
20+
label="Bio"
21+
#editor="markdownEditor"
22+
formControlName="minibio"
23+
[maxRows]="80"
24+
/>
25+
<devmx-markdown-view
26+
[content]="form.profile.controls.minibio?.value ?? ''"
27+
/>
28+
</devmx-markdown-toolbar>
29+
</section>
30+
1731
<footer>
1832
<button mat-flat-button [disabled]="state()">
1933
{{state() ? state() : 'Salvar'}}

packages/account/feature-shell/src/lib/containers/account/account.container.ts

+8
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ import { UserComponent } from './user/user.component';
1515
import { ReactiveFormsModule } from '@angular/forms';
1616
import { RouterLink } from '@angular/router';
1717
import { UserForm } from '../../forms/user';
18+
import {
19+
MarkdownEditorComponent,
20+
MarkdownToolbarComponent,
21+
MarkdownViewComponent,
22+
} from '@devmx/shared-ui-global/markdown';
1823
import {
1924
inject,
2025
signal,
@@ -30,6 +35,9 @@ import {
3035
providers: [provideUserPhoto()],
3136
imports: [
3237
ReactiveFormsModule,
38+
MarkdownToolbarComponent,
39+
MarkdownEditorComponent,
40+
MarkdownViewComponent,
3341
UserComponent,
3442
ProfileComponent,
3543
ContactComponent,

packages/account/feature-shell/src/lib/containers/account/profile/profile.component.html

-13
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,4 @@
2727
<mat-datepicker #picker></mat-datepicker>
2828
</mat-form-field>
2929
</div>
30-
31-
<devmx-markdown-toolbar>
32-
<devmx-markdown-editor
33-
label="Bio"
34-
#editor="markdownEditor"
35-
formControlName="minibio"
36-
[maxRows]="40"
37-
[minRows]="40"
38-
/>
39-
<devmx-markdown-view
40-
[content]="form.profile.controls.minibio?.value ?? ''"
41-
/>
42-
</devmx-markdown-toolbar>
4330
</div>

packages/account/feature-shell/src/lib/containers/account/profile/profile.component.ts

-8
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@ import { MatSelectModule } from '@angular/material/select';
77
import { MatInputModule } from '@angular/material/input';
88
import { provideUserPhoto } from '../../../dialogs';
99
import { UserForm } from '../../../forms';
10-
import {
11-
MarkdownEditorComponent,
12-
MarkdownToolbarComponent,
13-
MarkdownViewComponent,
14-
} from '@devmx/shared-ui-global/markdown';
1510

1611
@Component({
1712
selector: 'devmx-account-profile',
@@ -26,9 +21,6 @@ import {
2621
],
2722
providers: [provideNativeDateAdapter(), provideUserPhoto()],
2823
imports: [
29-
MarkdownToolbarComponent,
30-
MarkdownEditorComponent,
31-
MarkdownViewComponent,
3224
ReactiveFormsModule,
3325
MatDatepickerModule,
3426
MatFormFieldModule,

packages/account/feature-shell/src/lib/containers/account/skills/skills.component.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<mat-expansion-panel-header>
1717
<div *cdkDragPlaceholder></div>
1818
<mat-panel-title> {{ item.value.skill?.name }} </mat-panel-title>
19-
<mat-panel-description> {{ item.value.weight }}% </mat-panel-description>
19+
<mat-panel-description class="skill-weight"> {{ item.value.weight }}% </mat-panel-description>
2020
<devmx-icon name="drag/indicator" cdkDragHandle />
2121
</mat-expansion-panel-header>
2222

packages/account/feature-shell/src/lib/containers/account/skills/skills.component.scss

+4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
}
1616
}
1717

18+
.skill-weight {
19+
max-width: 3em;
20+
}
21+
1822
.cdk-drag-placeholder {
1923
opacity: 0;
2024
}

packages/account/feature-shell/src/lib/containers/account/skills/skills.component.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
import { ControlContainer, ReactiveFormsModule } from '@angular/forms';
22
import { MatProgressBarModule } from '@angular/material/progress-bar';
3-
import {
4-
CdkDragDrop,
5-
DragDropModule,
6-
moveItemInArray,
7-
} from '@angular/cdk/drag-drop';
83
import { inject, Component, ChangeDetectorRef } from '@angular/core';
4+
import { MatExpansionModule } from '@angular/material/expansion';
95
import { SearchSkillComponent } from '@devmx/learn-ui-shared';
6+
import { IconComponent } from '@devmx/shared-ui-global/icon';
107
import { MatButtonModule } from '@angular/material/button';
118
import { MatSliderModule } from '@angular/material/slider';
129
import { UserForm, UserSkillForm } from '../../../forms';
1310
import { SkillFacade } from '@devmx/learn-data-access';
14-
import { Skill } from '@devmx/shared-api-interfaces';
1511
import { MatCardModule } from '@angular/material/card';
16-
import { MatExpansionModule } from '@angular/material/expansion';
17-
import { IconComponent } from '@devmx/shared-ui-global/icon';
12+
import { Skill } from '@devmx/shared-api-interfaces';
13+
import {
14+
CdkDragDrop,
15+
DragDropModule,
16+
moveItemInArray,
17+
} from '@angular/cdk/drag-drop';
1818

1919
@Component({
2020
selector: 'devmx-account-skills',

packages/shared/ui-global/button/src/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@ export * from './lib/auto-save-button/auto-save-button.component';
22
export * from './lib/whats-app-button/whats-app-button.component';
33
export * from './lib/calendar-button/calendar-button.component';
44
export * from './lib/youtube-button/youtube-button.component';
5+
export * from './lib/external-link/external-link.directive';
56
export * from './lib/heart-button/heart-button.component';
67
export * from './lib/maps-button/maps-button.component';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import { isPlatformBrowser } from '@angular/common';
2+
import { InjectionToken } from '@angular/core';
3+
import {
4+
OnInit,
5+
inject,
6+
Directive,
7+
PLATFORM_ID,
8+
HostAttributeToken,
9+
} from '@angular/core';
10+
11+
export const WINDOW = new InjectionToken<Window>('WINDOW');
12+
13+
export function windowProvider(document: Document) {
14+
return document.defaultView;
15+
}
16+
17+
export function isExternalLink(link: string): boolean {
18+
return link.startsWith('http://') || link.startsWith('https://');
19+
}
20+
21+
@Directive({
22+
selector: `[devmxExternalLink],a[href]:not([noBlankForExternalLink])`,
23+
host: { '[attr.target]': 'target', '[attr.rel]': 'rel' },
24+
})
25+
export class ExternalLinkDirective implements OnInit {
26+
#platformId = inject(PLATFORM_ID);
27+
28+
target: '_blank' | '_self' | '_parent' | '_top' | '' = '';
29+
30+
href = inject(new HostAttributeToken('href'), { optional: false });
31+
32+
rel: 'noopener noreferrer' | '' = '';
33+
34+
ngOnInit() {
35+
if (!this.href) {
36+
throw new Error(`Este elemento não é um link`);
37+
}
38+
39+
this.#setAnchorTarget();
40+
}
41+
42+
#setAnchorTarget() {
43+
if (!isPlatformBrowser(this.#platformId)) {
44+
return;
45+
}
46+
47+
if (isExternalLink(this.href)) {
48+
this.rel = 'noopener noreferrer';
49+
this.target = '_blank';
50+
}
51+
}
52+
}

packages/shared/ui-global/markdown/src/lib/components/mardown-editor/markdown-editor.component.html

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#textareaRef
66
cdkTextareaAutosize
77
[formControl]="control"
8+
[autofocus]="hasAutofocus"
89
#autosize="cdkTextareaAutosize"
910
[cdkAutosizeMinRows]="minRows()"
1011
[cdkAutosizeMaxRows]="maxRows()"

packages/shared/ui-global/markdown/src/lib/components/mardown-editor/markdown-editor.component.ts

+9
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,15 @@ export class MarkdownEditorComponent extends DefaultValueAccessor {
4141
return ref ? ref.nativeElement : null;
4242
}
4343

44+
autofocus = input<boolean | ''>(false);
45+
46+
get hasAutofocus() {
47+
const value = this.autofocus();
48+
return value === true || value === '';
49+
}
50+
51+
resize = input(true);
52+
4453
label = input('');
4554

4655
hint = input('');

packages/shared/ui-global/markdown/src/lib/components/markdown-view/markdown-view.component.scss

+39
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,42 @@
2121
white-space: pre-wrap;
2222
}
2323
}
24+
25+
:root .mat-typography .markdown-view {
26+
& > h1,
27+
& > h2,
28+
& > h3,
29+
& > h4,
30+
& > h5,
31+
& > h6 {
32+
font-weight: 600;
33+
margin: 1em 0 0;
34+
}
35+
36+
& > h1 {
37+
font-size: 1.7em;
38+
}
39+
& > h2 {
40+
font-size: 1.6em;
41+
}
42+
& > h3 {
43+
font-size: 1.5em;
44+
}
45+
& > h4 {
46+
font-size: 1.4em;
47+
}
48+
& > h5 {
49+
font-size: 1.3em;
50+
}
51+
& > h6 {
52+
font-size: 1.2em;
53+
}
54+
55+
p {
56+
padding: 1em 0 0;
57+
}
58+
59+
ul + p {
60+
margin-top: 1em;
61+
}
62+
}

0 commit comments

Comments
 (0)