-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Copy over changes from studiorack-app
- Loading branch information
Showing
13 changed files
with
377 additions
and
31 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import styles from '../styles/components/tabs.module.css'; | ||
import { PluginType, PluginTypes, ProjectType, ProjectTypes } from '@studiorack/core'; | ||
import { useRouter } from 'next/router'; | ||
import { ChangeEvent } from 'react'; | ||
|
||
type TabsProps = { | ||
items: PluginTypes | ProjectTypes; | ||
}; | ||
|
||
type TabsItem = PluginType | ProjectType; | ||
type TabsKey = keyof PluginTypes & keyof ProjectTypes; | ||
|
||
const Tabs = ({ items }: TabsProps) => { | ||
const router = useRouter(); | ||
let category: string = (router.query['category'] as string) || 'all'; | ||
const search: string = (router.query['search'] as string) || ''; | ||
|
||
const isSelected = (path: string) => { | ||
return category === path ? 'selected' : ''; | ||
}; | ||
|
||
const onSearch = (event: ChangeEvent) => { | ||
const el: HTMLInputElement = event.target as HTMLInputElement; | ||
router.query['search'] = el.value ? el.value.toLowerCase() : ''; | ||
router.push({ | ||
pathname: router.pathname, | ||
query: router.query, | ||
}); | ||
}; | ||
|
||
const selectCategory = (event: any) => { | ||
category = (event.target as HTMLTextAreaElement).getAttribute('data-category') || ''; | ||
router.query['category'] = category || ''; | ||
router.push({ | ||
pathname: router.pathname, | ||
query: router.query, | ||
}); | ||
}; | ||
|
||
return ( | ||
<div className={styles.tabs}> | ||
<ul className={styles.tabsCategory}> | ||
<li> | ||
<a data-category="all" onClick={selectCategory} className={isSelected('all')}> | ||
All | ||
</a> | ||
</li> | ||
{Object.keys(items).map((key: string, index: number) => ( | ||
<li key={`${key}-${index}`}> | ||
<a data-category={key} onClick={selectCategory} className={isSelected(key)}> | ||
{(items[key as TabsKey] as TabsItem).name} | ||
</a> | ||
</li> | ||
))} | ||
<li> | ||
<input | ||
className={styles.tabsSearch} | ||
placeholder="Keyword" | ||
type="search" | ||
id="search" | ||
name="search" | ||
value={search} | ||
onChange={onSearch} | ||
/> | ||
</li> | ||
</ul> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Tabs; |
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,19 @@ | ||
import { ProjectTypes, ProjectVersion } from '@studiorack/core'; | ||
import { NextRouter } from 'next/router'; | ||
|
||
export function filterProjects(projectTypes: ProjectTypes, projects: ProjectVersion[], router: NextRouter) { | ||
const category: string = (router.query['category'] as string) || 'all'; | ||
const search: string = router.query['search'] as string; | ||
return projects.filter((project: ProjectVersion) => { | ||
if (category !== 'all' && project.type?.ext !== projectTypes[category as keyof ProjectTypes]?.ext) return false; | ||
if ( | ||
search && | ||
project.id?.toLowerCase().indexOf(search.toLowerCase()) === -1 && | ||
project.name?.toLowerCase().indexOf(search.toLowerCase()) === -1 && | ||
project.description?.toLowerCase().indexOf(search.toLowerCase()) === -1 && | ||
project.tags?.indexOf(search.toLowerCase()) === -1 | ||
) | ||
return false; | ||
return project; | ||
}); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { configDefaults, ConfigList, projectsGetLocal, ProjectVersion, ProjectVersionLocal } from '@studiorack/core'; | ||
import { useRouter } from 'next/router'; | ||
import Layout from '../../components/layout'; | ||
import Head from 'next/head'; | ||
import { GetStaticProps } from 'next'; | ||
import { pageTitle } from '../../lib/utils'; | ||
import List from '../../components/list'; | ||
import { filterProjects } from '../../lib/project'; | ||
|
||
type ProjectsProps = { | ||
projects: ProjectVersion[]; | ||
}; | ||
|
||
const Projects = ({ projects }: ProjectsProps) => { | ||
const router = useRouter(); | ||
const projectTypes = configDefaults('appFolder', 'pluginFolder', 'presetFolder', 'projectFolder').projectTypes; | ||
const projectsFiltered: ProjectVersion[] = filterProjects(projectTypes, projects, router); | ||
return ( | ||
<Layout> | ||
<Head> | ||
<title>{pageTitle(['Projects'])}</title> | ||
</Head> | ||
<List items={projectsFiltered} type="projects" title="Projects" filters={false} tabs={projectTypes} /> | ||
</Layout> | ||
); | ||
}; | ||
|
||
export default Projects; | ||
|
||
export const getStaticProps: GetStaticProps = async () => { | ||
let projects = await projectsGetLocal(); | ||
projects = projects.sort(function (a: ProjectVersionLocal, b: ProjectVersionLocal) { | ||
return a.name.localeCompare(b.name); | ||
}); | ||
return { | ||
props: { | ||
projects, | ||
}, | ||
}; | ||
}; |
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,88 @@ | ||
.pluginLink, | ||
.pluginLink:hover { | ||
border-bottom: none; | ||
padding-bottom: 0; | ||
transition: none; | ||
} | ||
|
||
.plugin { | ||
background-color: #111; | ||
border-radius: 0.5rem; | ||
cursor: pointer; | ||
max-height: 200px; | ||
overflow: hidden; | ||
padding: 1.5rem 1.5rem 0 1.5rem; | ||
margin-bottom: 1rem; | ||
transition: background-color 0.25s ease-out; | ||
} | ||
|
||
.plugin:hover { | ||
background-color: #222; | ||
} | ||
|
||
.pluginDetails { | ||
margin-bottom: 1.5rem; | ||
} | ||
|
||
.pluginHead { | ||
display: flex; | ||
justify-content: space-between; | ||
} | ||
|
||
.pluginTitle { | ||
flex-shrink: 1; | ||
margin: 0; | ||
} | ||
|
||
.pluginButton, | ||
.pluginButtonInstalled { | ||
background-color: #0d51ff; | ||
border-radius: 4px; | ||
display: flex; | ||
flex-shrink: 0; | ||
height: 15px; | ||
justify-content: center; | ||
margin-left: 0.5rem; | ||
padding: 8px; | ||
width: 15px; | ||
} | ||
|
||
.pluginButtonIcon, | ||
.projectButtonIcon { | ||
max-width: 100%; | ||
} | ||
|
||
.pluginButtonInstalled { | ||
background-color: #48ad6a; | ||
} | ||
|
||
.projectButton { | ||
margin-left: 0.5rem; | ||
width: 30px; | ||
} | ||
|
||
.pluginVersion { | ||
color: #666; | ||
font-size: 0.75rem; | ||
} | ||
|
||
.pluginTags { | ||
display: flex; | ||
list-style: none; | ||
margin: 0; | ||
padding: 0; | ||
} | ||
|
||
.pluginIcon { | ||
margin-right: 0.5rem; | ||
width: 15px; | ||
} | ||
|
||
.pluginTag { | ||
margin-right: 0.25rem; | ||
} | ||
|
||
.pluginImage { | ||
display: cover; | ||
width: 100%; | ||
} |
Oops, something went wrong.