Skip to content

Commit ded9050

Browse files
committed
Style selected file system object
1 parent 337b639 commit ded9050

2 files changed

Lines changed: 16 additions & 6 deletions

File tree

src/programs/FileBrowser/FileBrowser.scss

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
}
7272

7373
&__favorite {
74+
border-radius: 10px;
7475
padding: 6px 10px;
7576
box-sizing: border-box;
7677
box-shadow: 2px 2px 4px rgb(0, 0, 0, 0);
@@ -91,18 +92,23 @@
9192
overflow-y: scroll;
9293
display: grid;
9394
gap: 20px;
94-
grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
95+
grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
9596
grid-template-rows: min-content;
9697
box-sizing: border-box;
9798
&__item {
9899
width: 100%;
100+
padding: 10px;
101+
overflow-wrap: break-word;
102+
word-break: normal;
103+
box-sizing: border-box;
99104
aspect-ratio: 1/1;
100105
height: auto;
101106
display: flex;
102107
justify-content: center;
103108
align-items: center;
104109
flex-direction: column;
105110
gap: 10px;
111+
border-radius: 10px;
106112

107113
&-icon {
108114
height: 80%;

src/programs/FileBrowser/FileBrowser.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,17 +78,21 @@ function SideBar({ favorites, openFSObject, currentPath }: SideBarProps) {
7878
}
7979

8080
interface MainContentProps {
81-
diContents: Record<string, FSObject>;
81+
dirContents: Record<string, FSObject>;
8282
openFSObject: (fsObject: FSObject) => void;
8383
}
8484

85-
function MainContent({ diContents, openFSObject }: MainContentProps) {
85+
function MainContent({ dirContents, openFSObject }: MainContentProps) {
86+
const [selected, setSelected] = useState<string>("");
8687
return (
8788
<div className="file-browser__main-content">
88-
{Object.values<FSObject>(diContents).map((fsObject) => (
89+
{Object.values<FSObject>(dirContents).map((fsObject) => (
8990
<div
90-
className="file-browser__main-content__item"
91+
className={`file-browser__main-content__item ${
92+
fsObject.path === selected ? "active" : ""
93+
}`}
9194
onDoubleClick={() => openFSObject(fsObject)}
95+
onClick={() => setSelected(fsObject.path)}
9296
key={fsObject.path}
9397
>
9498
{isFSDirectory(fsObject) ? (
@@ -141,7 +145,7 @@ function FileBrowser({ path = defaultPath }: FileBrowserProps) {
141145
/>
142146

143147
<MainContent
144-
diContents={fs.currentDirectory.contents}
148+
dirContents={fs.currentDirectory.contents}
145149
openFSObject={fs.navToObject}
146150
/>
147151
<div className="file-browser__bottom-bar"></div>

0 commit comments

Comments
 (0)