-
Notifications
You must be signed in to change notification settings - Fork 7
Dev dashboard #253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
AAsteria
wants to merge
6
commits into
dev
Choose a base branch
from
dev-dashboard
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Dev dashboard #253
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
97d2550
[Feat] dashboard (need refactoring)
AAsteria 45f2dc9
[Feat] add dashboard styles
AAsteria 0ab1df8
[Refactor] composite pattern to for extensible subview creating process
AAsteria 7d4a614
[Refactor] dynamically create subViews by passing subview options
AAsteria 1058116
[Fix] improve lifecycle management for `TypeXSubView`
AAsteria 2fd73ac
[Refactor] add slider and slider-items to dashboard
AAsteria File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,37 @@ | ||
| import { IInstantiationService } from "src/platform/instantiation/common/instantiation"; | ||
| import { Component } from "src/workbench/services/component/component"; | ||
|
|
||
| export class DashboardSlider extends Component { | ||
|
|
||
| private items: HTMLElement[]; | ||
|
|
||
| constructor( | ||
| @IInstantiationService instantiationService: IInstantiationService, | ||
| items: HTMLElement[], | ||
| ) { | ||
| super('dashboard-slider', null, instantiationService); | ||
| this.items = items; | ||
| } | ||
|
|
||
| public createView(): HTMLElement { | ||
| const sliderContainer = document.createElement('div'); | ||
| sliderContainer.classList.add('slider'); | ||
|
|
||
| this.items.forEach(item => { | ||
| const itemContainer = document.createElement('div'); | ||
| itemContainer.classList.add('slider-item'); | ||
| itemContainer.appendChild(item); | ||
| sliderContainer.appendChild(itemContainer); | ||
| }); | ||
AAsteria marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return sliderContainer; | ||
| } | ||
|
|
||
| protected override _createContent(): void { | ||
| const viewElement = this.createView(); | ||
| this.element.appendChild(viewElement); | ||
| } | ||
|
|
||
| protected override _registerListeners(): void { | ||
|
|
||
| } | ||
| } | ||
This file contains hidden or 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,51 @@ | ||
| import { Priority } from "src/base/common/event"; | ||
|
|
||
| export interface IDashboardSubView { | ||
| /** | ||
| * The unique identifier of the subview. | ||
| */ | ||
| readonly id: string; | ||
|
|
||
| /** | ||
| * The priority of the subview when determining its display order. | ||
| * Subviews with higher priority are displayed before others. | ||
| * @default Priority.Low | ||
| */ | ||
| priority?: Priority; | ||
|
|
||
| /** | ||
| * Renders the subview and appends it to the provided parent element. | ||
| * @param parentElement - The DOM element to append the rendered subview to. | ||
| * @returns The rendered subview element. | ||
| */ | ||
| render(parentElement: HTMLElement): HTMLElement; | ||
|
|
||
| /** | ||
| * Cleans up resources and removes the subview when it is no longer needed. | ||
| */ | ||
| dispose(): void; | ||
| } | ||
|
|
||
| export interface IDashboardSubViewOpts { | ||
| /** | ||
| * The unique identifier of the dashboard view. | ||
| */ | ||
| id: string; | ||
|
|
||
| /** | ||
| * When adding/removing subview, the view with higher priority will show at top | ||
| * first. | ||
| * @default Priority.Low | ||
| */ | ||
| priority?: Priority; | ||
|
|
||
| /** | ||
| * The title of the subview, typically displayed as a header. | ||
| */ | ||
| title?: string; | ||
|
|
||
| /** | ||
| * The content of the subview, which can include an array of strings. | ||
| */ | ||
| content?: string[]; | ||
| } |
This file contains hidden or 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,57 @@ | ||
| import "src/workbench/services/dashboard/media/dashboard.scss"; | ||
| import { IInstantiationService } from "src/platform/instantiation/common/instantiation"; | ||
| import { Component } from "src/workbench/services/component/component"; | ||
| import { Type1SubView } from "src/workbench/services/dashboard/type1SubView"; | ||
| import { Type2SubView } from "src/workbench/services/dashboard/type2SubView"; | ||
| import { IDashboardSubView, IDashboardSubViewOpts } from "src/workbench/services/dashboard/dashboardSubView"; | ||
| import { Priority } from "src/base/common/event"; | ||
| import { panic } from "src/base/common/utilities/panic"; | ||
|
|
||
| export interface IDashboardViewOpts { | ||
| subViews?: IDashboardSubViewOpts[]; | ||
| } | ||
|
|
||
| export class DashboardView extends Component { | ||
|
|
||
| constructor( | ||
| private opts: IDashboardViewOpts, | ||
AAsteria marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| @IInstantiationService instantiationService: IInstantiationService | ||
| ) { | ||
| super("dashboard-view", null, instantiationService); | ||
| } | ||
|
|
||
| public createView(): HTMLElement { | ||
| const container = document.createElement("div"); | ||
| container.classList.add("dashboard-view"); | ||
|
|
||
| this.createSubViews() | ||
| .sort((a, b) => (a.priority || Priority.Low) - (b.priority || Priority.Low)) | ||
| .forEach((subView) => { | ||
| container.appendChild(subView.render(container)); | ||
| this.__register(subView); | ||
| }); | ||
|
|
||
| return container; | ||
| } | ||
|
|
||
| protected override _createContent(): void { | ||
| const viewElement = this.createView(); | ||
| this.element.appendChild(viewElement); | ||
| } | ||
|
|
||
| protected override _registerListeners(): void {} | ||
|
|
||
| private createSubViews(): IDashboardSubView[] { | ||
AAsteria marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| const subViewOptions = this.opts.subViews || []; | ||
| return subViewOptions.map((opts) => { | ||
| switch (opts.id) { | ||
| case 'type1': | ||
| return new Type1SubView(opts); | ||
| case 'type2': | ||
| return new Type2SubView(this.instantiationService, opts); | ||
| default: | ||
| panic(`Unsupported subview type: ${opts.id}`); | ||
| } | ||
| }); | ||
| } | ||
| } | ||
This file contains hidden or 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,126 @@ | ||
| .dashboard-view { | ||
| display: flex; | ||
| flex-direction: column; | ||
| padding: 100px 65px; | ||
| height: 100vh; | ||
| overflow-y: auto; | ||
|
|
||
| // Targeting type1-subview for the welcome section | ||
| .type1-subview { | ||
| display: flex; | ||
| flex-direction: column; | ||
| align-items: flex-start; | ||
|
|
||
| h2 { | ||
| font-size: 28px; | ||
| font-weight: bolder; | ||
| color: #211F27; | ||
| margin-bottom: 24px; | ||
| } | ||
|
|
||
| .new-note-btn { | ||
| background-color: #2aa882; | ||
| color: #ffffff; | ||
| border: none; | ||
| border-radius: 2px; | ||
| padding: 8px 10px; | ||
| margin-bottom: 8px; | ||
| cursor: pointer; | ||
| font-size: 14px; | ||
| transition: background-color 0.3s ease; | ||
|
|
||
| &:hover { | ||
| background-color: #249372; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // Updated for all subviews | ||
| .type2-subview { | ||
| padding: 1rem 0; | ||
|
|
||
| .section-header { | ||
| display: flex; | ||
| align-items: center; | ||
| margin-bottom: 16px; | ||
|
|
||
| h2 { | ||
| font-size: 1.2rem; | ||
| font-weight: 900; | ||
| color: #211F27; | ||
| margin: 0; | ||
| } | ||
|
|
||
| .sort-dropdown { | ||
| display: flex; | ||
| align-items: center; | ||
| font-size: 12px; | ||
| color: #5A564D; | ||
| cursor: pointer; | ||
| background-color: #F0F8F5; | ||
| border: 2px; | ||
| margin-left: 8px; | ||
| padding: 4px 8px; | ||
| border-radius: 2px; | ||
|
|
||
| .triangle-icon { | ||
| width: 4px; | ||
| height: 6px; | ||
| background-color: #2aa882; | ||
| clip-path: polygon(0% 0%, 100% 50%, 0% 100%); | ||
| margin-right: 6px; | ||
| } | ||
|
|
||
| .dropdown-text { | ||
| font-weight: 500; | ||
| color: #5A564D; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| .slider { | ||
| display: flex; | ||
| overflow-x: auto; | ||
| gap: 1rem; | ||
| padding-bottom: 1rem; // Add padding for smooth scrolling | ||
|
|
||
| scrollbar-color: #D9D9D9 transparent; | ||
|
|
||
| &::-webkit-scrollbar { | ||
| height: 3.2px; | ||
| } | ||
|
|
||
| &::-webkit-scrollbar-thumb { | ||
| background: #D9D9D9; | ||
| } | ||
|
|
||
| .slider-item { | ||
| flex: 0 0 calc((100% - 3rem) / 5); | ||
| background-color: transparent; | ||
| border: 1px solid #e6e6e6; | ||
| padding: 10px; | ||
| text-align: left; | ||
| font-size: 10px; | ||
| font-weight: 500; | ||
| color: #495057; | ||
| transition: transform 0.2s ease; | ||
| scroll-behavior: smooth; | ||
|
|
||
| &:hover { | ||
| cursor: pointer; | ||
| } | ||
|
|
||
| .item-title { | ||
| font-weight: bold; | ||
| color: #211F27; | ||
| margin-bottom: 0.5rem; | ||
| } | ||
|
|
||
| .item-meta { | ||
| font-size: 0.8rem; | ||
| color: #5A564D; | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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,65 @@ | ||
| import { IDashboardSubView, IDashboardSubViewOpts } from "src/workbench/services/dashboard/dashboardSubView"; | ||
| import { Disposable } from "src/base/common/dispose"; | ||
| import { addDisposableListener } from "src/base/browser/basic/dom"; | ||
|
|
||
| export class Type1SubView extends Disposable implements IDashboardSubView { | ||
|
|
||
| // [fields] | ||
|
|
||
| public id: string = 'type1'; | ||
| private _subViewContainer: HTMLElement; | ||
|
|
||
| // [constructor] | ||
|
|
||
| constructor( | ||
| private opts: IDashboardSubViewOpts | ||
| ) { | ||
| super(); | ||
| this._subViewContainer = document.createElement("div"); | ||
| this._subViewContainer.classList.add("type1-subview"); | ||
| this._subViewContainer.setAttribute("data-id", this.opts.id); | ||
| } | ||
|
|
||
| // [public methods] | ||
|
|
||
| public render(): HTMLElement { | ||
|
|
||
| this._subViewContainer.innerHTML = ""; | ||
|
|
||
| // Create section header | ||
| const header = document.createElement("div"); | ||
| header.classList.add("section-header"); | ||
|
|
||
| // Title for the section | ||
| const title = document.createElement("h2"); | ||
| title.textContent = this.opts.title || "Welcome to the Dashboard"; | ||
| header.appendChild(title); | ||
|
|
||
| this._subViewContainer.appendChild(header); | ||
|
|
||
| // Add the New Note button | ||
| const newNoteButton = this.__createNewNoteButton(); | ||
| this._subViewContainer.appendChild(newNoteButton); | ||
|
|
||
| return this._subViewContainer; | ||
| } | ||
|
|
||
| // [protected methods] | ||
|
|
||
| public override dispose(): void { | ||
| super.dispose(); | ||
| this._subViewContainer.remove(); | ||
| } | ||
|
|
||
| // [private methods] | ||
|
|
||
| private __createNewNoteButton(): HTMLElement { | ||
| const button = document.createElement("button"); | ||
| button.classList.add("new-note-btn"); | ||
| button.textContent = "+ New Note"; | ||
| this.__register(addDisposableListener(button, "click", () => { | ||
| console.log("New Note button clicked"); | ||
| })); | ||
| return button; | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.