summaryrefslogtreecommitdiff
path: root/frontend/src/components/TitleView.tsx
blob: 8ca81028aa6f8ddb9f50cb069983bd697696e632 (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
32
import { DialogButton, staticClasses } from 'decky-frontend-lib';
import { VFC } from 'react';
import { FaShoppingBag } from 'react-icons/fa';

import { useDeckyState } from './DeckyState';

const TitleView: VFC = () => {
  const { activePlugin } = useDeckyState();

  const openPluginStore = () => fetch('http://127.0.0.1:1337/methods/open_plugin_store', { method: 'POST' });

  if (activePlugin === null) {
    return (
      <div className={staticClasses.Title}>
        Decky
        <div style={{ position: 'absolute', top: '3px', right: '16px', zIndex: 20 }}>
          <DialogButton style={{ minWidth: 0, padding: '10px 12px' }} onClick={openPluginStore}>
            <FaShoppingBag style={{ display: 'block' }} />
          </DialogButton>
        </div>
      </div>
    );
  }

  return (
    <div className={staticClasses.Title} style={{ paddingLeft: '60px' }}>
      {activePlugin.name}
    </div>
  );
};

export default TitleView;