Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update sidebar #88

Merged
merged 74 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from 67 commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
0099c4e
- Add rovering focus index
duduBTW Oct 19, 2024
40324ee
Merge branch 'master' of https://github.com/Team-BTMC/osu-radio into …
duduBTW Oct 19, 2024
9283822
- Add home and end support to rovering focus group
duduBTW Oct 19, 2024
a68b689
- Remove old roving focus group component
duduBTW Oct 19, 2024
de9dac5
- Add new tabs component
duduBTW Oct 19, 2024
bb0519f
- Remove queue modal
duduBTW Oct 19, 2024
94a2751
- Remove sticky headers.
duduBTW Oct 19, 2024
950aa15
- Add button square size
duduBTW Oct 19, 2024
4487b21
Merge branch 'master' of https://github.com/Team-BTMC/osu-radio into …
duduBTW Oct 19, 2024
c4f2e01
Fix settings page padding
duduBTW Oct 19, 2024
ba6e9a5
- fix
duduBTW Oct 20, 2024
b9d31b3
update sidebar design
duduBTW Oct 20, 2024
e944e87
- sidebar windows
duduBTW Oct 20, 2024
ce65ba2
- start mac sidebar
duduBTW Oct 20, 2024
1a6079a
- win
duduBTW Oct 20, 2024
3b8dbf2
- bg stroke
duduBTW Oct 21, 2024
9f78b98
- increase bg darkness
duduBTW Oct 21, 2024
e41a6d5
drag mac area
duduBTW Oct 21, 2024
f0656dc
drag only on mac area
duduBTW Oct 21, 2024
137e80f
- Update win styles
duduBTW Oct 21, 2024
d72177e
- aba
duduBTW Oct 21, 2024
40ab887
- Windows collapsable sidebar
duduBTW Oct 21, 2024
33d4934
ring-inset, song details bg
Tnixc Oct 21, 2024
d162959
- mac collapsable sidebar
duduBTW Oct 22, 2024
be8f87c
- More win padding changes
duduBTW Oct 24, 2024
95aa6c4
add cmd/ctrl+s keybind to toggle sidebar
hrfarmer Oct 25, 2024
836e6be
change keybinds
hrfarmer Oct 25, 2024
b3906b4
Merge branch 'master' of https://github.com/Team-BTMC/osu-radio into …
duduBTW Oct 25, 2024
6fdad66
- New filters component
duduBTW Oct 27, 2024
ed707bd
- Changes popover position when the trigger element changes size.
duduBTW Oct 27, 2024
a6fafd9
Merge branch 'temp/sidebar-animation-2' of https://github.com/Team-BT…
duduBTW Oct 27, 2024
40ade2d
- Add new tab indicator to the main page tabs.
duduBTW Oct 27, 2024
4722803
Merge branch 'master' of https://github.com/Team-BTMC/osu-radio into …
duduBTW Oct 27, 2024
3ccc665
- standardize win design
duduBTW Oct 28, 2024
b790983
- mac standard
duduBTW Oct 28, 2024
1c46960
- mac position
duduBTW Oct 29, 2024
d7a91fe
- Add default value to the list
duduBTW Oct 30, 2024
add155d
Merge branch 'feature/sidebar' of https://github.com/Team-BTMC/osu-ra…
duduBTW Oct 30, 2024
71b0f53
- Add popover stack.
duduBTW Nov 1, 2024
5674806
- Remove stack id when popup is closed.
duduBTW Nov 1, 2024
d0bb529
- Remove `console.log`
duduBTW Nov 1, 2024
c7c02fa
Merge branch 'master' of https://github.com/Team-BTMC/osu-radio into …
duduBTW Nov 1, 2024
e4b5dcf
- Removes dependecy on windows for the design
duduBTW Nov 1, 2024
b3727f4
- Disable filter button when the filter is collapsed
duduBTW Nov 1, 2024
5ff3f0f
- Add song item context menu mouse positin
duduBTW Nov 2, 2024
1b32f40
- Add "d" back to main page fixed
duduBTW Nov 2, 2024
aa5ec1e
- Move custom coords middlware up
duduBTW Nov 2, 2024
ecc4dbc
- Update song context menu popover position
duduBTW Nov 2, 2024
2398638
- Fix sidebar icon size
duduBTW Nov 2, 2024
7cff4b7
- Moved generic list styles to the `RawList` component
duduBTW Nov 2, 2024
3c5b55d
- Fix play next
duduBTW Nov 3, 2024
b5dcaf8
- Made focus styles global
duduBTW Nov 3, 2024
2baf4fb
- Improve tabs keyboard controls
duduBTW Nov 3, 2024
d072a68
- Improve tabs keyboard controls 2
duduBTW Nov 3, 2024
4e0d32e
- Improve tabs keyboard controls 3
duduBTW Nov 3, 2024
639ac74
- Improve tabs keyboard controls 4
duduBTW Nov 3, 2024
c9b5ec9
- Changed "red" color to not colide with the tailwind red
duduBTW Nov 3, 2024
656604b
- Fix focus outline when clicking with a mouse
duduBTW Nov 3, 2024
24c3d92
- Combine select and input styles
duduBTW Nov 3, 2024
005bd34
narrow sidebar
Tnixc Nov 4, 2024
f409671
Merge pull request #102 from Team-BTMC/narrow-sidebar
duduBTW Nov 7, 2024
7c7d766
fix windows sidebar icon position
duduBTW Nov 12, 2024
9380b5e
- Add resizable sidebar
duduBTW Nov 17, 2024
2cee343
- Update popover position on resize
duduBTW Nov 17, 2024
06a0b9f
- drag handle mac
duduBTW Nov 17, 2024
41130ef
- Add keyboard controls to resize handler
duduBTW Nov 18, 2024
1c8ff31
fix: make drag handler vertically centered
Tnixc Nov 19, 2024
1eb538d
Merge remote-tracking branch 'origin/master' into feature/sidebar
brw Nov 19, 2024
2197809
move PopoverAnchor to its own file
brw Nov 19, 2024
eca7194
fix sidebar resize handle again
Tnixc Nov 19, 2024
0507604
change top padding depending on os
brw Nov 19, 2024
60c5e18
add resizeObserver cleanup and move stackIds cleanup
brw Nov 19, 2024
2e789d2
remove unnecessary arrow function
brw Nov 19, 2024
652f076
rename resize handler function
brw Nov 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/@types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ export type System = {
// Settings table definition
export type Settings = {
volume: number;
sidebarWidth: number;
audioDeviceId: string;
osuSongsDir: string;
"window.width": number;
Expand Down
3 changes: 2 additions & 1 deletion src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ async function createWindow() {
show: false,
autoHideMenuBar: true,
titleBarStyle: "hidden",
minWidth: 500,
trafficLightPosition: {
x: 20,
y: 20,
y: 28,
},
icon: getIcon(),
webPreferences: {
Expand Down
49 changes: 33 additions & 16 deletions src/renderer/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import { Scenes } from "../../@types";
import NoticeContainer from "./components/notice/NoticeContainer";
import Popover from "./components/popover/Popover";
import "./keyboard-registers/initialize";
import { fetchOs, os, setOs } from "./lib/os";
import { TokenNamespace } from "./lib/tungsten/token";
import ErrorScene from "./scenes/ErrorScene";
import NoScene from "./scenes/NoScene";
import DirSelectScene from "./scenes/dir-select-scene/DirSelectScene";
import LoadingScene from "./scenes/loading-scene/LoadingScene";
import MainScene from "./scenes/main-scene/MainScene";
import type { JSX } from "solid-js";
import { createSignal, Match, onCleanup, onMount, Switch } from "solid-js";
import { createMemo, createSignal, Match, onCleanup, onMount, Show, Switch } from "solid-js";
import { sidebarWidth } from "./scenes/main-scene/main.utils";

export default function App(): JSX.Element {
const [scene, setScene] = createSignal<Scenes>("");
Expand All @@ -22,31 +26,44 @@ export default function App(): JSX.Element {
setScene(event.detail.scene);
};

onMount(() => {
onMount(async () => {
window.api.listen("changeScene", setScene);
window.addEventListener("changeScene", eventHandler);

// Sets current OS
setOs(await fetchOs());
});

onCleanup(() => {
window.api.removeListener("changeScene", setScene);
window.removeEventListener("changeScene", eventHandler);
});

const hasRequiredOptions = createMemo(() => {
return typeof os() !== "undefined" && typeof sidebarWidth() !== "undefined";
});

return (
<Switch fallback={<NoScene />}>
<Match when={scene() === "dir-select"}>
<DirSelectScene />
</Match>
<Match when={scene() === "main"}>
<MainScene />
</Match>
<Match when={scene() === "loading"}>
<LoadingScene />
</Match>
<Match when={scene() === "error"}>
<ErrorScene />
</Match>
</Switch>
<Show when={hasRequiredOptions()}>
<NoticeContainer />

<Switch fallback={<NoScene />}>
<Match when={scene() === "dir-select"}>
<DirSelectScene />
</Match>
<Match when={scene() === "main"}>
<MainScene />
</Match>
<Match when={scene() === "loading"}>
<LoadingScene />
</Match>
<Match when={scene() === "error"}>
<ErrorScene />
</Match>
</Switch>

<Popover.PortalMountStack />
</Show>
);
}

Expand Down
6 changes: 5 additions & 1 deletion src/renderer/src/components/InfiniteScroller.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,11 @@ const InfiniteScroller: Component<InfinityScrollerProps> = (props) => {
});

return (
<div class={"list flex flex-col gap-4 py-4"} ref={container} {...rest}>
<div
class="grid grid-cols-[repeat(auto-fit,_minmax(340px,_1fr))] gap-4 py-4 items-stretch"
ref={container}
{...rest}
>
<Show when={show() === true} fallback={props.fallback ?? <div>No items...</div>}>
<For each={elements()}>{(componentProps) => props.builder(componentProps)}</For>
</Show>
Expand Down
41 changes: 19 additions & 22 deletions src/renderer/src/components/button/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,27 @@
import { cva, type VariantProps } from "class-variance-authority";
import { Component, JSX, splitProps } from "solid-js";
import { twMerge } from "tailwind-merge";

const buttonStyles = cva(
["rounded-lg", "transition-colors", "duration-200", "ease-in-out", "font-medium"],
{
variants: {
variant: {
primary: "bg-text text-thick-material hover:bg-text/80",
secondary: "bg-surface text-text ring-inset ring-1 ring-stroke hover:bg-surface/40",
outlined: "bg-transparent border-stroke border-solid text-text hover:bg-surface",
ghost: "rounded-full border-none text-xl hover:bg-surface",
link: "bg-transparent text-text hover:underline text-decoration-2 underline-offset-2",
},
size: {
medium: "px-4 py-2",
large: "px-7 py-2.5",
icon: "grid place-items-center aspect-square size-9 p-1 -m-2",
},
const buttonStyles = cva(["rounded-lg transition-colors duration-200 ease font-medium"], {
variants: {
variant: {
primary: "bg-text text-thick-material hover:bg-text/80",
secondary: "bg-surface text-text hover:bg-surface/40 border-stroke border border-solid",
outlined: "bg-transparent border-stroke text-text hover:bg-surface border border-solid",
ghost: "border-transparent hover:bg-surface",
link: "bg-transparent text-text hover:underline text-decoration-2 underline-offset-2",
},
defaultVariants: {
variant: "primary",
size: "medium",
size: {
medium: "px-4 py-2",
large: "px-7 py-2.5",
icon: "grid place-items-center aspect-square size-9 p-1 -m-2",
square: "grid place-items-center aspect-square h-10",
},
},
);
defaultVariants: {
variant: "primary",
size: "medium",
},
});

type ButtonProps = JSX.ButtonHTMLAttributes<HTMLButtonElement> & VariantProps<typeof buttonStyles>;

Expand All @@ -33,7 +30,7 @@ const Button: Component<ButtonProps> = (props) => {

return (
<button
class={twMerge(buttonStyles({ variant: local.variant, size: local.size }), local.class)}
class={buttonStyles({ variant: local.variant, size: local.size, class: local.class })}
{...others}
>
{local.children}
Expand Down
65 changes: 65 additions & 0 deletions src/renderer/src/components/dropdown-list/DropdownList.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import DropdownListItem from "./DropdownListItem";
import { useRovingFocusGroup } from "@renderer/lib/roving-focus-group/rovingFocusGroup";
import { createContext, createSignal, JSX, ParentComponent, useContext } from "solid-js";
import { RawList } from "../raw-list/RawList";
import { TokenNamespace } from "@renderer/lib/tungsten/token";

export type Props = JSX.IntrinsicElements["div"];

export type Context = ReturnType<typeof useProviderValue>;
function useProviderValue() {
const namespace = new TokenNamespace();
let pointerLeaveTimeout: NodeJS.Timeout | undefined;

const [isHighlighted, setIsHighlighted] = createSignal(false);

const rovingFocusGroup = useRovingFocusGroup({
updateFocusOnHover: true,
onKeyUp: () => {
setIsHighlighted(true);
},
});

const handleItemPointerLeave = () => {
clearTimeout(pointerLeaveTimeout);
pointerLeaveTimeout = setTimeout(() => {
setIsHighlighted(false);
}, 60);
};

const handleItemPointerMove = () => {
setIsHighlighted(true);
};

return {
...rovingFocusGroup,
handleItemPointerMove,
isHighlighted,
handleItemPointerLeave,
namespace,
};
}

export const DropdownListContext = createContext<Context>();
const DropdownListRoot: ParentComponent<Props> = (props) => {
const value = useProviderValue();
return (
<DropdownListContext.Provider value={value}>
<RawList {...props} {...value.attrs} />
</DropdownListContext.Provider>
);
};

export function useDropdownList(): Context {
const state = useContext(DropdownListContext);
if (!state) {
throw new Error("useDropdownList needs to be used inisde of the `ListContext` component.");
}
return state;
}

const DropdownList = Object.assign(DropdownListRoot, {
Item: DropdownListItem,
});

export default DropdownList;
31 changes: 31 additions & 0 deletions src/renderer/src/components/dropdown-list/DropdownListItem.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { useDropdownList } from "./DropdownList";
import { Component, onCleanup } from "solid-js";
import { JSX } from "solid-js/jsx-runtime";
import { RawList } from "../raw-list/RawList";

export type Props = JSX.IntrinsicElements["button"];
const DropdownListItem: Component<Props> = (props) => {
const state = useDropdownList();
const value = state.namespace.create();
const { attrs, tabIndex, isSelected } = state.item(value, {
onPointerMove: state.handleItemPointerMove,
});

onCleanup(() => {
state.namespace.destroy(value);
});

return (
<RawList.Item
onPointerLeave={state.handleItemPointerLeave}
tabIndex={tabIndex()}
classList={{
"bg-overlay/30": state.isHighlighted() && isSelected(),
}}
{...attrs}
{...props}
/>
);
};

export default DropdownListItem;
19 changes: 0 additions & 19 deletions src/renderer/src/components/dropdown/Dropdown.tsx

This file was deleted.

18 changes: 0 additions & 18 deletions src/renderer/src/components/dropdown/DropdownList.tsx

This file was deleted.

16 changes: 0 additions & 16 deletions src/renderer/src/components/dropdown/DropdownListItem.tsx

This file was deleted.

15 changes: 0 additions & 15 deletions src/renderer/src/components/dropdown/DropdownSelectTrigger.tsx

This file was deleted.

15 changes: 0 additions & 15 deletions src/renderer/src/components/dropdown/DropdownTrigger.tsx

This file was deleted.

34 changes: 34 additions & 0 deletions src/renderer/src/components/input/Input.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { cva, VariantProps } from "class-variance-authority";
import { Component, JSX, splitProps } from "solid-js";

export const inputStyles = cva(
[
"ring-offset-background placeholder:text-subtext flex h-[42px] w-full rounded-lg px-3.5 py-2 disabled:cursor-not-allowed disabled:opacity-50 focus-visible:outline-none focus-visible:bg-surface",
],
{
variants: {
variant: {
primary: "",
outlined:
"border border-stroke bg-transparent border-solid block focus-visible:border-grey-400",
},
},
defaultVariants: {
variant: "outlined",
},
},
);

type Props = JSX.IntrinsicElements["input"] & VariantProps<typeof inputStyles>;
export const Input: Component<Props> = (_props) => {
const [props, rest] = splitProps(_props, ["class", "variant"]);
return (
<input
{...rest}
class={inputStyles({
variant: props.variant,
class: props.class,
})}
/>
);
};
Loading