-
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.
feat(list): add minimal style for list component
- Loading branch information
patrickjahr
committed
Apr 16, 2024
1 parent
c9e22fd
commit 21b26da
Showing
24 changed files
with
380 additions
and
197 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
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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
<div class="sk-title">{{ label() }}</div> | ||
<ng-content></ng-content> | ||
<div class="sk-actions"> | ||
@if (link()) { | ||
<a class="sk-link" [routerLink]="link()">View Component</a> | ||
} @else { | ||
@if (routes()) { @for (route of routes(); track route.route) { | ||
<a class="sk-link" [routerLink]="route.route">{{ route.label }}</a> | ||
} } @else { | ||
<span class="sk-link">View Component</span> | ||
} | ||
</div> |
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 |
---|---|---|
@@ -1,56 +0,0 @@ | ||
:host { | ||
padding: 0 1rem; | ||
} | ||
|
||
.sk-list { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 1rem; | ||
} | ||
|
||
sk-list-item { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 1rem; | ||
} | ||
|
||
.sk-child-list, | ||
.sk-grand-child-list { | ||
gap: 0.5rem; | ||
} | ||
|
||
.sk-child-list { | ||
margin: 0 0 0.5rem 0.5rem; | ||
} | ||
|
||
.sk-grand-child-list { | ||
margin-bottom: 1rem; | ||
} | ||
|
||
.sk-list.sk-grand-child-list { | ||
width: 100%; | ||
display: grid; | ||
grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); | ||
} | ||
|
||
.sk-label { | ||
height: 32px; | ||
padding: 1rem; | ||
background: white; | ||
cursor: pointer; | ||
display: flex; | ||
align-items: center; | ||
justify-content: flex-start; | ||
border-radius: 0.5rem; | ||
color: #000; | ||
} | ||
|
||
.sk-active { | ||
color: var(--sk-primary-color); | ||
} | ||
|
||
.sk-active.sk-label span { | ||
will-change: transform; | ||
transition: transform 0.3s ease-in-out; | ||
transform: scale(1.1) translateX(0.5rem); | ||
} | ||
68 changes: 1 addition & 67 deletions
68
apps/demo-app/src/app/pages/list-sample/list-sample.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 |
---|---|---|
@@ -1,67 +1 @@ | ||
<sk-list skListProvider (activeIdChanged)="rootActiveId.set($event)"> | ||
<div class="sk-list" @skListAnimation> | ||
@for (rootItem of items(); track rootItem.link) { | ||
<sk-list-item [skListItemId]="rootItem.link" [skEnableRouting]="true"> | ||
<div | ||
class="sk-label" | ||
[class.sk-active]="rootActiveId() === rootItem.link" | ||
sk-label | ||
> | ||
<span> {{ rootItem.label }} </span> | ||
</div> | ||
@if (rootItem.children?.length && rootActiveId() === rootItem.link) { | ||
<sk-list | ||
class="sk-child-list" | ||
sk-childs | ||
(activeIdChanged)="childActiveId.set($event)" | ||
> | ||
<div class="sk-list sk-child-list" @skListAnimation> | ||
@for (childItem of rootItem.children; track childItem.link) { | ||
<sk-list-item | ||
[skListItemId]="childItem.link" | ||
[skEnableRouting]="true" | ||
> | ||
<div | ||
class="sk-label" | ||
[class.sk-active]="childActiveId() === childItem.link" | ||
sk-label | ||
> | ||
<span> {{ childItem.label }} </span> | ||
</div> | ||
@if (childItem.children?.length && childActiveId() === | ||
childItem.link) { | ||
<sk-list | ||
class="sk-grand-child-list" | ||
sk-childs | ||
(activeIdChanged)="grandChildActiveId.set($event)" | ||
> | ||
<div class="sk-list sk-grand-child-list" @skListAnimation> | ||
@for (grandChildItem of childItem.children; track | ||
grandChildItem.link) { | ||
<sk-list-item | ||
[skListItemId]="grandChildItem.link" | ||
[skEnableRouting]="true" | ||
> | ||
<div | ||
class="sk-label" | ||
[class.sk-active]=" | ||
grandChildActiveId() === grandChildItem.link | ||
" | ||
sk-label | ||
> | ||
<span> {{ grandChildItem.label }} </span> | ||
</div> | ||
</sk-list-item> | ||
} | ||
</div> | ||
</sk-list> | ||
} | ||
</sk-list-item> | ||
} | ||
</div> | ||
</sk-list> | ||
} | ||
</sk-list-item> | ||
} | ||
</div> | ||
</sk-list> | ||
<router-outlet></router-outlet> |
36 changes: 3 additions & 33 deletions
36
apps/demo-app/src/app/pages/list-sample/list-sample.component.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 |
---|---|---|
@@ -1,43 +1,13 @@ | ||
import { ChangeDetectionStrategy, Component, signal } from '@angular/core'; | ||
import { ChangeDetectionStrategy, Component } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
import { | ||
ListComponent, | ||
ListItemActiveDirective, | ||
ListItemComponent, | ||
ListProviderDirective, | ||
} from '@qupaya/sketch'; | ||
import { SAMPLE_DATA } from './list-sample.data'; | ||
import { query, transition, trigger } from '@angular/animations'; | ||
import { slideFadeAnimationFactory } from '../../animations/slide.animation'; | ||
import { RouterOutlet } from '@angular/router'; | ||
|
||
@Component({ | ||
selector: 'app-list-sample', | ||
standalone: true, | ||
imports: [ | ||
CommonModule, | ||
ListItemActiveDirective, | ||
ListItemComponent, | ||
ListComponent, | ||
RouterOutlet, | ||
ListProviderDirective, | ||
], | ||
imports: [CommonModule, RouterOutlet], | ||
templateUrl: './list-sample.component.html', | ||
styleUrl: './list-sample.component.css', | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
animations: [ | ||
trigger('skListAnimation', [ | ||
transition(':enter', [ | ||
query(':enter', slideFadeAnimationFactory(), { optional: true }), | ||
]), | ||
]), | ||
], | ||
}) | ||
export class ListSampleComponent { | ||
readonly rootActiveId = signal<string | undefined>(undefined); | ||
readonly childActiveId = signal<string | undefined>(undefined); | ||
readonly grandChildActiveId = signal<string | undefined>(undefined); | ||
readonly items = signal(SAMPLE_DATA, { | ||
equal: (a, b) => a.length === b.length, | ||
}); | ||
} | ||
export class ListSampleComponent {} |
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
2 changes: 2 additions & 0 deletions
2
apps/demo-app/src/app/pages/list-sample/pure-headless/pure-headless.component.css
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,2 @@ | ||
sk-list-item { | ||
} |
28 changes: 28 additions & 0 deletions
28
apps/demo-app/src/app/pages/list-sample/pure-headless/pure-headless.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,28 @@ | ||
<sk-list skListProvider> | ||
@for (rootItem of items(); track rootItem.route) { | ||
<sk-list-item [skListItemId]="rootItem.route"> | ||
<div skLabel> | ||
<span> {{ rootItem.label }} </span> | ||
</div> | ||
<sk-list skChilds> | ||
@for (childItem of rootItem.children; track childItem.route) { | ||
<sk-list-item [skListItemId]="childItem.route"> | ||
<div skLabel> | ||
<span> {{ childItem.label }} </span> | ||
</div> | ||
<sk-list skChilds> | ||
@for (grandChildItem of childItem.children; track | ||
grandChildItem.route) { | ||
<sk-list-item [skListItemId]="grandChildItem.route"> | ||
<div skLabel> | ||
<span> {{ grandChildItem.label }} </span> | ||
</div> | ||
</sk-list-item> | ||
} | ||
</sk-list> | ||
</sk-list-item> | ||
} | ||
</sk-list> | ||
</sk-list-item> | ||
} | ||
</sk-list> |
22 changes: 22 additions & 0 deletions
22
apps/demo-app/src/app/pages/list-sample/pure-headless/pure-headless.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,22 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { PureHeadlessComponent } from './pure-headless.component'; | ||
import { RouterModule } from '@angular/router'; | ||
|
||
describe('PureHeadlessComponent', () => { | ||
let component: PureHeadlessComponent; | ||
let fixture: ComponentFixture<PureHeadlessComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [PureHeadlessComponent, RouterModule.forRoot([])], | ||
}).compileComponents(); | ||
|
||
fixture = TestBed.createComponent(PureHeadlessComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
28 changes: 28 additions & 0 deletions
28
apps/demo-app/src/app/pages/list-sample/pure-headless/pure-headless.component.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,28 @@ | ||
import { Component, signal } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
import { | ||
ListComponent, | ||
ListItemActiveDirective, | ||
ListItemComponent, | ||
ListProviderDirective, | ||
} from '@qupaya/sketch'; | ||
import { SAMPLE_DATA } from '../list-sample.data'; | ||
|
||
@Component({ | ||
selector: 'app-pure-headless', | ||
standalone: true, | ||
imports: [ | ||
CommonModule, | ||
ListItemActiveDirective, | ||
ListItemComponent, | ||
ListComponent, | ||
ListProviderDirective, | ||
], | ||
templateUrl: './pure-headless.component.html', | ||
styleUrl: './pure-headless.component.css', | ||
}) | ||
export class PureHeadlessComponent { | ||
readonly items = signal(SAMPLE_DATA, { | ||
equal: (a, b) => a.length === b.length, | ||
}); | ||
} |
Oops, something went wrong.