Skip to content

Commit

Permalink
Fixed the aSide behavior (#7588)
Browse files Browse the repository at this point in the history
  • Loading branch information
SasLord authored Jan 6, 2025
1 parent d447937 commit 1254f01
Show file tree
Hide file tree
Showing 7 changed files with 135 additions and 66 deletions.
25 changes: 25 additions & 0 deletions packages/ui/src/components/Separator.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,27 @@
if (parentElement != null && typeof float === 'string') parentElement.setAttribute('data-float', float)
}
const clearContainer = (container: HTMLElement): void => {
if (container === null) return
if (container.hasAttribute('data-float')) container.removeAttribute('data-float')
if (container.hasAttribute('data-size')) container.removeAttribute('data-size')
container.style.width = ''
container.style.minWidth = ''
container.style.maxWidth = ''
}
const clearSibling = (): void => {
if (separators != null && prevElement != null && separators[index].float !== undefined) {
clearContainer(prevElement)
}
if (separators != null && nextElement != null && separators[index + 1].float !== undefined) {
clearContainer(nextElement)
}
}
const clearParent = (): void => {
if (parentElement === null && separator != null) parentElement = separator.parentElement as HTMLElement
if (parentElement != null && typeof float === 'string') clearContainer(parentElement)
}
const calculateSeparators = (): void => {
if (parentElement != null) {
const elements: Element[] = Array.from(parentElement.children)
Expand Down Expand Up @@ -600,6 +621,10 @@
}
})
onDestroy(() => {
if (mounted) {
if (sState === SeparatorState.FLOAT) clearParent()
else if (sState === SeparatorState.NORMAL) clearSibling()
}
window.removeEventListener('resize', resizeDocument)
if (sState !== SeparatorState.FLOAT && $separatorsStore.filter((f) => f === name).length > 0) {
$separatorsStore = $separatorsStore.filter((f) => f !== name)
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/components/internal/Root.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
updateDeviceSize()
$: secondRow = checkAdaptiveMatching($deviceInfo.size, 'xs')
$: asideFloat = $deviceInfo.aside.float
$: asideFloat = checkAdaptiveMatching($deviceInfo.size, 'sm')
$: asideOpen = $deviceInfo.aside.visible
$: appsMini =
$deviceInfo.isMobile &&
Expand Down
20 changes: 13 additions & 7 deletions plugins/workbench-resources/src/components/Workbench.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@
import { get } from 'svelte/store'
const HIDE_NAVIGATOR = 720
const HIDE_ASIDE = 1024
const HIDE_ASIDE = 680 // sm
const FLOAT_ASIDE = 1024 // lg
let contentPanel: HTMLElement
const { setTheme } = getContext<{ setTheme: (theme: string) => void }>('theme')
Expand Down Expand Up @@ -642,13 +643,14 @@
}
}
checkWorkbenchWidth()
$: if ($deviceInfo.docWidth <= HIDE_ASIDE && !$deviceInfo.aside.float) {
$: if ($deviceInfo.docWidth <= FLOAT_ASIDE && !$deviceInfo.aside.float) {
$deviceInfo.aside.visible = false
$deviceInfo.aside.float = true
} else if ($deviceInfo.docWidth > HIDE_ASIDE && $deviceInfo.aside.float) {
} else if ($deviceInfo.docWidth > FLOAT_ASIDE && $deviceInfo.aside.float) {
$deviceInfo.aside.float = false
$deviceInfo.aside.visible = !hiddenAside
}
$: expandedFloatASide = $deviceInfo.docWidth <= FLOAT_ASIDE && $deviceInfo.docWidth > HIDE_ASIDE
const checkOnHide = (): void => {
if ($deviceInfo.navigator.visible && $deviceInfo.navigator.float) $deviceInfo.navigator.visible = false
}
Expand Down Expand Up @@ -976,6 +978,7 @@
<div
bind:this={contentPanel}
class={navigatorModel === undefined ? 'hulyPanels-container' : 'hulyComponent overflow-hidden'}
class:straighteningCorners={expandedFloatASide && $sidebarStore.variant === SidebarVariant.EXPANDED}
data-id={'contentPanel'}
>
{#if currentApplication && currentApplication.component}
Expand Down Expand Up @@ -1014,15 +1017,15 @@
{/if}
</div>
</div>
{#if !$deviceInfo.aside.float}
{#if $sidebarStore.variant === SidebarVariant.EXPANDED}
{#if $deviceInfo.docWidth > HIDE_ASIDE}
{#if $sidebarStore.variant === SidebarVariant.EXPANDED && !expandedFloatASide}
<Separator name={'main'} index={0} color={'transparent'} separatorSize={0} short />
{/if}
<WidgetsBar />
<WidgetsBar expandedFloat={expandedFloatASide} />
{/if}
</div>
<Dock />
{#if $deviceInfo.aside.float}
{#if $deviceInfo.docWidth <= HIDE_ASIDE}
<div
class="antiPanel-navigator right fly no-print {$deviceInfo.navigator.direction === 'horizontal'
? 'portrait'
Expand Down Expand Up @@ -1067,6 +1070,9 @@
&.inner {
background-color: var(--theme-navpanel-color);
.straighteningCorners {
border-radius: var(--medium-BorderRadius) 0 0 var(--medium-BorderRadius);
}
&.rounded {
border-radius: 0 var(--medium-BorderRadius) var(--medium-BorderRadius) 0;
}
Expand Down
21 changes: 17 additions & 4 deletions plugins/workbench-resources/src/components/sidebar/Sidebar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import SidebarMini from './SidebarMini.svelte'
import SidebarExpanded from './SidebarExpanded.svelte'
export let expandedFloat: boolean = false
const client = getClient()
const widgets = client.getModel().findAllSync(workbench.class.Widget, {})
Expand Down Expand Up @@ -64,13 +66,14 @@
<div
id="sidebar"
class="antiPanel-application vertical sidebar-container"
class:mini
class:float={$deviceInfo.aside.float}
class:mini={mini || expandedFloat}
class:expandedFloat
class:float={$deviceInfo.aside.float && !expandedFloat}
>
{#if mini}
<SidebarMini {widgets} {preferences} />
{:else if $sidebarStore.variant === SidebarVariant.EXPANDED}
<SidebarExpanded {widgets} {preferences} />
<SidebarExpanded {widgets} {preferences} float={expandedFloat} />
{/if}
</div>

Expand All @@ -96,8 +99,18 @@
@media (max-width: 1024px) {
.sidebar-container {
width: 100%;
&:not(.expandedFloat) {
border-radius: var(--medium-BorderRadius);
}
&.expandedFloat {
border-left-color: transparent;
}
}
}
@media (max-width: 680px) {
.sidebar-container {
border: 1px solid var(--theme-navpanel-divider);
border-radius: var(--medium-BorderRadius);
}
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
Location,
Header,
Breadcrumbs,
getCurrentLocation
getCurrentLocation,
Separator
} from '@hcengineering/ui'
import { onDestroy, onMount } from 'svelte'
Expand All @@ -32,6 +33,7 @@
export let widgets: Widget[] = []
export let preferences: WidgetPreference[] = []
export let float: boolean = false
let widgetId: Ref<Widget> | undefined = undefined
let widget: Widget | undefined = undefined
Expand Down Expand Up @@ -96,70 +98,92 @@
}
</script>

<div class="sidebar-content">
{#if widget?.component}
<div class="component" use:resizeObserver={resize}>
{#if widget.headerLabel}
<Header
allowFullsize={false}
type="type-aside"
hideBefore={true}
hideActions={false}
hideDescription={true}
adaptive="disabled"
closeOnEscape={false}
<div class="sidebar-wrap__content" class:float>
{#if float}
<Separator name={'main'} index={0} color={'var(--theme-navpanel-border)'} float={'sidebar'} />
{/if}
<div class="sidebar-content">
{#if widget?.component}
<div class="component" use:resizeObserver={resize}>
{#if widget.headerLabel}
<Header
allowFullsize={false}
type="type-aside"
hideBefore={true}
hideActions={false}
hideDescription={true}
adaptive="disabled"
closeOnEscape={false}
on:close={() => {
if (widget !== undefined) {
closeWidget(widget._id)
}
}}
>
<Breadcrumbs items={[{ label: widget.headerLabel }]} currentOnly />
</Header>
{/if}
<Component
is={widget?.component}
props={{ tab, widgetState, height: componentHeight, width: componentWidth, widget }}
on:close={() => {
if (widget !== undefined) {
closeWidget(widget._id)
}
}}
>
<Breadcrumbs items={[{ label: widget.headerLabel }]} currentOnly />
</Header>
{/if}
<Component
is={widget?.component}
props={{ tab, widgetState, height: componentHeight, width: componentWidth, widget }}
on:close={() => {
if (widget !== undefined) {
closeWidget(widget._id)
}
}}
/>
</div>
/>
</div>
{/if}
</div>
{#if widget !== undefined && tabs.length > 0}
<SidebarTabs
{tabs}
selected={tab?.id}
{widget}
on:close={(e) => {
void handleTabClose(e.detail, widget)
}}
on:open={(e) => {
handleTabOpen(e.detail, widget)
}}
/>
{/if}
</div>
{#if widget !== undefined && tabs.length > 0}
<SidebarTabs
{tabs}
selected={tab?.id}
{widget}
on:close={(e) => {
void handleTabClose(e.detail, widget)
}}
on:open={(e) => {
handleTabOpen(e.detail, widget)
}}
/>
{/if}
<WidgetsBar {widgets} {preferences} selected={widgetId} />
<WidgetsBar {widgets} {preferences} selected={widgetId} expandedFloat={float} />

<style lang="scss">
.sidebar-wrap__content,
.sidebar-content {
display: flex;
flex-direction: column;
border-top: 1px solid transparent; // var(--theme-divider-color);
border-right: 1px solid var(--theme-divider-color);
overflow: auto;
width: calc(100% - 3.5rem);
height: 100%;
min-width: 0;
min-height: 0;
}
.sidebar-wrap__content {
width: calc(100% - 3.5rem);
background-color: var(--theme-panel-color);
border-top: 1px solid transparent; // var(--theme-divider-color);
border-right: 1px solid var(--theme-divider-color);
border-left: none;
&.float {
position: absolute;
top: 0;
right: 3.5rem;
border-top-color: var(--theme-divider-color);
border-bottom: 1px solid var(--theme-divider-color);
z-index: 491;
filter: drop-shadow(-2px 0 5px rgba(0, 0, 0, 0.2));
}
@media (max-width: 680px) {
border-top: none;
}
}
.sidebar-content {
overflow: auto;
flex-direction: column;
width: 100%;
}
.component {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@
flex-direction: column;
overflow-x: hidden;
overflow-y: auto;
width: 30px;
min-width: 30px;
max-width: 30px;
width: 2rem;
min-width: 2rem;
max-width: 2rem;
height: 100%;
border-right: 1px solid var(--theme-divider-color);
border-left: 1px solid var(--theme-divider-color);
gap: 0.25rem;
align-items: center;
padding: 0.25rem 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@
export let widgets: Widget[] = []
export let preferences: WidgetPreference[] = []
export let selected: Ref<Widget> | undefined = undefined
export let expandedFloat: boolean = false
function handleAddWidget (): void {
showPopup(AddWidgetsPopup, { widgets })
}
function handleSelectWidget (widget: Widget): void {
if (selected === widget._id) {
if ($deviceInfo.aside.float) $deviceInfo.aside.visible = false
if ($deviceInfo.aside.float && !expandedFloat) $deviceInfo.aside.visible = false
else minimizeSidebar(true)
} else {
openWidget(widget, $sidebarStore.widgetsState.get(widget._id)?.data, { active: true, openedByUser: true })
Expand Down

0 comments on commit 1254f01

Please sign in to comment.