Skip to content
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

feat: soothe right sidebar panel transitions #11614

Merged
merged 1 commit into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions changelog/unreleased/enhancement-soothe-sidebar-transitions
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Enhancement: Soothe right sidebar panel transitions

The panel transitions of the right sidebar are a bit smoother now.

https://github.com/owncloud/web/pull/11614
12 changes: 10 additions & 2 deletions packages/web-pkg/src/components/SideBar/FileSideBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,19 @@
@select-panel="setActiveSideBarPanel"
@close="closeSideBar"
>
<template #header>
<template #rootHeader>
<file-info
v-if="isFileHeaderVisible"
class="sidebar-panel__file_info"
:is-sub-panel-active="!!activePanel"
:is-sub-panel-active="false"
/>
<space-info v-else-if="isSpaceHeaderVisible" class="sidebar-panel__space_info" />
</template>
<template #subHeader>
<file-info
v-if="isFileHeaderVisible"
class="sidebar-panel__file_info"
:is-sub-panel-active="true"
/>
<space-info v-else-if="isSpaceHeaderVisible" class="sidebar-panel__space_info" />
</template>
Expand Down
17 changes: 16 additions & 1 deletion packages/web-pkg/src/components/SideBar/SideBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
:data-testid="`sidebar-panel-${panel.name}`"
:tabindex="activePanelName === panel.name ? -1 : null"
class="sidebar-panel"
:inert="activePanelName !== panel.name"
:class="{
'is-root-panel': panel.isRoot?.(panelContext),
'is-active-sub-panel': hasActiveSubPanel && activeSubPanelName === panel.name, // only one specific sub panel can be active
'is-active-root-panel': hasActiveRootPanel && panel.isRoot?.(panelContext) // all root panels are active if no sub panel is active
}"
Expand Down Expand Up @@ -54,7 +56,8 @@
</div>
<div>
<slot name="header" />
<slot v-if="panel.isRoot?.(panelContext)" name="rootHeader" />
<slot v-else name="subHeader" />
</div>
<div class="sidebar-panel__body" :class="[`sidebar-panel__body-${panel.name}`]">
<div
Expand Down Expand Up @@ -329,6 +332,18 @@ export default defineComponent({
transform: translateX(0);
}
&.is-active-root-panel {
right: 0 !important;
transition: right 0.4s 0s;
}
&.is-root-panel {
transform: translateX(0);
visibility: visible;
transition: right 0.4s 0s;
right: 100px;
}
.multi-root-panel-separator {
border-top: 1px solid var(--oc-color-border);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { AncestorMetaDataValue } from '../../../../src'

const InnerSideBarComponent = defineComponent({
props: { availablePanels: { type: Array, required: true } },
template: '<div id="foo"><slot name="header"></slot></div>'
template: '<div id="foo"><slot name="rootHeader"></slot></div>'
})

vi.mock('../../../../src/composables/selection', () => ({ useSelectedResources: vi.fn() }))
Expand Down
12 changes: 10 additions & 2 deletions tests/e2e/support/objects/app-files/utils/sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { locatorUtils } from '../../../utils'

const contextMenuSelector =
'//span[@data-test-resource-name="%s"]/ancestor::tr[contains(@class, "oc-tbody-tr")]//button[contains(@class, "resource-table-btn-action-dropdown")]'
const closeSidebarRootPanelBtn = `#app-sidebar .is-active-root-panel .header__close`
const closeSidebarSubPanelBtn = `#app-sidebar .is-active-sub-panel .header__close`

const openForResource = async ({
page,
Expand Down Expand Up @@ -48,8 +50,14 @@ export const open = async ({
}

export const close = async ({ page }: { page: Page }): Promise<void> => {
const closeButtonSelector = `//div[contains(@class,"sidebar-panel is-active")]//button[contains(@class,"header__close")]`
await page.locator(closeButtonSelector).click()
// await sidebar transitions
await new Promise((resolve) => setTimeout(resolve, 250))
const isSubPanelActive = await page.locator(closeSidebarSubPanelBtn).isVisible()
if (isSubPanelActive) {
await page.locator(closeSidebarSubPanelBtn).click()
} else {
await page.locator(closeSidebarRootPanelBtn).click()
}
}

export const openPanel = async ({ page, name }: { page: Page; name: string }): Promise<void> => {
Expand Down
2 changes: 2 additions & 0 deletions tests/e2e/support/objects/runtime/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ export class Application {
}

async closeSidebar(): Promise<void> {
// await sidebar transitions
await new Promise((resolve) => setTimeout(resolve, 250))
const isSubPanelActive = await this.#page.locator(closeSidebarSubPanelBtn).isVisible()
if (isSubPanelActive) {
await this.#page.locator(closeSidebarSubPanelBtn).click()
Expand Down