-
-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
183 additions
and
17 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
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,23 @@ | ||
import { useMemo } from 'react'; | ||
import { createRoot } from 'react-dom/client'; | ||
import LuminoBox from './../jupyter/lumino/LuminoBox'; | ||
import LuminoWidget from './lumino/LuminoWidget'; | ||
|
||
export const LuminoExample = () => { | ||
const luminoWidget = useMemo(() => new LuminoWidget(), []); | ||
return ( | ||
<LuminoBox height="100px"> | ||
{luminoWidget.panel} | ||
</LuminoBox> | ||
) | ||
} | ||
|
||
const div = document.createElement('div'); | ||
document.body.appendChild(div); | ||
const root = createRoot(div) | ||
|
||
root.render( | ||
<> | ||
<LuminoExample/> | ||
</> | ||
); |
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,34 @@ | ||
.content { | ||
min-width: 50px; | ||
min-height: 50px; | ||
display: block; | ||
padding: 8px; | ||
border: 1px solid #C0C0C0; | ||
border-top: none; | ||
box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2); | ||
} | ||
|
||
.content > div { | ||
border: 1px solid #505050; | ||
overflow: auto; | ||
} | ||
|
||
.content input { | ||
margin: 8px; | ||
} | ||
|
||
.red > div { | ||
background: #E74C3C; | ||
} | ||
|
||
.yellow > div { | ||
background: #F1C40F; | ||
} | ||
|
||
.green > div { | ||
background: #27AE60; | ||
} | ||
|
||
.blue > div { | ||
background: #3498DB; | ||
} |
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,90 @@ | ||
import { Message } from '@lumino/messaging'; | ||
import { DockPanel, BoxPanel, Widget } from '@lumino/widgets'; | ||
|
||
import '@lumino/default-theme/style/index.css'; | ||
|
||
import './LuminoWidget.css' | ||
|
||
class LuminoWidget extends Widget { | ||
|
||
constructor(name: string) { | ||
super({ node: LuminoWidget.createNode() }); | ||
this.setFlag(Widget.Flag.DisallowLayout); | ||
this.addClass('content'); | ||
this.addClass(name.toLowerCase()); | ||
this.title.label = name; | ||
this.title.closable = true; | ||
this.title.caption = `Long description for: ${name}`; | ||
} | ||
|
||
static createNode(): HTMLElement { | ||
let node = document.createElement('div'); | ||
let content = document.createElement('div'); | ||
let input = document.createElement('input'); | ||
input.placeholder = 'Placeholder...'; | ||
content.appendChild(input); | ||
node.appendChild(content); | ||
return node; | ||
} | ||
|
||
get inputNode(): HTMLInputElement { | ||
return this.node.getElementsByTagName('input')[0] as HTMLInputElement; | ||
} | ||
|
||
protected onActivateRequest(msg: Message): void { | ||
if (this.isAttached) { | ||
this.inputNode.focus(); | ||
} | ||
} | ||
|
||
} | ||
|
||
class SimpleAdapter { | ||
private simplePanel: BoxPanel; | ||
|
||
constructor() { | ||
const colors = [ | ||
'Red', | ||
'Yellow', | ||
'Green', | ||
'Blue' | ||
]; | ||
|
||
this.simplePanel = new BoxPanel(); | ||
this.simplePanel.id = 'simple-panel'; | ||
// this.simplePanel.direction = 'top-to-bottom'; | ||
this.simplePanel.spacing = 0; | ||
|
||
// Dock Panel | ||
const r1 = new LuminoWidget('Red'); | ||
const b1 = new LuminoWidget('Blue'); | ||
const g1 = new LuminoWidget('Green'); | ||
const y1 = new LuminoWidget('Yellow'); | ||
const r2 = new LuminoWidget('Red'); | ||
const b2 = new LuminoWidget('Blue'); | ||
|
||
const dockPanel = new DockPanel(); | ||
dockPanel.addWidget(r1); | ||
dockPanel.addWidget(b1, { mode: 'split-right', ref: r1 }); | ||
dockPanel.addWidget(y1, { mode: 'split-bottom', ref: b1 }); | ||
dockPanel.addWidget(g1, { mode: 'split-left', ref: y1 }); | ||
dockPanel.addWidget(r2, { ref: b1 }); | ||
dockPanel.addWidget(b2, { mode: 'split-right', ref: y1 }); | ||
dockPanel.id = 'simple-dock-panel'; | ||
|
||
this.simplePanel.addWidget(dockPanel); | ||
|
||
for (let i = 0; i < 20; i++) { | ||
const c = new LuminoWidget(colors[Math.floor(Math.random() * 4)]); | ||
this.simplePanel.addWidget(c); | ||
} | ||
|
||
} | ||
|
||
get panel(): BoxPanel { | ||
return this.simplePanel; | ||
} | ||
|
||
} | ||
|
||
export default SimpleAdapter; |
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
2 changes: 1 addition & 1 deletion
2
...src/jupyter/lumino/IPyWidgetsAttached.tsx → ...jupyter/ipywidgets/IPyWidgetsAttached.tsx
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