Skip to content

Commit 9041773

Browse files
committed
✨ add change folder color
1 parent a1c4f34 commit 9041773

File tree

12 files changed

+197
-3
lines changed

12 files changed

+197
-3
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
export const COLORS = [
2+
'#FF8C00',
3+
'#FF8550',
4+
'#FF0000',
5+
'#FF5159',
6+
'#FF889D',
7+
'#FFBCD9',
8+
'#F2BEFF',
9+
'#D1A0FF',
10+
'#8D67FF',
11+
'#00CEDE',
12+
'#00BAE5',
13+
'#008C62',
14+
'#53C395',
15+
'#95FFCA'
16+
];

src/app/core/models/file.model.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ export class File {
1414
folder: Folder;
1515
type: string;
1616
_id?: string;
17+
color?: string;
1718
}

src/app/core/models/folder.model.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ export class Folder {
1616
files: File[];
1717
color: string;
1818
_id?: string;
19+
__v?: number;
1920
}

src/app/core/services/modal.service.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ export class ModalService {
77
openNewFolderModal: EventEmitter<{ open: boolean, folderID: string }> = new EventEmitter();
88
openNewFileModal: EventEmitter<{ open: boolean, folderID: string }> = new EventEmitter();
99
openUpdateNameModal: EventEmitter<{ folderID: string, name: string }> = new EventEmitter();
10+
openUpdateColorModal: EventEmitter<{ folderID: string, currentColor: string }>
11+
= new EventEmitter();
1012

1113
openNewFolder(folderID: string): void {
1214
this.openNewFolderModal.emit({ open: true, folderID });
@@ -19,4 +21,8 @@ export class ModalService {
1921
openUpdateName(folderID: string, name: string): void {
2022
this.openUpdateNameModal.emit({ folderID, name });
2123
}
24+
25+
openUpdateColor(folderID: string, currentColor: string): void {
26+
this.openUpdateColorModal.emit({ folderID, currentColor });
27+
}
2228
}

src/app/features/home/home.component.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,4 @@
2727
<app-new-folder></app-new-folder>
2828
<app-upload-files></app-upload-files>
2929
<app-update-name></app-update-name>
30+
<app-colors></app-colors>

src/app/shared/dropdowns/dots-dropdown/dots-dropdown.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<i class="bx bx-edit-alt"></i>
77
<span class="title">Cambiar nombre</span>
88
</li>
9-
<li role="menuitem" class='dropdown-item' *ngIf="!isFile()">
9+
<li role="menuitem" class='dropdown-item' *ngIf="!isFile()" (click)="openUpdateColorModal()">
1010
<i class="bx bx-palette"></i>
1111
<span class="title">Cambiar color</span>
1212
</li>

src/app/shared/dropdowns/dots-dropdown/dots-dropdown.component.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,11 @@ export class DotsDropdownComponent {
6464
this.hideDropdown();
6565
this.modalService.openUpdateName(this.file._id as string, this.file.name);
6666
}
67+
68+
openUpdateColorModal(): void {
69+
if (this.file.type === 'folder') {
70+
this.hideDropdown();
71+
this.modalService.openUpdateColor(this.file._id as string, this.file.color as string);
72+
}
73+
}
6774
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<div class="modal dialog" #modalColors>
2+
<div class="modal-content">
3+
<div class="header">
4+
<span class="title">Cambiar color</span>
5+
<div class="i-wrapper">
6+
<i class="bx bx-x" (click)="closeModal()"></i>
7+
</div>
8+
</div>
9+
<div class="body">
10+
<div class="colors">
11+
<div class="color"
12+
*ngFor="let color of colors"
13+
[ngStyle]="{'background-color': color}"
14+
(click)="selectColor(color)"
15+
[ngClass]="{'selected': color === selectedColor}">
16+
</div>
17+
</div>
18+
<div class="actions">
19+
<button class="btn btn-primary" [disabled]="!selectedColor" (click)="updateColor()">Guardar</button>
20+
</div>
21+
</div>
22+
</div>
23+
</div>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
.colors {
2+
display: grid;
3+
grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
4+
grid-gap: 0.7rem;
5+
width: 100%;
6+
padding: 0.6rem 0.4rem;
7+
8+
.color {
9+
width: 40px;
10+
height: 40px;
11+
border-radius: 50%;
12+
cursor: pointer;
13+
transition: all 0.3s ease-in-out;
14+
border: 4px solid transparent;
15+
16+
&:hover {
17+
transform: scale(1.1);
18+
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
19+
}
20+
21+
&.selected {
22+
box-shadow: none;
23+
border: 4px solid var(--fc-purple);
24+
}
25+
}
26+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { ComponentFixture, TestBed } from '@angular/core/testing';
2+
3+
import { ColorsComponent } from './colors.component';
4+
5+
describe('ColorsComponent', () => {
6+
let component: ColorsComponent;
7+
let fixture: ComponentFixture<ColorsComponent>;
8+
9+
beforeEach(async () => {
10+
await TestBed.configureTestingModule({
11+
declarations: [ ColorsComponent ]
12+
})
13+
.compileComponents();
14+
});
15+
16+
beforeEach(() => {
17+
fixture = TestBed.createComponent(ColorsComponent);
18+
component = fixture.componentInstance;
19+
fixture.detectChanges();
20+
});
21+
22+
it('should create', () => {
23+
expect(component).toBeTruthy();
24+
});
25+
});

0 commit comments

Comments
 (0)