Skip to content

Commit

Permalink
Reuse components
Browse files Browse the repository at this point in the history
  • Loading branch information
undyingwraith committed Jan 21, 2025
1 parent f37842f commit c246458
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
9 changes: 7 additions & 2 deletions packages/ui/src/components/atoms/Spacer.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import React from 'react';

export function Spacer() {
return <div style={{ flexGrow: 1 }} />;
interface ISpacerProps {
width?: number | string;
height?: number | string;
}

export function Spacer(props: ISpacerProps) {
return <div style={{ flexGrow: 1, minWidth: props.width ?? 0, minHeight: props.height ?? 0 }} />;
}
6 changes: 3 additions & 3 deletions packages/ui/src/components/organisms/LibraryAppBar.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { AppBar, Box, Button, ButtonGroup, Toolbar } from "@mui/material";
import { AppBar, Button, ButtonGroup, Toolbar } from "@mui/material";
import { Signal, useComputed, useSignal } from "@preact/signals-react";
import React from "react";
import { useHotkey } from '../../hooks';
import { useTranslation } from '../../hooks/useTranslation';
import { TextInput } from '../atoms';
import { Spacer, TextInput } from '../atoms';
import { Display } from "../pages/LibraryManager";

// Icons
Expand Down Expand Up @@ -55,7 +55,7 @@ export function LibraryAppBar(props: { query: Signal<string>, display: Signal<Di
inputRef={searchFieldRef}
variant={'standard'}
/>
<Box sx={{ flexGrow: 1, minWidth: 75 }} />
<Spacer width={75} />
{displayButtons}
</Toolbar>
</AppBar>
Expand Down
4 changes: 2 additions & 2 deletions packages/ui/src/services/AppbarButtonService.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Box } from '@mui/material';
import { computed, Signal } from '@preact/signals-react';
import { Spacer } from '../components/atoms';
import React from 'react';

export interface IAppbarButtonOptions {
Expand All @@ -22,7 +22,7 @@ export class AppbarButtonService {

public appbarButtons = computed(() => (<>
{this.buttons.value.filter(b => b.position === 'start').map(b => b.component)}
<Box sx={{ flexGrow: 1 }} />
<Spacer />
{this.buttons.value.filter(b => b.position === 'end').map(b => b.component)}
</>));

Expand Down

0 comments on commit c246458

Please sign in to comment.