Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-laplante committed May 17, 2024
1 parent b3017d6 commit 87ea132
Show file tree
Hide file tree
Showing 8 changed files with 465 additions and 514 deletions.
639 changes: 219 additions & 420 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"@babel/preset-env": "^7.24.5",
"@babel/preset-react": "^7.24.1",
"@babel/preset-typescript": "^7.24.1",
"@mantine/core": "^7.9.1",
"@pyodide/webpack-plugin": "^1.3.2",
"@shopify/react-web-worker": "^5.0.17",
"@types/jquery": "^3.5.30",
Expand Down Expand Up @@ -48,7 +47,6 @@
"mini-css-extract-plugin": "^2.9.0",
"postcss": "^8.4.38",
"postcss-loader": "^7.3.4",
"postcss-preset-mantine": "^1.15.0",
"postcss-simple-vars": "^7.0.1",
"react": "^18.3.1",
"react-ace": "^11.0.1",
Expand All @@ -71,21 +69,23 @@
"webpack-virtual-modules": "^0.6.1"
},
"dependencies": {
"@mantine/core": "^7.9.1",
"@mantine/hooks": "^7.9.1",
"@types/react": "^18.2.77",
"@types/react-dom": "^18.2.25",
"ace-builds": "^1.33.2",
"axios": "^1.6.8",
"bootstrap": "^5.3.3",
"classnames": "^2.5.1",
"flexlayout-react": "^0.7.15",
"immer": "^10.1.1",
"jquery": "^3.7.1",
"jquery.terminal": "^2.41.2",
"pyodide": "^0.25.1",
"react": "^18.2.0",
"react-ace": "^11.0.1",
"react-bootstrap": "^2.10.2",
"react-dom": "^18.2.0",
"react-error-boundary": "^4.0.13",
"sass-rem": "^4.0.0",
"swr": "^2.2.5",
"use-immer": "^0.9.0"
}
Expand Down
14 changes: 0 additions & 14 deletions postcss.config.cjs

This file was deleted.

171 changes: 108 additions & 63 deletions src/main/components/App.tsx
Original file line number Diff line number Diff line change
@@ -1,46 +1,112 @@
import React, {useEffect, useMemo, useRef} from "react";

import {AppShell, Burger, createTheme, Group, MantineColorsTuple, MantineProvider} from '@mantine/core';
import {useDisclosure} from "@mantine/hooks";
import {PlaygroundTerminal} from "./PlaygroundTerminal";
import AceEditor from "react-ace";
import BitBakeMode from "../BitBakeMode";
import {createWorkerFactory, useWorker} from "@shopify/react-web-worker";
import {Layout, Model} from 'flexlayout-react';
import 'flexlayout-react/style/light.css';
import {Button, ButtonGroup, Container, Dropdown, DropdownButton, Navbar} from "react-bootstrap";
import ButtonToolbar from 'react-bootstrap/ButtonToolbar'
import {IJsonModel} from "flexlayout-react/src/model/IJsonModel";

const myColor: MantineColorsTuple = [
'#e4f8ff',
'#d3eafc',
'#a9d1f1',
'#7db7e6',
'#58a1dd',
'#3f94d8',
'#2f8dd6',
'#1e7abe',
'#0c6cac',
'#005e99'
];

