Skip to content

Commit f8a09d3

Browse files
committed
feat(layout): Implement AppBar layout component
1 parent 9c90528 commit f8a09d3

File tree

10 files changed

+112
-18
lines changed

10 files changed

+112
-18
lines changed

apps/solid/src/App.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,17 @@ import '@spuxx/browser-utils/themes';
44
import { For, type Component } from 'solid-js';
55
import './styles/index.css';
66
import { routes } from './routes/routes';
7+
import { AppLayout } from './layout/app.layout';
78

89
const App: Component = () => {
910
return (
10-
<main>
11+
<AppLayout>
1112
<Router>
1213
<For each={routes}>
1314
{(route) => <Route path={route.path} component={route.component} />}
1415
</For>
1516
</Router>
16-
</main>
17+
</AppLayout>
1718
);
1819
};
1920

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { AppBar, Button } from '@spuxx/solid';
2+
3+
export const BottomAppBar = () => {
4+
return (
5+
<AppBar
6+
position="bottom"
7+
center={
8+
<a href="https://spuxx.dev">
9+
<Button variant="colored" color="text-default" rounded>
10+
Made with ❤️ by spuxx
11+
</Button>
12+
</a>
13+
}
14+
/>
15+
);
16+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { AppBar, Button } from '@spuxx/solid';
2+
3+
export const TopAppBar = () => {
4+
return (
5+
<AppBar
6+
left={<Button icon="mdi:menu" title="Menu" variant="colored" color="text-default" rounded />}
7+
center={
8+
<a href="/">
9+
<Button title="Home" variant="colored" color="text-default" rounded>
10+
@spuxx/solid
11+
</Button>
12+
</a>
13+
}
14+
right={
15+
<a href="https://github.com/spuxx-dev/jslibs" target="_blank">
16+
<Button icon="mdi:github" title="GitHub" variant="colored" color="text-default" rounded />
17+
</a>
18+
}
19+
/>
20+
);
21+
};

apps/solid/src/layout/app.layout.tsx

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { Component, ParentProps } from 'solid-js';
2+
import { TopAppBar } from './app-bars/top-app-bar.component';
3+
import { BottomAppBar } from './app-bars/bottom-app-bar.component';
4+
5+
export const AppLayout: Component<ParentProps> = (props) => {
6+
return (
7+
<>
8+
<TopAppBar />
9+
<main>{props.children}</main>
10+
<BottomAppBar />
11+
</>
12+
);
13+
};

apps/solid/src/routes/components/control/input.route.tsx

+13-16
Original file line numberDiff line numberDiff line change
@@ -84,18 +84,12 @@ export const InputRoute: Component = () => {
8484
<For each={variants}>
8585
{(variant) => (
8686
<>
87-
<Input
88-
label="Username"
89-
class="m-1"
90-
icon="mdi:account"
91-
attrs={{ type: 'text' }}
92-
variant={variant}
93-
/>
87+
<Input label="Username" class="m-1" icon="mdi:account" variant={variant} />
9488
<Input
9589
label="Password"
9690
class="m-1"
9791
icon="mdi:lock"
98-
attrs={{ type: 'password' }}
92+
type="password"
9993
variant={variant}
10094
/>
10195
</>
@@ -108,24 +102,27 @@ export const InputRoute: Component = () => {
108102
<For each={variants}>
109103
{(variant) => (
110104
<>
111-
<Input
112-
label="Username"
113-
class="m-1"
114-
icon="mdi:account"
115-
attrs={{ type: 'text' }}
116-
variant={variant}
117-
/>
105+
<Input label="Username" class="m-1" icon="mdi:account" variant={variant} />
118106
<Input
119107
label="Password"
120108
class="m-1"
121109
icon="mdi:lock"
122-
attrs={{ type: 'password' }}
110+
type="password"
123111
variant={variant}
124112
/>
125113
</>
126114
)}
127115
</For>
128116
</Container>
117+
<Container variant="contained" color="surface">
118+
<Heading level={2}>On Surface</Heading>
119+
<Divider color="gradient" />
120+
<For each={variants}>
121+
{(variant) => (
122+
<Input label="Username" class="m-1" icon="mdi:account" variant={variant} />
123+
)}
124+
</For>
125+
</Container>
129126
</Container>
130127
</>
131128
);

packages/solid/src/components/layout/app-bar/app-bar.component.test.tsx

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { AppBarProps, attributes, classNames } from '@src/main';
2+
import { Component } from 'solid-js';
3+
4+
export const AppBar: Component<AppBarProps> = (props) => {
5+
const { position = 'top' } = props;
6+
7+
return (
8+
<header
9+
{...classNames('spx-app-bar', props.class)}
10+
{...attributes(props)}
11+
spx-position={position}
12+
>
13+
<div {...classNames('spx-app-bar-left')}>{props.left}</div>
14+
<div {...classNames('spx-app-bar-center')}>{props.center}</div>
15+
<div {...classNames('spx-app-bar-right')}>{props.right}</div>
16+
</header>
17+
);
18+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { ComponentProps } from '@src/main';
2+
import { JSX } from 'solid-js/jsx-runtime';
3+
4+
/**
5+
* The AppBar component properties.
6+
*/
7+
export interface AppBarProps extends ComponentProps<JSX.HTMLAttributes<HTMLElement>> {
8+
/**
9+
* The position of the app bar.
10+
* @default 'top'
11+
*/
12+
position?: 'top' | 'bottom';
13+
/**
14+
* The left-side content of the app bar.
15+
*/
16+
left?: JSX.Element;
17+
/**
18+
* The center content of the app bar.
19+
*/
20+
center?: JSX.Element;
21+
/**
22+
* The right-side content of the app bar.
23+
*/
24+
right?: JSX.Element;
25+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from './app-bar.component';
2+
export * from './app-bar.types';

packages/solid/src/main.ts

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export * from './types/public';
66

77
export * from './components/control/button';
88
export * from './components/control/input';
9+
export * from './components/layout/app-bar';
910
export * from './components/layout/container';
1011
export * from './components/layout/divider';
1112
export * from './components/typography/heading';

0 commit comments

Comments
 (0)