Skip to content

Commit b4b63f2

Browse files
committed
feat: Users can now create new lists via the side nav
1 parent 717adad commit b4b63f2

File tree

7 files changed

+52
-15
lines changed

7 files changed

+52
-15
lines changed

apps/spuxx-client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"@solidjs/router": "0.15.3",
2424
"@spuxx/browser-utils": "1.8.0",
2525
"@spuxx/js-utils": "2.0.1",
26-
"@spuxx/solid": "1.5.0",
26+
"@spuxx/solid": "1.5.1",
2727
"iconify-icon": "2.3.0",
2828
"solid-js": "^1.9.5"
2929
}

apps/spuxx-client/src/App.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,10 @@ import '@spuxx/browser-utils/themes';
33
import './styles/index.css';
44

55
import { type Component } from 'solid-js';
6-
import { AppLayout } from './layout';
76
import { AppRouter } from './router/router';
87

98
const App: Component = () => {
10-
return (
11-
<AppLayout>
12-
<AppRouter />
13-
</AppLayout>
14-
);
9+
return <AppRouter />;
1510
};
1611

1712
export default App;

apps/spuxx-client/src/assets/locales/de.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,13 @@ main:
33
page:
44
login:
55
login-via-oidc: Anmelden via auth.spuxx.dev
6+
lists:
7+
component:
8+
create-list-button:
9+
title: Neue Liste
10+
new-list-name: Neue Liste
611

712
layout:
813
side-nav:
914
lists:
10-
title: Listen
15+
title: Listen
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { Api } from '@/services/api';
2+
import { NewList } from '@/services/api/lists/lists.types';
3+
import { useNavigate } from '@solidjs/router';
4+
import { intl } from '@spuxx/js-utils';
5+
import { Button, Layout } from '@spuxx/solid';
6+
import { Component, createSignal } from 'solid-js';
7+
8+
export const CreateListButton: Component = () => {
9+
const [loading, setLoading] = createSignal(false);
10+
const navigate = useNavigate();
11+
12+
const handleClick = async () => {
13+
const list: NewList = {
14+
name: intl('lists.component.create-list-button.new-list-name'),
15+
};
16+
setLoading(true);
17+
const request = Api.createList({ args: { list } });
18+
const { id } = await request.promise;
19+
setLoading(false);
20+
navigate(`/lists/${id}`);
21+
Layout.closeSidebarOnMobile();
22+
};
23+
24+
return (
25+
<Button
26+
variant="colored"
27+
color="text-default"
28+
onClick={handleClick}
29+
icon="mdi:plus"
30+
loading={loading()}
31+
>
32+
{intl('lists.component.create-list-button.title')}
33+
</Button>
34+
);
35+
};

apps/spuxx-client/src/layout/side-nav/side-nav-lists.component.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { CreateListButton } from '@/features/lists/components/create-list-button.component';
12
import { createListsStore } from '@/stores/lists.store';
23
import { intl } from '@spuxx/js-utils';
34
import { ButtonLink, Layout, Sidebar } from '@spuxx/solid';
@@ -18,7 +19,6 @@ export const SideNavLists: Component = () => {
1819
<For each={store.lists}>
1920
{(list) => (
2021
<ButtonLink
21-
class="decoration-transsparent"
2222
href={`/lists/${list.id}`}
2323
variant="colored"
2424
color="text-default"
@@ -30,6 +30,7 @@ export const SideNavLists: Component = () => {
3030
</ButtonLink>
3131
)}
3232
</For>
33+
<CreateListButton />
3334
</Sidebar.Group>
3435
);
3536
};

apps/spuxx-client/src/router/router.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { Route, Router } from '@solidjs/router';
22
import { For, type ParentComponent } from 'solid-js';
33
import { routes } from './routes';
4+
import { AppLayout } from '@/layout';
45

56
export const AppRouter: ParentComponent = () => {
67
return (
7-
<Router>
8+
<Router root={AppLayout}>
89
<For each={routes}>
910
{(route) => <Route path={route.path} component={route.component} />}
1011
</For>

pnpm-lock.yaml

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)