-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from gabriel-gn/feature/sidebar-development
- Loading branch information
Showing
21 changed files
with
6,059 additions
and
4,186 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,4 +11,4 @@ export const parameters = { | |
}, | ||
}, | ||
docs: { inlineStories: true }, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export interface SidebarItem { | ||
label: string; // should be unique | ||
iconClass: string; | ||
path?: string | any; // router link | ||
queryParams?: any; // queryParams router link | ||
action?: () => void; // action to trigger | ||
translate?: string; // if provided, use transloco pipe | ||
badge?: any; // badge to be displayed, if not observable, turns into string | ||
children?: SidebarItem[]; | ||
} |
95 changes: 95 additions & 0 deletions
95
src/components/layout/sidebar/sidebar-content/sidebar-content.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
<div class="app-sidebar-content" | ||
[ngStyle]="{'min-width': minWidth}" | ||
> | ||
<ul class="sidebar-nav"> | ||
<ng-container *ngFor="let entry of sidebarEntries"> | ||
<ng-container *ngTemplateOutlet="entryChecker; context: {$implicit: entry, prefixId: getIdForEntry(entry)}"></ng-container> | ||
</ng-container> | ||
</ul> | ||
</div> | ||
|
||
<ng-template #entryChecker let-entry let-prefixId="prefixId"> | ||
<li routerLinkActive="active" | ||
[routerLinkActiveOptions]="{exact: true}" | ||
[ngClass]="{'active': currentExpandedSession.startsWith(prefixId)}" | ||
> | ||
<ng-container [ngSwitch]="!!entry?.children"> | ||
<!--Se for um item sem submenus--> | ||
<ng-container *ngSwitchCase="false"> | ||
<ng-container *ngTemplateOutlet="noSubmenuEntry; context: {$implicit: entry}"></ng-container> | ||
</ng-container> | ||
|
||
<!--Se for um item com submenus--> | ||
<ng-container *ngSwitchCase="true"> | ||
<ng-container *ngTemplateOutlet="submenuEntry; context: {$implicit: entry, prefixId: prefixId}"></ng-container> | ||
</ng-container> | ||
</ng-container> | ||
</li> | ||
</ng-template> | ||
|
||
<ng-template #noSubmenuEntry let-entry> | ||
<a (click)="executeAction($event, entry)" | ||
[routerLink]="entry.path" | ||
[queryParams]="entry?.queryParams" | ||
> | ||
<ng-container *ngTemplateOutlet="entryContent; context: {$implicit: entry}"></ng-container> | ||
</a> | ||
</ng-template> | ||
|
||
<ng-template #submenuEntry let-entry let-prefixId="prefixId" let-isSub="isSub"> | ||
<a [ngClass]="{'sub': isSub}" | ||
[attr.data-bs-toggle]="'collapse'" | ||
[attr.data-bs-target]="'#collapse' + prefixId" | ||
> | ||
<ng-container *ngTemplateOutlet="entryContent; context: {$implicit: entry}"></ng-container> | ||
</a> | ||
|
||
<!--Exibe os itens do submenu--> | ||
<ng-container *ngTemplateOutlet="childEntryContent; context: {$implicit: entry, prefixId: prefixId}"></ng-container> | ||
</ng-template> | ||
|
||
<ng-template #entryContent let-entry> | ||
<i class="{{ entry.iconClass }}"></i> | ||
<p class="ms-2"> | ||
{{entry.label}} | ||
<b *ngIf="entry?.children" class="caret ms-3"></b> | ||
</p> | ||
</ng-template> | ||
|
||
<ng-template #childEntryContent let-entry let-prefixId="prefixId"> | ||
<div *ngIf="entry?.children" | ||
[attr.id]="'collapse' + prefixId" | ||
class="{{currentExpandedSession.startsWith(getIdForEntry(entry, prefixId)) ? 'show' : 'collapse'}}" | ||
> | ||
<div class="d-flex"> | ||
<div class="aux-bar"></div> | ||
<ul class="sidebar-nav"> | ||
<ng-container *ngFor="let childEntry of entry.children"> | ||
<li routerLinkActive="active" | ||
[routerLinkActiveOptions]="{exact: true}" | ||
(isActiveChange)="keepSessionExpanded($event, getIdForEntry(entry, prefixId))" | ||
[ngClass]="{'active': currentExpandedSession.startsWith(getIdForEntry(childEntry, prefixId))}" | ||
> | ||
<ng-container [ngSwitch]="!!childEntry?.children"> | ||
<!--Se for um item sem submenus--> | ||
<ng-container *ngSwitchCase="false"> | ||
<a class="sub" | ||
(click)="executeAction($event, childEntry)" | ||
[routerLink]="childEntry.path" | ||
[queryParams]="childEntry?.queryParams" | ||
> | ||
<ng-container *ngTemplateOutlet="entryContent; context: {$implicit: childEntry}"></ng-container> | ||
</a> | ||
</ng-container> | ||
|
||
<!--Se for um item com submenus--> | ||
<ng-container *ngSwitchCase="true"> | ||
<ng-container *ngTemplateOutlet="submenuEntry; context: {$implicit: childEntry, prefixId: getIdForEntry(childEntry, prefixId), isSub: true}"></ng-container> | ||
</ng-container> | ||
</ng-container> | ||
</li> | ||
</ng-container> | ||
</ul> | ||
</div> | ||
</div> | ||
</ng-template> |
124 changes: 124 additions & 0 deletions
124
src/components/layout/sidebar/sidebar-content/sidebar-content.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
.app-sidebar-content { | ||
$main-link-margin-top: 1.2em; | ||
$sub-link-margin-top: 0.6em; | ||
|
||
padding: 0 1em 1em 0.5em; | ||
list-style: none !important; | ||
|
||
.sidebar-nav { | ||
padding: 0px; | ||
display: block; | ||
transition: 0.3s; | ||
list-style: none !important; | ||
|
||
li { | ||
cursor: pointer; | ||
|
||
* { | ||
color: var(--color-gray-dark); | ||
|
||
&:focus-visible { | ||
outline: none; | ||
} | ||
|
||
} | ||
|
||
a { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
padding: 0.5em 1em; | ||
border-radius: 1em; | ||
|
||
text-decoration: none; | ||
font-size: 0.8em; | ||
font-weight: 500; | ||
|
||
&.expanded { | ||
background-color: rgba(var(--color-gray-dark-rgb), 0.15); | ||
} | ||
|
||
&:hover { | ||
background-color: rgba(var(--color-gray-dark-rgb), 0.15); | ||
|
||
* { | ||
color: var(--color-primary) !important; | ||
} | ||
} | ||
} | ||
|
||
&.active { | ||
> a:first-child { | ||
background-color: rgba(var(--color-primary-rgb), 0.2); | ||
|
||
* { | ||
color: var(--color-primary) !important; | ||
} | ||
} | ||
} | ||
} | ||
|
||
a { | ||
&:first-child { | ||
margin-top: $main-link-margin-top; | ||
} | ||
|
||
&.sub { | ||
margin-top: $sub-link-margin-top; | ||
} | ||
} | ||
|
||
.collapse, | ||
.collapsing { | ||
.nav { | ||
margin-top: 0; | ||
} | ||
} | ||
|
||
p { | ||
margin: 0; | ||
white-space: nowrap; | ||
display: flex; | ||
justify-content: space-between; | ||
width: 100%; | ||
|
||
> { | ||
align-self: center; | ||
} | ||
} | ||
|
||
a:not(.sub) { | ||
p { | ||
font-size: 14px; | ||
font-weight: 700; | ||
text-transform: uppercase; | ||
} | ||
} | ||
|
||
i { | ||
font-size: 24px; | ||
float: left; | ||
line-height: 30px; | ||
width: 34px; | ||
text-align: center; | ||
color: #ffffff; | ||
position: relative; | ||
} | ||
|
||
ul { | ||
margin: 0px; | ||
width: 100%; | ||
} | ||
|
||
div { | ||
.aux-bar { | ||
width: 2px; | ||
min-width: 2px; | ||
border-radius: 50px; | ||
margin: $sub-link-margin-top $sub-link-margin-top 0 $sub-link-margin-top; | ||
background-color: rgba(var(--color-gray-dark-rgb), 0.3); | ||
} | ||
} | ||
|
||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/components/layout/sidebar/sidebar-content/sidebar-content.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { SidebarContentComponent } from './sidebar-content.component'; | ||
|
||
describe('SidebarContentComponent', () => { | ||
let component: SidebarContentComponent; | ||
let fixture: ComponentFixture<SidebarContentComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [ SidebarContentComponent ] | ||
}) | ||
.compileComponents(); | ||
}); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(SidebarContentComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
Oops, something went wrong.
2822a42
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
prisma-components – ./
prisma-components-gabriel-gn.vercel.app
prisma-components.vercel.app
prisma-components-git-main-gabriel-gn.vercel.app