mirror of
https://github.com/urbit/shrub.git
synced 2024-12-19 16:51:42 +03:00
ui: style tabs
also rename join --> useDark; clean up extraneous logging statements
This commit is contained in:
parent
fe1ece47d8
commit
438e6d4df9
@ -1,13 +1,12 @@
|
|||||||
/* eslint-disable max-lines */
|
|
||||||
import React, {
|
import React, {
|
||||||
useCallback, useEffect
|
useCallback, useEffect
|
||||||
} from 'react';
|
} from 'react';
|
||||||
|
|
||||||
import useTermState, { Sessions } from './state';
|
import useTermState from './state';
|
||||||
import { useDark } from './join';
|
import { useDark } from './lib/useDark';
|
||||||
import api from './api';
|
import api from './api';
|
||||||
|
|
||||||
import { Reset, _dark, _light } from '@tlon/indigo-react';
|
import { _dark, _light } from '@tlon/indigo-react';
|
||||||
|
|
||||||
import 'xterm/css/xterm.css';
|
import 'xterm/css/xterm.css';
|
||||||
|
|
||||||
@ -83,11 +82,10 @@ export default function TermApp(props: TermAppProps) {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ThemeProvider theme={dark ? _dark : _light}>
|
<ThemeProvider theme={dark ? _dark : _light}>
|
||||||
<Reset />
|
|
||||||
<Tabs />
|
<Tabs />
|
||||||
<div className="buffer-container">
|
<div className="buffer-container">
|
||||||
{names.map(name => {
|
{names.map(name => {
|
||||||
return <Buffer name={name} selected={name === selected} />;
|
return <Buffer name={name} selected={name === selected} dark={dark}/>;
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
</ThemeProvider>
|
</ThemeProvider>
|
@ -12,8 +12,7 @@ import useTermState from './state';
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Box, Col } from '@tlon/indigo-react';
|
import { Box, Col } from '@tlon/indigo-react';
|
||||||
import { makeTheme } from './lib/theme';
|
import { makeTheme } from './lib/theme';
|
||||||
import { useDark } from './join';
|
import { showBlit, csi } from './lib/blit';
|
||||||
import { showBlit, csi, showSlog } from './lib/blit';
|
|
||||||
|
|
||||||
const termConfig: ITerminalOptions = {
|
const termConfig: ITerminalOptions = {
|
||||||
logLevel: 'warn',
|
logLevel: 'warn',
|
||||||
@ -138,11 +137,11 @@ const onInput = (name: string, session: Session, e: string) => {
|
|||||||
interface BufferProps {
|
interface BufferProps {
|
||||||
name: string,
|
name: string,
|
||||||
selected: boolean,
|
selected: boolean,
|
||||||
|
dark: boolean,
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function Buffer({ name, selected }: BufferProps) {
|
export default function Buffer({ name, selected, dark }: BufferProps) {
|
||||||
const container = useRef<HTMLDivElement>(null);
|
const container = useRef<HTMLDivElement>(null);
|
||||||
const dark = useDark();
|
|
||||||
|
|
||||||
const session: Session = useTermState(s => s.sessions[name]);
|
const session: Session = useTermState(s => s.sessions[name]);
|
||||||
|
|
||||||
@ -210,10 +209,6 @@ export default function Buffer({ name, selected }: BufferProps) {
|
|||||||
let newContainer = containerRef || container.current;
|
let newContainer = containerRef || container.current;
|
||||||
if(session && newContainer) {
|
if(session && newContainer) {
|
||||||
container.current = newContainer;
|
container.current = newContainer;
|
||||||
console.log('newcont', newContainer);
|
|
||||||
// session.term.open(newContainer);
|
|
||||||
} else {
|
|
||||||
console.log('kaboom', session);
|
|
||||||
}
|
}
|
||||||
}, [session]);
|
}, [session]);
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ export const Tab = ( { session, name }: TabProps ) => {
|
|||||||
}, [session]);
|
}, [session]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={'tab ' + isSelected ? 'selected' : ''}>
|
<div className={'tab ' + (isSelected ? 'selected' : '')}>
|
||||||
<a className='session-name' onClick={onClick}>
|
<a className='session-name' onClick={onClick}>
|
||||||
{session?.hasBell ? '🔔 ' : ''}
|
{session?.hasBell ? '🔔 ' : ''}
|
||||||
{name === DEFAULT_SESSION ? 'default' : name}
|
{name === DEFAULT_SESSION ? 'default' : name}
|
||||||
|
@ -29,7 +29,7 @@ export const Tabs = () => {
|
|||||||
<Tab session={sessions[n]} name={n} key={i} />
|
<Tab session={sessions[n]} name={n} key={i} />
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
<button onClick={onAddClick}>+</button>
|
<button className="tab" onClick={onAddClick}>+</button>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -29,32 +29,38 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.buffer-container {
|
.buffer-container {
|
||||||
height: calc(100% - 33px);
|
height: calc(100% - 40px);
|
||||||
}
|
}
|
||||||
|
|
||||||
div.tabs {
|
div.tabs {
|
||||||
height: 33px;
|
height: 40px;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-flow: row nowrap;
|
flex-flow: row nowrap;
|
||||||
justify-content: flex-start;
|
justify-content: flex-start;
|
||||||
padding: 5px 0;
|
padding: 5px 5px 0 5px;
|
||||||
border-bottom: 1px solid black;
|
border-bottom: 1px solid black;
|
||||||
|
background-color: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.tabs > * {
|
div.tabs > * {
|
||||||
margin-left: 5px;
|
margin-left: 5px;
|
||||||
margin-right: 5px;
|
margin-right: 5px;
|
||||||
border: solid 1px black;
|
border: solid 1px black;
|
||||||
padding: 7px;
|
padding: 10px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.tab {
|
div.tab, button.tab {
|
||||||
text-align: center;
|
margin-bottom: -1px; /** To overlay the selected tab on the tabs container bottom border */
|
||||||
/* display: flex;
|
border-top-left-radius: 5px;
|
||||||
flex-flow: row nowrap;
|
border-top-right-radius: 5px;
|
||||||
align-items: center;
|
font-family: monospace;
|
||||||
justify-content: space-between; */
|
font-size: 14px;
|
||||||
|
line-height: 18px;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.tabs > div.selected {
|
||||||
|
border-bottom: white solid 1px;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.tabs > div.selected > a.session-name {
|
div.tabs > div.selected > a.session-name {
|
||||||
@ -65,6 +71,23 @@
|
|||||||
padding: 5px;
|
padding: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
div.tabs {
|
||||||
|
background-color: rgb(26, 26, 26);
|
||||||
|
color: rgba(255, 255, 255, 0.9);
|
||||||
|
border-bottom-color: rgba(255, 255, 255, 0.9);
|
||||||
|
}
|
||||||
|
|
||||||
|
div.tab, button.tab {
|
||||||
|
background-color: rgb(26, 26, 26);
|
||||||
|
color: rgba(255, 255, 255, 0.9);
|
||||||
|
border-color: rgba(255, 255, 255, 0.9);
|
||||||
|
}
|
||||||
|
|
||||||
|
div.tabs > div.selected {
|
||||||
|
border-bottom: black solid 1px;
|
||||||
|
}
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { useTheme } from './settings';
|
import useTermState from '../state';
|
||||||
import useTermState from './state';
|
|
||||||
|
|
||||||
export function useDark() {
|
export function useDark() {
|
||||||
const [osDark, setOsDark] = useState(false);
|
const [osDark, setOsDark] = useState(false);
|
||||||
@ -11,12 +10,11 @@ export function useDark() {
|
|||||||
setOsDark(e.matches);
|
setOsDark(e.matches);
|
||||||
};
|
};
|
||||||
setOsDark(themeWatcher.matches);
|
setOsDark(themeWatcher.matches);
|
||||||
themeWatcher.addListener(update);
|
themeWatcher.addEventListener('change', update);
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
themeWatcher.removeListener(update);
|
themeWatcher.removeEventListener('change', update);
|
||||||
}
|
}
|
||||||
|
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const theme = useTermState(s => s.theme);
|
const theme = useTermState(s => s.theme);
|
Loading…
Reference in New Issue
Block a user