-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into add-preferredSize-prop
- Loading branch information
Showing
19 changed files
with
1,074 additions
and
69 deletions.
There are no files selected for viewing
This file contains 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 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 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 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,7 @@ | ||
.container { | ||
box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06); | ||
color: #cccccc; | ||
font-family: sans-serif; | ||
height: 480px; | ||
width: 640px; | ||
} |
This file contains 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,145 @@ | ||
import "@vscode/codicons/dist/codicon.css"; | ||
|
||
import { Meta, Story } from "@storybook/react"; | ||
import { useState } from "react"; | ||
|
||
import { Allotment } from "../src"; | ||
import styles from "./advanced.stories.module.css"; | ||
import { ActivityBar } from "./components/activity-bar"; | ||
import { Editor } from "./components/editor"; | ||
import { Panel } from "./components/panel"; | ||
import { Sidebar } from "./components/sidebar"; | ||
|
||
const ACTIVITIES = [ | ||
"Explorer", | ||
"Search", | ||
"Source Control", | ||
"Run and Debug", | ||
"Extensions", | ||
]; | ||
|
||
const DOCUMENTS = [ | ||
{ title: "allotment.tsx", icon: "ts" }, | ||
{ title: "allotment.module.css", icon: "css" }, | ||
]; | ||
|
||
export interface Document { | ||
title: string; | ||
icon: string; | ||
} | ||
|
||
export default { | ||
title: "Advanced", | ||
Component: Allotment, | ||
argTypes: { | ||
activityBar: { | ||
control: { type: "boolean" }, | ||
}, | ||
primarySideBar: { | ||
control: { type: "boolean" }, | ||
}, | ||
primarySideBarPosition: { | ||
options: ["left", "right"], | ||
control: { type: "radio" }, | ||
}, | ||
}, | ||
} as Meta; | ||
|
||
export const VisualStudioCode: Story = ({ | ||
activityBar, | ||
primarySideBar, | ||
primarySideBarPosition, | ||
}) => { | ||
const [editorVisible, setEditorVisible] = useState(true); | ||
const [panelVisible, setPanelVisible] = useState(true); | ||
const [activity, setActivity] = useState(0); | ||
|
||
const [openEditors, setOpenEditors] = useState<Document[]>(DOCUMENTS); | ||
|
||
const sidebar = ( | ||
<Allotment.Pane key="sidebar" minSize={170} visible={primarySideBar} snap> | ||
<Sidebar | ||
title={ACTIVITIES[activity]} | ||
documents={DOCUMENTS} | ||
openEditors={openEditors} | ||
onOpenEditorsChange={(openEditor) => { | ||
setOpenEditors(openEditor); | ||
}} | ||
/> | ||
</Allotment.Pane> | ||
); | ||
|
||
return ( | ||
<div className={styles.container}> | ||
<Allotment> | ||
<Allotment.Pane | ||
key="activityBar" | ||
minSize={48} | ||
maxSize={48} | ||
visible={activityBar} | ||
> | ||
<ActivityBar | ||
checked={activity} | ||
items={[ | ||
"files", | ||
"search", | ||
"source-control", | ||
"debug-alt", | ||
"extensions", | ||
]} | ||
onClick={(index) => { | ||
setActivity(index); | ||
}} | ||
/> | ||
</Allotment.Pane> | ||
{primarySideBarPosition === "left" && sidebar} | ||
<Allotment.Pane key="content" minSize={300}> | ||
<Allotment | ||
vertical | ||
snap | ||
onVisibleChange={(index, value) => { | ||
if (index === 0) { | ||
setEditorVisible(value); | ||
} else if (index === 1) { | ||
setPanelVisible(value); | ||
} | ||
}} | ||
> | ||
<Allotment.Pane key="editor" minSize={70} visible={editorVisible}> | ||
<Editor | ||
documents={openEditors} | ||
onDocumentsChange={(documents) => { | ||
setOpenEditors(documents); | ||
}} | ||
/> | ||
</Allotment.Pane> | ||
<Allotment.Pane key="terminal" minSize={78} visible={panelVisible}> | ||
<Panel | ||
maximized={!editorVisible} | ||
onClose={() => { | ||
setEditorVisible(true); | ||
setPanelVisible(false); | ||
}} | ||
onMaximize={() => { | ||
setEditorVisible(false); | ||
setPanelVisible(true); | ||
}} | ||
onMinimize={() => { | ||
setEditorVisible(true); | ||
setPanelVisible(true); | ||
}} | ||
/> | ||
</Allotment.Pane> | ||
</Allotment> | ||
</Allotment.Pane> | ||
{primarySideBarPosition === "right" && sidebar} | ||
</Allotment> | ||
</div> | ||
); | ||
}; | ||
|
||
VisualStudioCode.args = { | ||
activityBar: true, | ||
primarySideBar: true, | ||
primarySideBarPosition: "left", | ||
}; |
This file contains 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,44 @@ | ||
.activitybar { | ||
background-color: rgb(51, 51, 51); | ||
height: 100%; | ||
overflow: hidden; | ||
} | ||
|
||
.content { | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: space-between; | ||
} | ||
|
||
.actionsContainer { | ||
list-style-type: none; | ||
padding: 0; | ||
margin: 0; | ||
} | ||
|
||
.actionItem { | ||
align-items: center; | ||
justify-content: center; | ||
cursor: pointer; | ||
position: relative; | ||
} | ||
|
||
.actionItem.checked:before { | ||
content: ""; | ||
position: absolute; | ||
z-index: 1; | ||
top: 0; | ||
height: 100%; | ||
width: 0; | ||
border-left: 2px solid; | ||
} | ||
|
||
.actionLabel { | ||
display: flex !important; | ||
align-items: center; | ||
justify-content: center; | ||
width: 48px; | ||
height: 48px; | ||
color: rgb(255, 255, 255); | ||
font-size: 24px !important; | ||
} |
This file contains 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,40 @@ | ||
import "@vscode/codicons/dist/codicon.css"; | ||
|
||
import classNames from "classnames"; | ||
|
||
import styles from "./activity-bar.module.css"; | ||
|
||
export type ActivityBarProps = { | ||
checked: number; | ||
items: string[]; | ||
onClick: (index: number) => void; | ||
}; | ||
|
||
export const ActivityBar = ({ checked, items, onClick }: ActivityBarProps) => { | ||
return ( | ||
<div className={styles.activitybar}> | ||
<div className={styles.content}> | ||
<ul className={styles.actionsContainer}> | ||
{items.map((item, index) => ( | ||
<li | ||
key={index} | ||
className={classNames(styles.actionItem, { | ||
[styles.checked]: index === checked, | ||
})} | ||
> | ||
<a | ||
className={classNames( | ||
`codicon codicon-${item}`, | ||
styles.actionLabel | ||
)} | ||
onClick={() => { | ||
onClick(index); | ||
}} | ||
></a> | ||
</li> | ||
))} | ||
</ul> | ||
</div> | ||
</div> | ||
); | ||
}; |
This file contains 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,48 @@ | ||
@font-face { | ||
src: url("../seti.woff") format("woff"); | ||
font-family: "seti"; | ||
font-weight: normal; | ||
font-style: normal; | ||
font-display: block; | ||
} | ||
|
||
.allotment { | ||
overflow-x: scroll; | ||
} | ||
|
||
.editorGroupContainer { | ||
height: 100%; | ||
} | ||
|
||
.title { | ||
background-color: rgb(37, 37, 38); | ||
} | ||
|
||
.editorContainer { | ||
background-color: rgb(30, 30, 30); | ||
} | ||
|
||
.iconLabel { | ||
display: flex; | ||
line-height: 35px; | ||
} | ||
|
||
.iconLabel::before { | ||
color: #519aba; | ||
background-image: unset; | ||
font-family: "seti"; | ||
font-size: 150%; | ||
} | ||
|
||
.typescriptReactFileIcon::before { | ||
content: "\E099"; | ||
} | ||
|
||
.cssLangFileIcon::before { | ||
content: "\E01D"; | ||
} | ||
|
||
.labelName { | ||
cursor: pointer; | ||
font-size: 13px; | ||
} |
Oops, something went wrong.