-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #88 from Team-BTMC/feature/sidebar
New UI 2
- Loading branch information
Showing
67 changed files
with
2,061 additions
and
885 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
src/renderer/src/components/dropdown-list/DropdownList.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
31
src/renderer/src/components/dropdown-list/DropdownListItem.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
15 changes: 0 additions & 15 deletions
15
src/renderer/src/components/dropdown/DropdownSelectTrigger.tsx
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
})} | ||
/> | ||
); | ||
}; |
Oops, something went wrong.