const theme = createTheme({
colors: {
myColor,

const json: IJsonModel = {
global: {},
borders: [],
layout: {
type: "row",
weight: 100,
children: [
{
type: "tabset",
weight: 50,
children: [
{
type: "tab",
name: "Editor",
component: "test",
}
]
},
{
type: "tabset",
weight: 50,
children: [
{
type: "tab",
name: "Terminal",
component: "button",
}
]
},
]
}
});
};

const createWorker = createWorkerFactory(() => import('../../pyodide-worker/worker'));
const model = Model.fromJson(json);

const wat = (str: string) => {
console.error(str);
}

export const App: React.FC = () => {
const [opened, {toggle}] = useDisclosure();
const EditorWrapper = () => {

const editor = useRef(null);

useEffect(() => {
editor.current.editor.getSession().setMode(new BitBakeMode());
}, []);

return (
<div>
{/*<ButtonToolbar>*/}
{/* <ButtonGroup>*/}
{/* <Button>1</Button>*/}
{/* <Button>2</Button>*/}

{/* <DropdownButton as={ButtonGroup} title="Dropdown" id="bg-nested-dropdown">*/}
{/* <Dropdown.Item eventKey="1">Dropdown link</Dropdown.Item>*/}
{/* <Dropdown.Item eventKey="2">Dropdown link</Dropdown.Item>*/}
{/* </DropdownButton>*/}
{/* </ButtonGroup>*/}
{/*</ButtonToolbar>*/}
<AceEditor
ref={editor}
mode="text"
theme="github"
editorProps={{$blockScrolling: true}}
/>
</div>
);
}

function Wat2() {

const factory = (node) => {
const component = node.getComponent();

if (component === "button") {
return <PlaygroundTerminal/>;
} else if (component === "test") {
return <EditorWrapper/>
}
}

return (
<div style={{position: "relative", height: "calc(100vh - 56px)"}}>
<Layout
model={model}
factory={factory}
/>
</div>
);
}


const createWorker = createWorkerFactory(() => import('../../pyodide-worker/worker'));

const wat = (str: string) => {
console.error(str);
}

export const App: React.FC = () => {
const worker = useWorker(createWorker);

useEffect(() => {
Expand All @@ -51,42 +117,21 @@ export const App: React.FC = () => {
}, [worker])

return (
<MantineProvider theme={theme}>
<AppShell
header={{height: 60}}
navbar={{
width: 300,
breakpoint: 'sm',
collapsed: {mobile: !opened},
}}
padding="md"
>
<AppShell.Header>
<Group h="100%" px="md">
<Burger

opened={opened}
onClick={toggle}
hiddenFrom="sm"
size="sm"
/>
OK
</Group>
</AppShell.Header>

<AppShell.Navbar p="md">Navbar</AppShell.Navbar>

<AppShell.Main>
{/*<PlaygroundTerminal/>*/}
<AceEditor
ref={editor}
mode="text"
theme="github"
editorProps={{ $blockScrolling: true }}
/>,
</AppShell.Main>
</AppShell>

</MantineProvider>
<div>
<Navbar className="bg-body-tertiary">
<Container fluid>
<Navbar.Brand href="#home" className="align-items-center d-flex">
<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" fill="currentColor"
className="bi bi-play-fill" viewBox="0 0 16 16">
<path
d="m11.596 8.697-6.363 3.692c-.54.313-1.233-.066-1.233-.697V4.308c0-.63.692-1.01 1.233-.696l6.363 3.692a.802.802 0 0 1 0 1.393"/>
</svg>
{' '}
BB Datastore Playground
</Navbar.Brand>
</Container>
</Navbar>
<Wat2/>
</div>
);
};
70 changes: 70 additions & 0 deletions src/main/components/Header.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import React, { useState } from 'react';
import { Container, Anchor, Group, Burger, Box } from '@mantine/core';
import { useDisclosure } from '@mantine/hooks';
import classes from '../../styles/DoubleHeader.module.scss';
import {AppShell} from '@mantine/core';

const userLinks = [
{ link: '#', label: 'Privacy & Security' },
{ link: '#', label: 'Account settings' },
{ link: '#', label: 'Support options' },
];

const mainLinks = [
{ link: '#', label: 'Book a demo' },
{ link: '#', label: 'Documentation' },
{ link: '#', label: 'Community' },
{ link: '#', label: 'Academy' },
{ link: '#', label: 'Forums' },
];

export function DoubleHeader() {
const [opened, { toggle }] = useDisclosure(false);
const [active, setActive] = useState(0);

const mainItems = mainLinks.map((item, index) => (
<Anchor<'a'>
href={item.link}
key={item.label}
className={classes.mainLink}
data-active={index === active || undefined}
onClick={(event) => {
event.preventDefault();
setActive(index);
}}
>
{item.label}
</Anchor>
));

const secondaryItems = userLinks.map((item) => (
<Anchor
href={item.link}
key={item.label}
onClick={(event) => event.preventDefault()}
className={classes.secondaryLink}
>
{item.label}
</Anchor>
));

return (<AppShell.Header className={classes.header}>
<Container className={classes.inner}>
OK
<Box className={classes.links} visibleFrom="sm">
<Group justify="flex-end">{secondaryItems}</Group>
<Group gap={0} justify="flex-end" className={classes.mainLinks}>
{mainItems}
</Group>
</Box>
<Burger
opened={opened}
onClick={toggle}
className={classes.burger}
size="sm"
hiddenFrom="sm"
/>
</Container>
</AppShell.Header>
);
}
2 changes: 1 addition & 1 deletion src/main/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import '@mantine/core/styles.css';
import 'bootstrap/dist/css/bootstrap.min.css';

import {createRoot} from "react-dom/client";
import {App} from "./components/App";
Expand Down
61 changes: 61 additions & 0 deletions src/styles/DoubleHeader.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
@use "~sass-rem" as rem-convert;

.header {
height: rem-convert.convert(84px);
margin-bottom: rem-convert.convert(120px);
background-color: var(--mantine-color-body);
border-bottom: rem-convert.convert(1px) solid light-dark(var(--mantine-color-gray-3), var(--mantine-color-dark-4));
}

.inner {
height: rem-convert.convert(84px);
display: flex;
align-items: center;
justify-content: space-between;
}

.links {
padding-top: var(--mantine-spacing-lg);
height: rem-convert.convert(84px);
display: flex;
flex-direction: column;
justify-content: space-between;
}

.mainLinks {
margin-right: calc(var(--mantine-spacing-sm) * -1);
}

.mainLink {
text-transform: uppercase;
font-size: var(--mantine-font-size-xs);
color: light-dark(var(--mantine-color-gray-6), var(--mantine-color-dark-1));
padding: rem-convert.convert(7px) var(--mantine-spacing-sm);
font-weight: 700;
border-bottom: rem-convert.convert(2px) solid transparent;
transition:
border-color 100ms ease,
color 100ms ease;

@mixin hover {
color: light-dark(var(--mantine-color-black), var(--mantine-color-white));
text-decoration: none;
}

&[data-active] {
color: light-dark(var(--mantine-color-black), var(--mantine-color-white));
border-bottom-color: var(--mantine-color-blue-6);
}
}

.secondaryLink {
color: light-dark(var(--mantine-color-gray-6), var(--mantine-color-dark-1));
font-size: var(--mantine-font-size-xs);
text-transform: uppercase;
transition: color 100ms ease;

@mixin hover {
color: light-dark(var(--mantine-color-black), var(--mantine-color-white));
text-decoration: none;
}
}
Loading

0 comments on commit 87ea132

Please sign in to comment.