Skip to content

Commit

Permalink
Changes to support app with same UI code
Browse files Browse the repository at this point in the history
  • Loading branch information
kmturley committed Sep 21, 2024
1 parent d750c71 commit 093c481
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 28 deletions.
12 changes: 7 additions & 5 deletions components/list.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import styles from '../styles/components/list.module.css';
import { PluginVersion, PluginVersionLocal } from '@studiorack/core';
import { PluginVersion, PluginVersionLocal, ProjectVersion, ProjectVersionLocal } from '@studiorack/core';
import Header from './header';
import Card from './card';
import Filters from './filters';
import Crumb from './crumb';

type ListProps = {
filters?: boolean;
plugins: PluginVersion[] | PluginVersionLocal[];
plugins: PluginVersion[] | PluginVersionLocal[] | ProjectVersion[] | ProjectVersionLocal[];
type: string;
title: string;
};
Expand All @@ -18,9 +18,11 @@ const List = ({ filters = true, plugins, type, title }: ListProps) => (
<Header title={title} count={plugins.length} />
{filters ? <Filters section={type} /> : ''}
<div className={styles.listGrid}>
{plugins.map((plugin: PluginVersion | PluginVersionLocal, pluginIndex: number) => (
<Card section={type} plugin={plugin} pluginIndex={pluginIndex} key={`${plugin.id}-${pluginIndex}`}></Card>
))}
{plugins.map(
(plugin: PluginVersion | PluginVersionLocal | ProjectVersion | ProjectVersionLocal, pluginIndex: number) => (
<Card section={type} plugin={plugin} pluginIndex={pluginIndex} key={`${plugin.id}-${pluginIndex}`}></Card>
),
)}
</div>
</section>
);
Expand Down
64 changes: 43 additions & 21 deletions components/navigation.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import styles from '../styles/components/navigation.module.css';
import { getBasePath, isSelected } from '../lib/path';
import { ELECTRON_APP } from '../lib/utils';

const Navigation = () => (
<div>
Expand All @@ -8,11 +9,20 @@ const Navigation = () => (
<span className={styles.navMenuNavIcn}></span>
</label>
<ul className={styles.navMenu}>
<li>
<a href={`${getBasePath()}/`} className={`${styles.navItem} ${isSelected('/')}`}>
Tools
</a>
</li>
{ELECTRON_APP ? (
<li>
<a href={`${getBasePath()}/projects`} className={`${styles.navItem} ${isSelected('/projects')}`}>
Projects
</a>
</li>
) : (
<li>
<a href={`${getBasePath()}/`} className={`${styles.navItem} ${isSelected('/')}`}>
Tools
</a>
</li>
)}

<li>
<a href={`${getBasePath()}/instruments`} className={`${styles.navItem} ${isSelected('/instruments')}`}>
Instruments
Expand All @@ -23,22 +33,34 @@ const Navigation = () => (
Effects
</a>
</li>
<li>
<a href={`${getBasePath()}/docs`} className={`${styles.navItem} ${isSelected('/docs')}`}>
Docs
</a>
</li>
<li>
<a href="https://discord.gg/9D94f98PxP" className={`${styles.navButton} button`} target="_blank">
Community
<img
className={styles.navButtonIcon}
src={`${getBasePath()}/images/icon-external-link.svg`}
alt="External link"
loading="lazy"
/>
</a>
</li>
{ELECTRON_APP ? (
<li>
<a href={`${getBasePath()}/settings`} className={`${styles.navItem} ${isSelected('/settings')}`}>
Settings
</a>
</li>
) : (
<li>
<a href={`${getBasePath()}/docs`} className={`${styles.navItem} ${isSelected('/docs')}`}>
Docs
</a>
</li>
)}
{!ELECTRON_APP ? (
<li>
<a href="https://discord.gg/9D94f98PxP" className={`${styles.navButton} button`} target="_blank">
Community
<img
className={styles.navButtonIcon}
src={`${getBasePath()}/images/icon-external-link.svg`}
alt="External link"
loading="lazy"
/>
</a>
</li>
) : (
''
)}
</ul>
</div>
);
Expand Down
3 changes: 2 additions & 1 deletion lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import { join } from 'path';
import matter from 'gray-matter';
import Doc from '../types/doc';
import { PluginEntry, PluginPack, pluginsGet, PluginVersion } from '@studiorack/core';
import { ELECTRON_APP } from './utils';

const docsDirectory = join(process.cwd(), '_docs');
const docsDirectory = ELECTRON_APP ? join(process.cwd(), 'renderer', '_docs') : join(process.cwd(), '_docs');

export function getDocSlugs() {
return fs.readdirSync(docsDirectory);
Expand Down
4 changes: 3 additions & 1 deletion lib/gtag.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { ELECTRON_APP } from './utils';

/* eslint-disable @typescript-eslint/no-explicit-any */
declare global {
interface Window {
Expand All @@ -12,7 +14,7 @@ interface AnalyticsProps {
value: string;
}

export const GA_TRACKING_ID = 'G-8XFFV4K2XH';
export const GA_TRACKING_ID = ELECTRON_APP ? 'G-70BC3S1DBZ' : 'G-8XFFV4K2XH';

// https://developers.google.com/analytics/devguides/collection/gtagjs/pages
export const pageview = (url: string) => {
Expand Down
2 changes: 2 additions & 0 deletions lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import slugify from 'slugify';
import { siteTitle } from '../components/layout';
import { PluginVersion, PluginVersionLocal } from '@studiorack/core';

export const ELECTRON_APP: boolean = false;

export function pageTitle(items: string[]) {
return (
siteTitle +
Expand Down
Binary file added public/images/plugin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/project.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions styles/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,21 @@ button:hover,
background: rgba(255, 255, 255, 0.15);
}

button:disabled,
.button:disabled {
cursor: default;
opacity: 0.5;
}

button:disabled:hover,
.button:disabled:hover {
background-color: #0d51ff;
}

.button-clear:disabled:hover {
background: transparent;
}

@media (min-width: 48rem) {
h1 {
font-size: 56px;
Expand Down

0 comments on commit 093c481

Please sign in to comment.