Skip to content

Commit

Permalink
feat: make long filename scrollable (#149)
Browse files Browse the repository at this point in the history
* feat: make long file name scrollable

* make it optional

---------

Co-authored-by: Andy Hsu <i@nn.ci>
  • Loading branch information
fengkx and xhofe authored Feb 23, 2024
1 parent d0e8acf commit 1fcd962
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/lang/en/home.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@
"show_sidebar_options": {
"none": "None",
"visible": "Visible"
}
},
"filename_scrollable": "Filename scrollable"
},
"package_download": {
"current_status": "Current Status",
Expand Down
11 changes: 9 additions & 2 deletions src/pages/home/folder/ListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { usePath, useUtil } from "~/hooks"
import {
checkboxOpen,
getMainColor,
local,
OrderBy,
selectAll,
selectIndex,
Expand Down Expand Up @@ -34,6 +35,7 @@ export const ListItem = (props: { obj: StoreObj; index: number }) => {
}
const { setPathAs } = usePath()
const { show } = useContextMenu({ id: 1 })
const filenameScrollable = () => local["filename_scrollable"] === "true"
return (
<Motion.div
initial={{ opacity: 0, scale: 0.95 }}
Expand Down Expand Up @@ -102,8 +104,13 @@ export const ListItem = (props: { obj: StoreObj; index: number }) => {
class="name"
css={{
whiteSpace: "nowrap",
overflow: "hidden",
textOverflow: "ellipsis",
"overflow-x": filenameScrollable() ? "auto" : "hidden",
textOverflow: filenameScrollable() ? "unset" : "ellipsis",
"scrollbar-width": "none", // firefox
"&::-webkit-scrollbar": {
// webkit
display: "none",
},
}}
title={props.obj.name}
>
Expand Down
9 changes: 9 additions & 0 deletions src/pages/home/toolbar/LocalSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
SelectTrigger,
SelectValue,
VStack,
Switch as HopeSwitch,
} from "@hope-ui/solid"
import { For, Match, onCleanup, Switch } from "solid-js"
import { SwitchLanguageWhite, SwitchColorMode } from "~/components"
Expand Down Expand Up @@ -71,6 +72,14 @@ function LocalSettingEdit(props: LocalSetting) {
</SelectContent>
</Select>
</Match>
<Match when={props.type === "boolean"}>
<HopeSwitch
defaultChecked={local[props.key] === "true"}
onChange={(e) => {
setLocal(props.key, e.currentTarget.checked.toString())
}}
/>
</Match>
</Switch>
</FormControl>
)
Expand Down
5 changes: 5 additions & 0 deletions src/store/local_settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ export const initialLocalSettings = [
default: "90",
type: "number",
},
{
key: "filename_scrollable",
default: "false",
type: "boolean",
},
]
export type LocalSetting = (typeof initialLocalSettings)[number]
for (const setting of initialLocalSettings) {
Expand Down

0 comments on commit 1fcd962

Please sign in to comment.