Skip to content

Commit

Permalink
Revise Workspace and Layout
Browse files Browse the repository at this point in the history
  • Loading branch information
chuchee authored and keikeicheung committed Aug 14, 2024
1 parent d7b8cf7 commit d1a7f12
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -231,16 +231,10 @@ export const useLayoutCreateNewChild = () => {
() =>
function createNewChild() {
if (layoutPlaceholderJSON) {
const placeholder = (layoutPlaceholderJSON as unknown as LayoutJSON)
.props
? (layoutPlaceholderJSON as unknown as LayoutJSON)
: (layoutPlaceholderJSON as unknown as LayoutJSON[])[
(layoutPlaceholderJSON as unknown as LayoutJSON[]).length - 1
];
const { props } = placeholder;
const { props } = layoutPlaceholderJSON;
return layoutFromJson(
{
...placeholder,
...layoutPlaceholderJSON,
props: {
...props,
resizeable: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
const { info } = logger("useLayoutManager");

export type WorkspaceProps = WorkspaceStackProps & {
layoutPlaceholderJSON?: LayoutJSON | LayoutJSON[];
layoutPlaceholderJSON?: LayoutJSON;
/**
* layoutJSON defines the default layout to render on first load and until such time as
* layout state has been persisted. After that, the persisted state will be rendered.
Expand All @@ -42,7 +42,7 @@ export interface WorkspaceProviderProps extends WorkspaceProps {
/**
* layoutPlaceholderJSON defines the layout to render when a new workspace layout is created.
*/
layoutPlaceholderJSON?: LayoutJSON | LayoutJSON[];
layoutPlaceholderJSON?: LayoutJSON;
}

const ensureLayoutHasTitle = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,26 +33,24 @@ export const getStackWorkspaceJSON = (
StackProps & {
preserve: boolean;
}
> => {
return {
type: "Stack",
id: VuuShellLocation.Workspace,
props: {
className: `${VuuShellLocation.Workspace}-tabs`,
TabstripProps: {
allowAddTab: true,
allowCloseTab: true,
allowRenameTab: true,
animateSelectionThumb: false,
"aria-label": "Workspace Tabs",
location: "workspace-tab",
variant: "primary",
},
preserve: true,
active: activeLayoutIndex ?? 0,
> => ({
type: "Stack",
id: VuuShellLocation.Workspace,
props: {
className: `${VuuShellLocation.Workspace}-tabs`,
TabstripProps: {
allowAddTab: true,
allowCloseTab: true,
allowRenameTab: true,
animateSelectionThumb: false,
"aria-label": "Workspace Tabs",
location: "workspace-tab",
variant: "primary",
},
};
};
preserve: true,
active: activeLayoutIndex ?? 0,
},
});

const placeholderLayout: LayoutJSON = {
props: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { LayoutMetadata, LayoutMetadataDto } from "../layout-types";

export interface WorkspaceContextProps {
layoutMetadata: LayoutMetadata[];
layoutPlaceholderJSON?: LayoutJSON | LayoutJSON[];
layoutPlaceholderJSON?: LayoutJSON;
getApplicationSettings: (
key?: keyof ApplicationSettings
) => ApplicationSettings | ApplicationSetting | undefined;
Expand Down
13 changes: 11 additions & 2 deletions vuu-ui/showcase/src/examples/Shell/ShellLayout.examples.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,16 @@ export const SimpleShellMultiLayouts = () => {
const persistNothing = useMemo(() => new StaticPersistenceManager({}), []);

const workspaceProps = useMemo<WorkspaceProps>(() => {
const placeHolder = [
const placeHolder = {
type: "Placeholder",
props: {
"data-testid": "custom-placeholder",
style: {
background: "yellow",
},
},
};
const layouts = [
{
type: "Placeholder",
props: {
Expand Down Expand Up @@ -240,7 +249,7 @@ export const SimpleShellMultiLayouts = () => {
},
];
return {
layoutJSON: placeHolder,
layoutJSON: layouts,
layoutPlaceholderJSON: placeHolder,
activeLayoutIndex: 1,
};
Expand Down

0 comments on commit d1a7f12

Please sign in to comment.