Skip to content

Commit a60db93

Browse files
authored
add filters for asset explorer (#1056)
* add filters for asset explorer * use decentraland/oddish-action * move 'Filter' to enum * move IAsset type determination to fn
1 parent f85e704 commit a60db93

File tree

14 files changed

+419
-121
lines changed

14 files changed

+419
-121
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ jobs:
115115
run: make install
116116

117117
- name: update version of packages/@dcl/sdk/package.json, this version will be used for all packages
118-
uses: menduz/oddish-action@master
118+
uses: decentraland/oddish-action@master
119119
with:
120120
cwd: ./packages/@dcl/sdk
121121
deterministic-snapshot: true
@@ -136,7 +136,7 @@ jobs:
136136

137137
- name: publish @dcl/js-runtime package
138138
id: publish_dcl_js_runtime
139-
uses: menduz/oddish-action@master
139+
uses: decentraland/oddish-action@master
140140
with:
141141
registry-url: 'https://registry.npmjs.org'
142142
access: public
@@ -158,7 +158,7 @@ jobs:
158158
AWS_SECRET_ACCESS_KEY: ${{ secrets.SDK_TEAM_AWS_SECRET }}
159159

160160
- name: publish @dcl/ecs package
161-
uses: menduz/oddish-action@master
161+
uses: decentraland/oddish-action@master
162162
id: publish_ecs
163163
with:
164164
registry-url: 'https://registry.npmjs.org'
@@ -194,7 +194,7 @@ jobs:
194194

195195
- name: publish @dcl/react-ecs package
196196
id: publish_dcl_react_ecs
197-
uses: menduz/oddish-action@master
197+
uses: decentraland/oddish-action@master
198198
with:
199199
registry-url: 'https://registry.npmjs.org'
200200
access: public
@@ -216,7 +216,7 @@ jobs:
216216
AWS_SECRET_ACCESS_KEY: ${{ secrets.SDK_TEAM_AWS_SECRET }}
217217

218218
- name: publish @dcl/inspector package
219-
uses: menduz/oddish-action@master
219+
uses: decentraland/oddish-action@master
220220
id: publish_decentraland_inspector
221221
with:
222222
registry-url: 'https://registry.npmjs.org'
@@ -253,7 +253,7 @@ jobs:
253253
INSPECTOR_URL: ${{ secrets.SDK_TEAM_S3_BASE_URL }}/${{ steps.publish_decentraland_inspector.outputs.s3-bucket-key }}
254254

255255
- name: publish @dcl/sdk-commands package
256-
uses: menduz/oddish-action@master
256+
uses: decentraland/oddish-action@master
257257
id: publish_decentraland_sdk_commands
258258
with:
259259
registry-url: 'https://registry.npmjs.org'
@@ -297,7 +297,7 @@ jobs:
297297
SDK_COMMANDS_S3_URL: ${{ secrets.SDK_TEAM_S3_BASE_URL }}/${{ steps.publish_decentraland_sdk_commands.outputs.s3-bucket-key }}
298298

299299
- name: publish @dcl/sdk package
300-
uses: menduz/oddish-action@master
300+
uses: decentraland/oddish-action@master
301301
id: publish_decentraland_sdk
302302
with:
303303
registry-url: 'https://registry.npmjs.org'
@@ -326,7 +326,7 @@ jobs:
326326
AWS_SECRET_ACCESS_KEY: ${{ secrets.SDK_TEAM_AWS_SECRET }}
327327

328328
- name: publish @dcl/playground-assets package
329-
uses: menduz/oddish-action@master
329+
uses: decentraland/oddish-action@master
330330
id: publish_playground_assets
331331
with:
332332
registry-url: 'https://registry.npmjs.org'

packages/@dcl/inspector/src/components/ImportAsset/ImportAsset.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@
1010
height: 100%;
1111
}
1212

13+
.ImportAsset .children {
14+
height: 100%;
15+
}
16+
17+
.ImportAsset .children.hidden {
18+
display: none;
19+
}
20+
1321
.ImportAssetHover {
1422
padding: 8px;
1523
}

packages/@dcl/inspector/src/components/ImportAsset/ImportAsset.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { PropsWithChildren, useCallback, useEffect, useState } from 'react'
1+
import React, { PropsWithChildren, useCallback, useEffect, useState, useMemo } from 'react'
22
import cx from 'classnames'
33
import { HiOutlineUpload } from 'react-icons/hi'
44

