Skip to content

Commit da705f7

Browse files
committed
add initial workspace selection screen
1 parent bb9b04d commit da705f7

File tree

8 files changed

+134
-31
lines changed

8 files changed

+134
-31
lines changed

minimap-app/.taurignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/www-src/

minimap-app/tauri.conf.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"$schema": "node_modules/@tauri-apps/cli/schema.json",
33
"build": {
44
"beforeBuildCommand": "npm run build",
5-
"beforeDevCommand": "npm run dev",
5+
"beforeDevCommand": "npm run tauri:icon && npm run build && npm run dev",
66
"devPath": "http://localhost:3891",
77
"distDir": "build"
88
},

minimap-app/www-src/js/component/Button.mjs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import sig from 'minimap/js/util/sig.mjs';
44
import css from 'minimap/js/util/css.mjs';
55
import disable from 'minimap/js/util/disable.mjs';
66

7-
import Link from 'minimap/js/component/Link.mjs';
8-
97
import * as C from './Button.css';
108

119
export default ({
@@ -24,17 +22,3 @@ export default ({
2422
{children}
2523
</button>
2624
);
27-
28-
export const LinkButton = ({
29-
disabled = false,
30-
className,
31-
children,
32-
...props
33-
}) => (
34-
<Link
35-
className={css(C.root, C.link, className, sig(disabled) && C.disabled)}
36-
{...props}
37-
>
38-
{children}
39-
</Link>
40-
);

minimap-app/www-src/js/global.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ body {
6161
scrollbar-color: var(--mm-scrollbar, var(--mm-border)) transparent;
6262
scrollbar-width: thin;
6363
font-family: 'Inter', sans-serif;
64-
font-size: 0.9rem;
64+
font-size: 1rem;
6565
font-weight: 500;
6666
}
6767

minimap-app/www-src/js/index.mjs

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,34 @@ import S from 's-js';
33

44
import I from 'minimap/js/util/i18n.mjs';
55
import systemTheme from 'minimap/js/util/s-theme.mjs';
6-
import { signal as configSignal } from 'minimap/js/util/tauri-config-signal.mjs';
6+
import * as configSignal from 'minimap/js/util/tauri-config-signal.mjs';
77

88
import Root from 'minimap/js/module/Root.mjs';
99
import ErrorView from 'minimap/js/module/ErrorView.mjs';
10+
import WorkspaceSelect from 'minimap/js/module/WorkspaceSelect.mjs';
1011

1112
import './reset.css';
1213
import './global.css';
1314
import './theme.css';
1415

15-
const XFormString = {
16-
stringify: v => v ?? '',
17-
parse: v => v ?? ''
18-
};
19-
2016
S.root(() => {
2117
const Minimap = {
2218
errorMessage: S.value(),
23-
theme: configSignal('theme', 'system'),
24-
langOverride: configSignal('lang')
19+
theme: configSignal.value('theme', 'system'),
20+
langOverride: configSignal.value('lang'),
21+
savedWorkspaces: configSignal.array('workspaces', [
22+
{
23+
type: 'git',
24+
remote:
25+
'file:///C:/Users/Anonymous/AppData/Roaming/minimap/test-repo'
26+
},
27+
{ type: 'mem', author: 'Max Mustermann', email: 'max@example.com' },
28+
{
29+
type: 'git',
30+
remote:
31+
'file:///C:/Users/Anonymous/AppData/Roaming/minimap/test-repo'
32+
}
33+
])
2534
};
2635

2736
if (typeof window !== 'undefined') window.Minimap = Minimap;
@@ -42,10 +51,9 @@ S.root(() => {
4251

4352
// Calculate the current main view
4453
const currentView = S(() => {
45-
if (Minimap.errorMessage()) return <ErrorView {...{ Minimap }} />;
54+
if (Minimap.errorMessage()) return <ErrorView {...Minimap} />;
4655

47-
// TODO Add your default view here.
48-
return () => <div>Hello, world!</div>;
56+
return () => <WorkspaceSelect {...Minimap} />;
4957
});
5058

5159
// Attach!
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
.root {
2+
border: 1px solid var(--mm-border);
3+
box-sizing: border-box;
4+
display: flex;
5+
flex-direction: column;
6+
gap: 1rem;
7+
}
8+
9+
.root > h1 {
10+
text-transform: uppercase;
11+
font-size: 1.5rem;
12+
font-weight: 700;
13+
padding: 1rem;
14+
box-sizing: border-box;
15+
background: var(--mm-text);
16+
color: var(--mm-bg);
17+
}
18+
19+
.workspaceList {
20+
display: flex;
21+
flex-direction: column;
22+
padding: 0.5rem;
23+
}
24+
25+
.workspace {
26+
display: flex;
27+
flex-direction: column;
28+
padding: 1rem 0.5rem;
29+
box-sizing: border-box;
30+
border: none;
31+
background: transparent;
32+
cursor: pointer;
33+
color: var(--mm-text);
34+
}
35+
36+
.workspace:not(:last-child) {
37+
border-bottom: 1px solid var(--mm-border);
38+
}
39+
40+
.workspace:hover {
41+
background: var(--mm-invert-bg, var(--mm-accent));
42+
color: var(--mm-invert, var(--mm-text));
43+
}
44+
45+
.workspaceType {
46+
font-size: 1.25rem;
47+
font-weight: 700;
48+
margin-bottom: 0.5rem;
49+
}
50+
51+
.property > strong {
52+
display: inline-block;
53+
width: 9ch;
54+
font-weight: 900;
55+
text-align: left;
56+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import * as Surplus from 'surplus';
2+
3+
import I from 'minimap/js/util/i18n.mjs';
4+
5+
import * as C from './WorkspaceSelect.css';
6+
7+
const TYPE_TAGS = {
8+
git: ({ remote }) => [
9+
<div className={C.workspaceType}>{I`Git Repository`}</div>,
10+
<div className={C.property}>
11+
<strong>{I`Remote:`}</strong> {remote}
12+
</div>
13+
],
14+
mem: ({ author, email }) => [
15+
<div className={C.workspaceType}>{I`In-Memory`}</div>,
16+
<div className={C.property}>
17+
<strong>{I`Author:`}</strong> {author}
18+
</div>,
19+
<div className={C.property}>
20+
<strong>{I`E-Mail:`}</strong> {email}
21+
</div>
22+
]
23+
};
24+
25+
export default ({ savedWorkspaces }) => {
26+
return (
27+
<div className={C.root}>
28+
<h1>{I`Select a workspace`}</h1>
29+
<div className={C.workspaceList}>
30+
{savedWorkspaces.map(workspace => {
31+
const TypeTag = TYPE_TAGS[workspace.type];
32+
return (
33+
<button className={C.workspace}>
34+
<TypeTag {...workspace} />
35+
</button>
36+
);
37+
})}
38+
</div>
39+
</div>
40+
);
41+
};

minimap-app/www-src/js/util/tauri-config-signal.mjs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import S from 's-js';
2+
import Sarray from 's-array';
23
import { invoke } from '@tauri-apps/api/tauri';
34

45
const currentConfig = S.value();
@@ -11,8 +12,8 @@ export async function save() {
1112
await invoke('config_store', { config: S.sample(currentConfig) });
1213
}
1314

14-
export function signal(name, init) {
15-
const v = S.value(S.sample(currentConfig)[name] ?? init);
15+
function setup(name, init, fn) {
16+
const v = fn(S.sample(currentConfig)[name] ?? init);
1617
S.on(
1718
currentConfig,
1819
() => {
@@ -30,4 +31,16 @@ export function signal(name, init) {
3031
return v;
3132
}
3233

34+
export function value(name, init) {
35+
return setup(name, init, S.value);
36+
}
37+
38+
export function data(name, init) {
39+
return setup(name, init, S.data);
40+
}
41+
42+
export function array(name, init) {
43+
return setup(name, init, Sarray);
44+
}
45+
3346
await refresh();

0 commit comments

Comments
 (0)