summaryrefslogtreecommitdiff
path: root/frontend/src/components/PluginView.tsx
blob: cc6dbefcfc0d4f2673bb6fbc3b8ccc11195d9f4d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { ButtonItem, PanelSection, PanelSectionRow } from 'decky-frontend-lib';
import { VFC } from 'react';

import { useDeckyState } from './DeckyState';

const PluginView: VFC = () => {
  const { plugins, activePlugin, setActivePlugin } = useDeckyState();

  if (activePlugin) {
    return <div style={{ height: '100%' }}>{activePlugin.content}</div>;
  }

  return (
    <PanelSection>
      {plugins
        .filter((p) => p.content)
        .map(({ name, icon }) => (
          <PanelSectionRow key={name}>
            <ButtonItem layout="below" onClick={() => setActivePlugin(name)}>
              <div style={{ display: 'flex', justifyContent: 'space-between' }}>
                <div>{icon}</div>
                <div>{name}</div>
              </div>
            </ButtonItem>
          </PanelSectionRow>
        ))}
    </PanelSection>
  );
};

export default PluginView;