-
Notifications
You must be signed in to change notification settings - Fork 52
new navbar component #725
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
timea-solid
wants to merge
12
commits into
staging
Choose a base branch
from
navbar
base: staging
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
new navbar component #725
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
100a089
new navbar component
timea-solid 9111028
up version
timea-solid 21a5b23
chore: update solidos dependencies (dev: solid-logic@4.0.8-1 solid-ui…
github-actions[bot] e1624e4
Potential fix for pull request finding
timea-solid f8313a0
Potential fix for pull request finding
timea-solid f78db6a
chore: update solidos dependencies (dev: solid-logic@4.0.8-1 solid-ui…
github-actions[bot] 878fcaf
Potential fix for pull request finding
timea-solid 26920ef
Potential fix for pull request finding
timea-solid c3a24ac
Potential fix for pull request finding
timea-solid f0f62c5
fix test
timea-solid 662bc65
Merge branch 'navbar' of https://github.com/solidos/solid-panes into …
timea-solid bc4d3a3
fix button texts
timea-solid 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
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,26 @@ | ||
| :host { | ||
| .navbar { | ||
| border: 1px solid var(--color-border,#444); | ||
| border-radius: 5px; | ||
| display: flex; | ||
| background: var(--solid-ui-color-white, #fff); | ||
| overflow: hidden; | ||
| } | ||
|
|
||
| button { | ||
| padding: 10px 25px; | ||
| border-bottom: 2px solid transparent; | ||
| font-weight: 500; | ||
| font-size: 90%; | ||
| } | ||
|
|
||
| button:active, | ||
| button:hover, | ||
| button:focus { | ||
| border-bottom-color: var(--solid-ui-color-primary, #7C4DFF); | ||
| border-radius: 0; | ||
| color: var(--solid-ui-color-primary, #7C4DFF); | ||
| text-transform: capitalize; | ||
| background: color-mix(in srgb, currentColor 25%, transparent); | ||
| } | ||
| } |
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,43 @@ | ||
| import { customElement, WebComponent } from 'solid-ui' | ||
| import { html, TemplateResult } from 'lit' | ||
| import { property } from 'lit/decorators.js' | ||
|
|
||
| import 'solid-ui/components/account' | ||
| import 'solid-ui/components/button' | ||
| import 'solid-ui/components/menu-item' | ||
| import 'solid-ui/components/menu' | ||
| import 'solid-ui/components/solid-emblem' | ||
| import '~icons/lucide/help-circle' | ||
|
|
||
| import styles from './Navbar.styles.css' | ||
|
|
||
| export interface NavbarMenuItem { | ||
| label: string | TemplateResult | ||
| href?: string | ||
| selected?: boolean | ||
| onSelected?(): void | ||
| } | ||
|
|
||
| @customElement('solid-panes-navbar') | ||
| export default class Navbar extends WebComponent { | ||
| static styles = styles | ||
|
|
||
| @property({ type: Array }) | ||
| accessor navbarItems: NavbarMenuItem[] = [] | ||
|
|
||
| render () { | ||
| return html` | ||
| <nav class="navbar"> | ||
| ${this.navbarItems.map(menuItem => html` | ||
| <button | ||
| type="button" | ||
| @click=${() => menuItem.onSelected?.()} | ||
| title=${typeof menuItem.label === 'string' ? menuItem.label : ''} | ||
| > | ||
| ${menuItem.label} | ||
| </button> | ||
| `)} | ||
| </nav> | ||
| ` | ||
| } | ||
| } |
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,4 @@ | ||
| import Navbar from './Navbar' | ||
|
|
||
| export { Navbar } | ||
| export default Navbar |
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,86 @@ | ||
| import { store } from 'solid-logic' | ||
| import { html, render } from 'lit-html' | ||
| import type { OutlineManager } from '../outline/manager' | ||
| import { getPodStorages } from '../outline/podUtils' | ||
| import { createFolderPaneItem } from '../outline/folderPaneUtils' | ||
|
|
||
| import '~icons/lucide/user' | ||
| import '~icons/lucide/users' | ||
| import '~icons/lucide/folder-open' | ||
| import '../components/navbar' | ||
| import { NamedNode } from 'rdflib' | ||
| import type { NavbarMenuItem } from '../components/navbar/Navbar' | ||
|
|
||
| function createNavItem (label: string, onSelected: () => void): NavbarMenuItem { | ||
| return { label, onSelected } | ||
| } | ||
|
|
||
| async function createNavbarMenuItems ( | ||
| outliner: OutlineManager, | ||
| subject: NamedNode, | ||
| OutlineView: HTMLElement | null | ||
| ): Promise<NavbarMenuItem[]> { | ||
| const baseItems: NavbarMenuItem[] = [ | ||
| createNavItem('Profile', () => { | ||
| const profilePane = outliner?.context?.session?.paneRegistry?.byName('profile') | ||
| outliner.GotoSubject(subject, true, profilePane, true, undefined, OutlineView) | ||
| }), | ||
| createNavItem('Friends', () => { | ||
| const socialPane = outliner?.context?.session?.paneRegistry?.byName('social') | ||
| outliner.GotoSubject(subject, true, socialPane, true, undefined, OutlineView) | ||
| }) | ||
| ] | ||
|
|
||
| const podStorages = await getPodStorages(subject.uri) | ||
| if (podStorages.length === 0) return baseItems | ||
|
|
||
| return [ | ||
| ...baseItems, | ||
| createNavItem('Storage', () => { | ||
| const folderPane = outliner?.context?.session?.paneRegistry?.byName('folder') | ||
| if (!folderPane) { | ||
| console.warn('Folder pane is not registered') | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe you should also add this message for profile and social. |
||
| return | ||
| } | ||
| const folderPanes = podStorages.map((pod, index) => | ||
| createFolderPaneItem(folderPane, pod, index) | ||
| ) | ||
| // TODO make storage work for more storage spaces, not just the first one | ||
| outliner.GotoSubject(subject, true, folderPanes[0], true, undefined, OutlineView) | ||
| }) | ||
|
Copilot marked this conversation as resolved.
|
||
| ] | ||
| } | ||
|
|
||
| export async function createNavbar (outliner: OutlineManager) { | ||
| const existingNavbar = document.querySelector('solid-panes-navbar') | ||
|
|
||
| if (existingNavbar) { | ||
| return existingNavbar | ||
| } | ||
|
|
||
| const OutlineView = document.getElementById('OutlineView') | ||
| const mainContent = document.getElementById('MainContent') | ||
| const tmpContainer = document.createElement('div') | ||
| const uri = window.location.href | ||
| const subject: NamedNode = typeof uri === 'string' ? store.sym(uri) : uri | ||
| const menuItems = await createNavbarMenuItems(outliner, subject, OutlineView) | ||
|
|
||
| render( | ||
| html`<solid-panes-navbar .navbarItems=${menuItems}></solid-panes-navbar>`, | ||
| tmpContainer | ||
| ) | ||
|
|
||
| const navbar = tmpContainer.firstElementChild as HTMLElement | null | ||
|
|
||
| if (!navbar) { | ||
| throw new Error('Failed to create nav bar') | ||
| } | ||
|
|
||
| if (mainContent) { | ||
| mainContent.insertBefore(navbar, mainContent.firstChild) | ||
| } else { | ||
| document.body.prepend(navbar) | ||
| } | ||
|
|
||
| return navbar | ||
| } | ||
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,39 @@ | ||
| import * as paneRegistry from 'pane-registry' | ||
| import { getPodStorages } from './podUtils' | ||
| import folderIcon from '../icons/folder.svg' | ||
| import { NamedNode } from 'rdflib' | ||
|
|
||
| const FOLDER_ICON = folderIcon | ||
|
|
||
| // returns the folder pane of the pods of the given subject (or the current URL subject if none is provided), if any. If not, returns an empty array. | ||
| export async function getFolderPaneforStorage (subject?: NamedNode) { | ||
| const uri = (new URL(window.location.href)).searchParams.get('uri') | ||
| const podUrl = subject?.uri || uri || window.location.href | ||
| const podStorages = await getPodStorages(podUrl) | ||
| if (!podStorages.length) return [] | ||
|
|
||
| const folderPane = paneRegistry.byName('folder') | ||
| if (!folderPane) return [] | ||
|
|
||
| return podStorages.map((pod, index) => createFolderPaneItem(folderPane, pod, index)) | ||
| } | ||
|
|
||
| export function createFolderPaneItem (folderPane, pod: NamedNode, index: number) { | ||
| return { | ||
| name: folderPane.name, | ||
| paneName: 'folder', | ||
| tabName: `folder-${index}`, | ||
| label: function () { | ||
| return 'Storage' | ||
| }, | ||
| render: function (_subject, context, options) { | ||
| return folderPane.render(pod, context, options) | ||
| }, | ||
| shouldGetFocus: function () { | ||
| return false | ||
| }, | ||
| requireQueryButton: !!folderPane.requireQueryButton, | ||
| subject: pod, | ||
| icon: FOLDER_ICON | ||
| } | ||
| } |
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
Oops, something went wrong.
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.
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.
Because rdflib is not in my solidos setup I didn't have to remove this one. Thought I'd just mention.