@dxos/plugin-deck 0.6.14-staging.54a8bab → 0.6.14-staging.7b35391
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/index.mjs +354 -314
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/types/src/DeckPlugin.d.ts.map +1 -1
- package/dist/types/src/components/DeckLayout/ComplementarySidebar.d.ts +1 -2
- package/dist/types/src/components/DeckLayout/ComplementarySidebar.d.ts.map +1 -1
- package/dist/types/src/components/DeckLayout/DeckLayout.d.ts +1 -7
- package/dist/types/src/components/DeckLayout/DeckLayout.d.ts.map +1 -1
- package/dist/types/src/components/DeckLayout/NodePlankHeading.d.ts +3 -4
- package/dist/types/src/components/DeckLayout/NodePlankHeading.d.ts.map +1 -1
- package/dist/types/src/components/DeckLayout/Plank.d.ts +3 -3
- package/dist/types/src/components/DeckLayout/Plank.d.ts.map +1 -1
- package/dist/types/src/components/DeckLayout/PlankControls.d.ts +19 -0
- package/dist/types/src/components/DeckLayout/PlankControls.d.ts.map +1 -0
- package/dist/types/src/components/DeckLayout/PlankError.d.ts +1 -2
- package/dist/types/src/components/DeckLayout/PlankError.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +7 -0
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/util/overscroll.d.ts +1 -2
- package/dist/types/src/util/overscroll.d.ts.map +1 -1
- package/package.json +27 -27
- package/src/DeckPlugin.tsx +5 -33
- package/src/components/DeckLayout/ComplementarySidebar.tsx +18 -23
- package/src/components/DeckLayout/DeckLayout.tsx +139 -136
- package/src/components/DeckLayout/NodePlankHeading.tsx +30 -17
- package/src/components/DeckLayout/Plank.tsx +50 -91
- package/src/components/DeckLayout/PlankControls.tsx +133 -0
- package/src/components/DeckLayout/PlankError.tsx +6 -8
- package/src/components/DeckLayout/PlankLoading.tsx +1 -1
- package/src/components/DeckLayout/Toast.tsx +1 -1
- package/src/translations.ts +11 -3
- package/src/util/overscroll.ts +9 -30
|
@@ -2,16 +2,13 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { Plus } from '@phosphor-icons/react';
|
|
6
5
|
import React, { type KeyboardEvent, memo, useCallback, useLayoutEffect, useMemo, useRef } from 'react';
|
|
7
6
|
|
|
8
7
|
import {
|
|
9
|
-
LayoutAction,
|
|
10
8
|
type LayoutCoordinate,
|
|
11
9
|
type LayoutEntry,
|
|
12
10
|
type LayoutPart,
|
|
13
11
|
type LayoutParts,
|
|
14
|
-
NavigationAction,
|
|
15
12
|
Surface,
|
|
16
13
|
useIntentDispatcher,
|
|
17
14
|
type Layout,
|
|
@@ -20,17 +17,15 @@ import {
|
|
|
20
17
|
} from '@dxos/app-framework';
|
|
21
18
|
import { debounce } from '@dxos/async';
|
|
22
19
|
import { useGraph } from '@dxos/plugin-graph';
|
|
23
|
-
import { Button, Tooltip, useTranslation } from '@dxos/react-ui';
|
|
24
20
|
import { useAttendableAttributes } from '@dxos/react-ui-attention';
|
|
25
|
-
import {
|
|
26
|
-
import { mainIntrinsicSize } from '@dxos/react-ui-theme';
|
|
21
|
+
import { StackItem, railGridHorizontal } from '@dxos/react-ui-stack';
|
|
22
|
+
import { mainIntrinsicSize, mx } from '@dxos/react-ui-theme';
|
|
27
23
|
|
|
28
24
|
import { NodePlankHeading } from './NodePlankHeading';
|
|
29
25
|
import { PlankContentError, PlankError } from './PlankError';
|
|
30
26
|
import { PlankLoading } from './PlankLoading';
|
|
31
27
|
import { DeckAction } from '../../DeckPlugin';
|
|
32
28
|
import { useNode, useMainSize } from '../../hooks';
|
|
33
|
-
import { DECK_PLUGIN } from '../../meta';
|
|
34
29
|
import { useDeckContext } from '../DeckContext';
|
|
35
30
|
import { useLayout } from '../LayoutContext';
|
|
36
31
|
|
|
@@ -42,12 +37,11 @@ export type PlankProps = {
|
|
|
42
37
|
// TODO(wittjosiah): Remove. Pass in LayoutCoordinate instead of LayoutEntry.
|
|
43
38
|
part: LayoutPart;
|
|
44
39
|
layoutMode: Layout['layoutMode'];
|
|
45
|
-
|
|
46
|
-
|
|
40
|
+
order?: number;
|
|
41
|
+
last?: boolean;
|
|
47
42
|
};
|
|
48
43
|
|
|
49
|
-
export const Plank = memo(({ entry, layoutParts, part,
|
|
50
|
-
const { t } = useTranslation(DECK_PLUGIN);
|
|
44
|
+
export const Plank = memo(({ entry, layoutParts, part, layoutMode, order, last }: PlankProps) => {
|
|
51
45
|
const dispatch = useIntentDispatcher();
|
|
52
46
|
const coordinate: LayoutCoordinate = useMemo(() => ({ part, entryId: entry?.id ?? UNKNOWN_ID }), [entry?.id, part]);
|
|
53
47
|
const { popoverAnchorId, scrollIntoView } = useLayout();
|
|
@@ -55,7 +49,8 @@ export const Plank = memo(({ entry, layoutParts, part, flatDeck, searchEnabled,
|
|
|
55
49
|
const { graph } = useGraph();
|
|
56
50
|
const node = useNode(graph, entry?.id);
|
|
57
51
|
const rootElement = useRef<HTMLDivElement | null>(null);
|
|
58
|
-
const
|
|
52
|
+
const canResize = layoutMode === 'deck';
|
|
53
|
+
const Root = part === 'solo' ? 'article' : StackItem.Root;
|
|
59
54
|
|
|
60
55
|
const attendableAttrs = useAttendableAttributes(coordinate.entryId);
|
|
61
56
|
const index = indexInPart(layoutParts, coordinate);
|
|
@@ -65,11 +60,9 @@ export const Plank = memo(({ entry, layoutParts, part, flatDeck, searchEnabled,
|
|
|
65
60
|
|
|
66
61
|
const size = plankSizing?.[coordinate.entryId] as number | undefined;
|
|
67
62
|
const setSize = useCallback(
|
|
68
|
-
debounce(
|
|
69
|
-
(
|
|
70
|
-
|
|
71
|
-
200,
|
|
72
|
-
),
|
|
63
|
+
debounce((nextSize: number) => {
|
|
64
|
+
return dispatch({ action: DeckAction.UPDATE_PLANK_SIZE, data: { id: coordinate.entryId, size: nextSize } });
|
|
65
|
+
}, 200),
|
|
73
66
|
[dispatch, coordinate.entryId],
|
|
74
67
|
);
|
|
75
68
|
|
|
@@ -88,10 +81,7 @@ export const Plank = memo(({ entry, layoutParts, part, flatDeck, searchEnabled,
|
|
|
88
81
|
}, [coordinate.entryId, scrollIntoView, layoutMode]);
|
|
89
82
|
|
|
90
83
|
const isSolo = layoutMode === 'solo' && part === 'solo';
|
|
91
|
-
const
|
|
92
|
-
(layoutMode === 'solo' && part !== 'solo') ||
|
|
93
|
-
(layoutMode === 'deck' && part === 'solo') ||
|
|
94
|
-
coordinate.entryId === UNKNOWN_ID;
|
|
84
|
+
const isAttendable = isSolo || (layoutMode === 'deck' && part === 'main');
|
|
95
85
|
|
|
96
86
|
const sizeAttrs = useMainSize();
|
|
97
87
|
|
|
@@ -108,78 +98,47 @@ export const Plank = memo(({ entry, layoutParts, part, flatDeck, searchEnabled,
|
|
|
108
98
|
// TODO(wittjosiah): Change prop to accept a component.
|
|
109
99
|
const placeholder = useMemo(() => <PlankLoading />, []);
|
|
110
100
|
|
|
101
|
+
const className = mx(
|
|
102
|
+
'attention-surface relative',
|
|
103
|
+
isSolo && mainIntrinsicSize,
|
|
104
|
+
isSolo && railGridHorizontal,
|
|
105
|
+
isSolo && 'grid absolute inset-0 divide-separator divide-y',
|
|
106
|
+
last && '!border-li border-separator',
|
|
107
|
+
);
|
|
108
|
+
|
|
111
109
|
return (
|
|
112
|
-
<
|
|
113
|
-
size={size}
|
|
114
|
-
setSize={setSize}
|
|
115
|
-
classNames={[isSuppressed && '!sr-only']}
|
|
116
|
-
{...attendableAttrs}
|
|
117
|
-
{...(isSuppressed && { inert: '' })}
|
|
118
|
-
onKeyDown={handleKeyDown}
|
|
110
|
+
<Root
|
|
119
111
|
ref={rootElement}
|
|
112
|
+
data-testid='deck.plank'
|
|
113
|
+
tabIndex={0}
|
|
114
|
+
{...(part === 'solo'
|
|
115
|
+
? ({ ...sizeAttrs, className } as any)
|
|
116
|
+
: {
|
|
117
|
+
item: { id: entry?.id ?? 'never' },
|
|
118
|
+
size,
|
|
119
|
+
onSizeChange: setSize,
|
|
120
|
+
classNames: className,
|
|
121
|
+
order,
|
|
122
|
+
role: 'article',
|
|
123
|
+
})}
|
|
124
|
+
{...(isAttendable ? attendableAttrs : {})}
|
|
125
|
+
onKeyDown={handleKeyDown}
|
|
120
126
|
>
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
</>
|
|
138
|
-
) : (
|
|
139
|
-
<PlankError layoutCoordinate={coordinate} flatDeck={flatDeck} />
|
|
140
|
-
)}
|
|
141
|
-
</NaturalPlank.Content>
|
|
142
|
-
{searchEnabled && resizeable ? (
|
|
143
|
-
<div role='none' className='grid grid-rows-subgrid row-span-3'>
|
|
144
|
-
<Tooltip.Root>
|
|
145
|
-
<Tooltip.Trigger asChild>
|
|
146
|
-
<Button
|
|
147
|
-
data-testid='plankHeading.open'
|
|
148
|
-
variant='ghost'
|
|
149
|
-
classNames='p-1 w-fit'
|
|
150
|
-
onClick={() =>
|
|
151
|
-
dispatch([
|
|
152
|
-
{
|
|
153
|
-
action: LayoutAction.SET_LAYOUT,
|
|
154
|
-
data: {
|
|
155
|
-
element: 'dialog',
|
|
156
|
-
component: 'dxos.org/plugin/search/Dialog',
|
|
157
|
-
dialogBlockAlign: 'start',
|
|
158
|
-
subject: {
|
|
159
|
-
action: NavigationAction.SET,
|
|
160
|
-
position: 'add-after',
|
|
161
|
-
coordinate,
|
|
162
|
-
},
|
|
163
|
-
},
|
|
164
|
-
},
|
|
165
|
-
])
|
|
166
|
-
}
|
|
167
|
-
>
|
|
168
|
-
<span className='sr-only'>{t('insert plank label')}</span>
|
|
169
|
-
<Plus />
|
|
170
|
-
</Button>
|
|
171
|
-
</Tooltip.Trigger>
|
|
172
|
-
<Tooltip.Portal>
|
|
173
|
-
<Tooltip.Content side='bottom' classNames='z-[70]'>
|
|
174
|
-
{t('insert plank label')}
|
|
175
|
-
</Tooltip.Content>
|
|
176
|
-
</Tooltip.Portal>
|
|
177
|
-
</Tooltip.Root>
|
|
178
|
-
<NaturalPlank.ResizeHandle classNames='row-start-[toolbar-start] row-end-[content-end]' />
|
|
179
|
-
</div>
|
|
180
|
-
) : resizeable ? (
|
|
181
|
-
<NaturalPlank.ResizeHandle classNames='row-span-3' />
|
|
182
|
-
) : null}
|
|
183
|
-
</NaturalPlank.Root>
|
|
127
|
+
{node ? (
|
|
128
|
+
<>
|
|
129
|
+
<NodePlankHeading
|
|
130
|
+
coordinate={coordinate}
|
|
131
|
+
node={node}
|
|
132
|
+
canIncrementStart={canIncrementStart}
|
|
133
|
+
canIncrementEnd={canIncrementEnd}
|
|
134
|
+
popoverAnchorId={popoverAnchorId}
|
|
135
|
+
/>
|
|
136
|
+
<Surface role='article' data={data} limit={1} fallback={PlankContentError} placeholder={placeholder} />
|
|
137
|
+
</>
|
|
138
|
+
) : (
|
|
139
|
+
<PlankError layoutCoordinate={coordinate} />
|
|
140
|
+
)}
|
|
141
|
+
{canResize && <StackItem.ResizeHandle />}
|
|
142
|
+
</Root>
|
|
184
143
|
);
|
|
185
144
|
});
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React, { forwardRef } from 'react';
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
Button,
|
|
9
|
+
ButtonGroup,
|
|
10
|
+
type ButtonGroupProps,
|
|
11
|
+
type ButtonProps,
|
|
12
|
+
Icon,
|
|
13
|
+
Tooltip,
|
|
14
|
+
useTranslation,
|
|
15
|
+
} from '@dxos/react-ui';
|
|
16
|
+
|
|
17
|
+
import { DECK_PLUGIN } from '../../meta';
|
|
18
|
+
|
|
19
|
+
export type PlankControlEvent = 'solo' | 'close' | `${'pin' | 'increment'}-${'start' | 'end'}`;
|
|
20
|
+
export type PlankControlHandler = (event: PlankControlEvent) => void;
|
|
21
|
+
|
|
22
|
+
export type PlankCapabilities = {
|
|
23
|
+
incrementStart?: boolean;
|
|
24
|
+
incrementEnd?: boolean;
|
|
25
|
+
solo?: boolean;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export type PlankControlsProps = Omit<ButtonGroupProps, 'onClick'> & {
|
|
29
|
+
onClick?: PlankControlHandler;
|
|
30
|
+
variant?: 'hide-disabled' | 'default';
|
|
31
|
+
close?: boolean | 'minify-start' | 'minify-end';
|
|
32
|
+
capabilities: PlankCapabilities;
|
|
33
|
+
isSolo?: boolean;
|
|
34
|
+
pin?: 'start' | 'end' | 'both';
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const PlankControl = ({ icon, label, ...props }: Omit<ButtonProps, 'children'> & { label: string; icon: string }) => {
|
|
38
|
+
return (
|
|
39
|
+
<Tooltip.Root>
|
|
40
|
+
<Tooltip.Trigger asChild>
|
|
41
|
+
<Button variant='ghost' {...props}>
|
|
42
|
+
<span className='sr-only'>{label}</span>
|
|
43
|
+
<Icon icon={icon} />
|
|
44
|
+
</Button>
|
|
45
|
+
</Tooltip.Trigger>
|
|
46
|
+
<Tooltip.Portal>
|
|
47
|
+
<Tooltip.Content side='bottom' classNames='z-[70]'>
|
|
48
|
+
{label}
|
|
49
|
+
</Tooltip.Content>
|
|
50
|
+
</Tooltip.Portal>
|
|
51
|
+
</Tooltip.Root>
|
|
52
|
+
);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
// TODO(wittjosiah): Duplicate of stack LayoutControls?
|
|
56
|
+
// Translations were to be duplicated between packages.
|
|
57
|
+
export const PlankControls = forwardRef<HTMLDivElement, PlankControlsProps>(
|
|
58
|
+
(
|
|
59
|
+
{ onClick, variant = 'default', capabilities: can, isSolo, pin, close = false, children, ...props },
|
|
60
|
+
forwardedRef,
|
|
61
|
+
) => {
|
|
62
|
+
const { t } = useTranslation(DECK_PLUGIN);
|
|
63
|
+
const buttonClassNames = variant === 'hide-disabled' ? 'disabled:hidden !p-1' : '!p-1';
|
|
64
|
+
|
|
65
|
+
return (
|
|
66
|
+
<ButtonGroup {...props} ref={forwardedRef}>
|
|
67
|
+
{pin && !isSolo && ['both', 'start'].includes(pin) && (
|
|
68
|
+
<PlankControl
|
|
69
|
+
label={t('pin start label')}
|
|
70
|
+
variant='ghost'
|
|
71
|
+
classNames={buttonClassNames}
|
|
72
|
+
onClick={() => onClick?.('pin-start')}
|
|
73
|
+
icon='ph--caret-line-left--regular'
|
|
74
|
+
/>
|
|
75
|
+
)}
|
|
76
|
+
|
|
77
|
+
{can.solo && (
|
|
78
|
+
<PlankControl
|
|
79
|
+
label={t('solo plank label')}
|
|
80
|
+
classNames={buttonClassNames}
|
|
81
|
+
onClick={() => onClick?.('solo')}
|
|
82
|
+
icon={isSolo ? 'ph--arrows-in--regular' : 'ph--arrows-out--regular'}
|
|
83
|
+
/>
|
|
84
|
+
)}
|
|
85
|
+
|
|
86
|
+
{!isSolo && can.solo && (
|
|
87
|
+
<>
|
|
88
|
+
<PlankControl
|
|
89
|
+
label={t('increment start label')}
|
|
90
|
+
disabled={!can.incrementStart}
|
|
91
|
+
classNames={buttonClassNames}
|
|
92
|
+
onClick={() => onClick?.('increment-start')}
|
|
93
|
+
icon='ph--caret-left--regular'
|
|
94
|
+
/>
|
|
95
|
+
<PlankControl
|
|
96
|
+
label={t('increment end label')}
|
|
97
|
+
disabled={!can.incrementEnd}
|
|
98
|
+
classNames={buttonClassNames}
|
|
99
|
+
onClick={() => onClick?.('increment-end')}
|
|
100
|
+
icon='ph--caret-right--regular'
|
|
101
|
+
/>
|
|
102
|
+
</>
|
|
103
|
+
)}
|
|
104
|
+
|
|
105
|
+
{pin && !isSolo && ['both', 'end'].includes(pin) && (
|
|
106
|
+
<PlankControl
|
|
107
|
+
label={t('pin end label')}
|
|
108
|
+
classNames={buttonClassNames}
|
|
109
|
+
onClick={() => onClick?.('pin-end')}
|
|
110
|
+
icon='ph--caret-line-right--regular'
|
|
111
|
+
/>
|
|
112
|
+
)}
|
|
113
|
+
|
|
114
|
+
{close && !isSolo && (
|
|
115
|
+
<PlankControl
|
|
116
|
+
label={t(`${typeof close === 'string' ? 'minify' : 'close'} label`)}
|
|
117
|
+
classNames={buttonClassNames}
|
|
118
|
+
onClick={() => onClick?.('close')}
|
|
119
|
+
data-testid='plankHeading.close'
|
|
120
|
+
icon={
|
|
121
|
+
close === 'minify-start'
|
|
122
|
+
? 'ph--caret-line-left--regular'
|
|
123
|
+
: close === 'minify-end'
|
|
124
|
+
? 'ph--caret-line-right--regular'
|
|
125
|
+
: 'ph--minus--regular'
|
|
126
|
+
}
|
|
127
|
+
/>
|
|
128
|
+
)}
|
|
129
|
+
{children}
|
|
130
|
+
</ButtonGroup>
|
|
131
|
+
);
|
|
132
|
+
},
|
|
133
|
+
);
|
|
@@ -15,18 +15,18 @@ import { DECK_PLUGIN } from '../../meta';
|
|
|
15
15
|
|
|
16
16
|
export const PlankContentError = ({ error }: { error?: Error }) => {
|
|
17
17
|
const { t } = useTranslation(DECK_PLUGIN);
|
|
18
|
+
const errorString = error?.toString() ?? '';
|
|
18
19
|
return (
|
|
19
|
-
<div role='none' className='grid place-items-center
|
|
20
|
+
<div role='none' className='overflow-auto p-8 attention-surface grid place-items-center'>
|
|
20
21
|
<p
|
|
21
22
|
role='alert'
|
|
22
23
|
className={mx(
|
|
23
24
|
descriptionText,
|
|
24
|
-
|
|
25
|
-
'
|
|
26
|
-
'place-self-center border border-dashed border-neutral-400/50 rounded-lg text-center p-8 font-normal text-lg',
|
|
25
|
+
'break-words border border-dashed border-separator rounded-lg p-8',
|
|
26
|
+
errorString.length < 256 && 'text-lg',
|
|
27
27
|
)}
|
|
28
28
|
>
|
|
29
|
-
{error ?
|
|
29
|
+
{error ? errorString : t('error fallback message')}
|
|
30
30
|
</p>
|
|
31
31
|
</div>
|
|
32
32
|
);
|
|
@@ -36,12 +36,10 @@ export const PlankError = ({
|
|
|
36
36
|
layoutCoordinate,
|
|
37
37
|
node,
|
|
38
38
|
error,
|
|
39
|
-
flatDeck,
|
|
40
39
|
}: {
|
|
41
40
|
layoutCoordinate: LayoutCoordinate;
|
|
42
41
|
node?: Node;
|
|
43
42
|
error?: Error;
|
|
44
|
-
flatDeck?: boolean;
|
|
45
43
|
}) => {
|
|
46
44
|
const [timedOut, setTimedOut] = useState(false);
|
|
47
45
|
useEffect(() => {
|
|
@@ -49,7 +47,7 @@ export const PlankError = ({
|
|
|
49
47
|
}, []);
|
|
50
48
|
return (
|
|
51
49
|
<>
|
|
52
|
-
<NodePlankHeading coordinate={layoutCoordinate} node={node} pending={!timedOut}
|
|
50
|
+
<NodePlankHeading coordinate={layoutCoordinate} node={node} pending={!timedOut} />
|
|
53
51
|
{timedOut ? <PlankContentError error={error} /> : <PlankLoading />}
|
|
54
52
|
</>
|
|
55
53
|
);
|
|
@@ -8,7 +8,7 @@ import { Status } from '@dxos/react-ui';
|
|
|
8
8
|
|
|
9
9
|
export const PlankLoading = () => {
|
|
10
10
|
return (
|
|
11
|
-
<div role='none' className='grid
|
|
11
|
+
<div role='none' className='grid place-items-center attention-surface'>
|
|
12
12
|
<Status indeterminate aria-label='Initializing' />
|
|
13
13
|
</div>
|
|
14
14
|
);
|
|
@@ -24,7 +24,7 @@ export const Toast = ({
|
|
|
24
24
|
<NaturalToast.Root data-testid={id} defaultOpen duration={duration} onOpenChange={onOpenChange}>
|
|
25
25
|
<NaturalToast.Body>
|
|
26
26
|
<NaturalToast.Title classNames='items-center'>
|
|
27
|
-
<Icon icon={icon} size={5} classNames='inline mr-1' />
|
|
27
|
+
{icon && <Icon icon={icon} size={5} classNames='inline mr-1' />}
|
|
28
28
|
<span>{title}</span>
|
|
29
29
|
</NaturalToast.Title>
|
|
30
30
|
{description && <NaturalToast.Description>{description}</NaturalToast.Description>}
|
package/src/translations.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
//
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
|
+
|
|
4
5
|
import { DECK_PLUGIN } from './meta';
|
|
5
6
|
|
|
6
7
|
export default [
|
|
@@ -8,8 +9,8 @@ export default [
|
|
|
8
9
|
'en-US': {
|
|
9
10
|
[DECK_PLUGIN]: {
|
|
10
11
|
'main header label': 'Main header',
|
|
11
|
-
'open navigation sidebar label': 'Open navigation sidebar
|
|
12
|
-
'open complementary sidebar label': 'Open complementary sidebar
|
|
12
|
+
'open navigation sidebar label': 'Open navigation sidebar',
|
|
13
|
+
'open complementary sidebar label': 'Open complementary sidebar',
|
|
13
14
|
'plugin error message': 'Content failed to render.',
|
|
14
15
|
'content fallback message': 'Unsupported',
|
|
15
16
|
'content fallback description':
|
|
@@ -33,7 +34,14 @@ export default [
|
|
|
33
34
|
'reload required message': 'Reload required.',
|
|
34
35
|
'pending heading': 'Loading…',
|
|
35
36
|
'insert plank label': 'Open',
|
|
36
|
-
'
|
|
37
|
+
'resize label': 'Drag to resize',
|
|
38
|
+
'pin start label': 'Pin to the left sidebar',
|
|
39
|
+
'pin end label': 'Pin to the right sidebar',
|
|
40
|
+
'increment start label': 'Move to the left',
|
|
41
|
+
'increment end label': 'Move to the right',
|
|
42
|
+
'solo plank label': 'Toggle solo mode',
|
|
43
|
+
'close label': 'Close',
|
|
44
|
+
'minify label': 'Minify',
|
|
37
45
|
'settings overscroll label': 'Plank Overscrolling',
|
|
38
46
|
'select overscroll placeholder': 'Select plank overscrolling behavior',
|
|
39
47
|
'settings overscroll centering label': 'Centering',
|
package/src/util/overscroll.ts
CHANGED
|
@@ -4,9 +4,6 @@
|
|
|
4
4
|
|
|
5
5
|
import type { CSSProperties } from 'react';
|
|
6
6
|
|
|
7
|
-
import { type LayoutEntry } from '@dxos/app-framework';
|
|
8
|
-
import { PLANK_DEFAULTS } from '@dxos/react-ui-deck';
|
|
9
|
-
|
|
10
7
|
/**
|
|
11
8
|
* ┌────────────────────────────────────────────────────────────────────────────────────────────────────┐
|
|
12
9
|
* | Overscroll Padding Calculation for Centering Planks on Screen. │
|
|
@@ -52,39 +49,21 @@ import { PLANK_DEFAULTS } from '@dxos/react-ui-deck';
|
|
|
52
49
|
* └────────────────────────────────────────────────────────────────────────────────────────────────────┘
|
|
53
50
|
*/
|
|
54
51
|
export const calculateOverscroll = (
|
|
55
|
-
|
|
56
|
-
plankSizing: Record<string, number>,
|
|
57
|
-
sidebarOpen: boolean,
|
|
58
|
-
complementarySidebarOpen: boolean,
|
|
52
|
+
planksCount: number,
|
|
59
53
|
): Pick<CSSProperties, 'paddingInlineStart' | 'paddingInlineEnd'> | undefined => {
|
|
60
|
-
if (!
|
|
54
|
+
if (!planksCount) {
|
|
61
55
|
return { paddingInlineStart: 0, paddingInlineEnd: 0 };
|
|
62
56
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
const complementarySidebarWidth = complementarySidebarOpen ? '360px' : '0px';
|
|
67
|
-
|
|
68
|
-
const getPlankSize = (id: string) => (plankSizing[id] ?? PLANK_DEFAULTS.size).toFixed(2) + 'rem';
|
|
69
|
-
|
|
70
|
-
if (planks.length === 1) {
|
|
71
|
-
// Center the plank in the content area.
|
|
72
|
-
const plank = planks[0];
|
|
73
|
-
const plankSize = getPlankSize(plank.id);
|
|
74
|
-
const overscrollPadding = `max(0px, calc(((100dvw - ${sidebarWidth} - ${complementarySidebarWidth} - (${plankSize} + 20px)) / 2)))`;
|
|
75
|
-
|
|
57
|
+
if (planksCount === 1) {
|
|
58
|
+
const overscrollPadding =
|
|
59
|
+
'max(0px, calc(((100dvw - var(--dx-main-sidebarWidth) - var(--dx-main-complementaryWidth) - (var(--dx-main-contentFirstWidth) + 1px)) / 2)))';
|
|
76
60
|
return { paddingInlineStart: overscrollPadding, paddingInlineEnd: overscrollPadding };
|
|
77
61
|
} else {
|
|
78
|
-
// Center the plank on the screen.
|
|
79
|
-
const first = planks[0];
|
|
80
|
-
const firstSize = getPlankSize(first.id);
|
|
81
|
-
|
|
82
|
-
const last = planks[planks.length - 1];
|
|
83
|
-
const lastSize = getPlankSize(last.id);
|
|
84
|
-
|
|
85
62
|
return {
|
|
86
|
-
paddingInlineStart:
|
|
87
|
-
|
|
63
|
+
paddingInlineStart:
|
|
64
|
+
'max(0px, calc(((100dvw - (var(--dx-main-contentFirstWidth) + 1px)) / 2) - var(--dx-main-sidebarWidth)))',
|
|
65
|
+
paddingInlineEnd:
|
|
66
|
+
'max(0px, calc(((100dvw - (var(--dx-main-contentLastWidth) + 1px)) / 2) - var(--dx-main-complementaryWidth)))',
|
|
88
67
|
};
|
|
89
68
|
}
|
|
90
69
|
};
|