@@ -117,6 +117,8 @@ const ImportAsset = React.forwardRef<InputRef, PropsWithChildren<PropTypes>>(({
117117
[assets]
118118
)
119119

120+
const isImportActive = useMemo(() => !files.length && isHover, [files, isHover])
121+
120122
return (
121123
<div className={cx('ImportAsset', { ImportAssetHover: isHover })}>
122124
<FileInput
@@ -127,16 +129,15 @@ const ImportAsset = React.forwardRef<InputRef, PropsWithChildren<PropTypes>>(({
127129
accept={ACCEPTED_FILE_TYPES}
128130
multiple
129131
>
130-
{!files.length && isHover ? (
132+
{isImportActive && (
131133
<>
132134
<div className="upload-icon">
133135
<HiOutlineUpload />
134136
</div>
135137
<span className="text">Drop {ACCEPTED_FILE_TYPES_STR} files</span>
136138
</>
137-
) : (
138-
children
139139
)}
140+
<div className={cx('children', { hidden: isImportActive })}>{children}</div>
140141
<Modal
141142
isOpen={!!files.length}
142143
onRequestClose={handleCloseModal}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
.ProjectFilters {
2+
display: flex;
3+
flex-direction: column;
4+
padding: 10px;
5+
height: calc(100% - 30px);
6+
overflow-y: auto;
7+
user-select: none;
8+
}
9+
10+
.ProjectFilters .filter {
11+
display: flex;
12+
flex-direction: column;
13+
align-items: center;
14+
padding: 10px;
15+
cursor: pointer;
16+
margin-bottom: 10px;
17+
border-radius: 8px;
18+
}
19+
20+
.ProjectFilters .filter:last-child {
21+
margin: 0;
22+
}
23+
24+
.ProjectFilters .filter:hover,
25+
.ProjectFilters .filter.active {
26+
background-color: var(--accent-blue-07);
27+
}
28+
29+
.ProjectFilters .filter svg {
30+
width: 20px;
31+
height: 20px;
32+
margin-bottom: 4px;
33+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import { useCallback } from 'react'
2+
import cx from 'classnames'
3+
import { AiOutlineSound as AudioIcon } from 'react-icons/ai'
4+
import { IoIosImage as ImageIcon } from 'react-icons/io'
5+
import { IoCubeOutline as ModelIcon, IoVideocamOutline as VideoIcon } from 'react-icons/io5'
6+
import { FaFile as AssetIcon } from 'react-icons/fa'
7+
import { GoClock as RecentIcon } from 'react-icons/go'
8+
9+
import { PropTypes, Filter } from './types'
10+
11+
import './Filters.css'
12+
13+
export function Filters({ filters, active, onClick }: PropTypes) {
14+
const getFilter = useCallback((type: Filter) => {
15+
switch (type) {
16+
case Filter.All:
17+
return { title: 'All Assets', icon: AssetIcon }
18+
case Filter.Recents:
19+
return { title: 'Recents', icon: RecentIcon }
20+
case Filter.Models:
21+
return { title: 'Models', icon: ModelIcon }
22+
case Filter.Images:
23+
return { title: 'Images', icon: ImageIcon }
24+
case Filter.Audio:
25+
return { title: 'Audio', icon: AudioIcon }
26+
case Filter.Video:
27+
return { title: 'Video', icon: VideoIcon }
28+
default:
29+
return { title: 'Other', icon: AssetIcon }
30+
}
31+
}, [])
32+
33+
const handleClick = useCallback((type: Filter) => () => onClick(type), [])
34+
35+
return (
36+
<div className="ProjectFilters">
37+
{filters.map(($) => {
38+
const _filter = getFilter($)
39+
return (
40+
<div className={cx('filter', { active: $ === active })} onClick={handleClick($)}>
41+
{<_filter.icon />}
42+
{_filter.title}
43+
</div>
44+
)
45+
})}
46+
</div>
47+
)
48+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { Filters } from './Filters'
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
export enum Filter {
2+
All = 'all',
3+
Recents = 'recents',
4+
Models = 'models',
5+
Images = 'images',
6+
Video = 'video',
7+
Audio = 'audio',
8+
Other = 'other'
9+
}
10+
11+
export type PropTypes = {
12+
filters: Filter[]
13+
active?: Filter
14+
onClick(type: Filter): void
15+
}

packages/@dcl/inspector/src/components/ProjectAssetExplorer/ProjectAssetExplorer.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
}
55

66
.ProjectView > .Tree-View {
7-
border-right: 0.1px solid;
8-
border-color: var(--border-gray);
7+
border-right: 0.1px solid var(--border-gray);
8+
border-left: 0.1px solid var(--border-gray);
99
}
1010

1111
.ProjectView > .Tree-View > .with-context-menu > .editor-assets-tree {

0 commit comments

Comments
 (0)