Skip to content

Commit

Permalink
wip: views
Browse files Browse the repository at this point in the history
  • Loading branch information
shanimal08 committed Feb 27, 2025
1 parent aa11bc2 commit 883bae8
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 19 deletions.
10 changes: 9 additions & 1 deletion src/containers/main/Dashboard/Dashboard.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
import MiningView from './MiningView/MiningView';
import { DashboardContentContainer } from './styles';
import { useUIStore } from '@app/store/useUIStore.ts';

export default function Dashboard() {
const view = useUIStore((s) => s.view);
return (
<DashboardContentContainer>
<MiningView />
{view === 'mining' ? (
<MiningView />
) : (
<div>
<h1>{`hello i am a wallet view`}</h1>
</div>
)}
</DashboardContentContainer>
);
}
10 changes: 9 additions & 1 deletion src/containers/main/MainView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,22 @@ import { useAppConfigStore } from '@app/store/useAppConfigStore';
import { Dashboard } from '@app/containers/main/Dashboard';
import SidebarNavigation from '@app/containers/main/SidebarNavigation/SidebarNavigation.tsx';
import { DashboardContainer } from '@app/theme/styles.ts';
import { useUIStore } from '@app/store/useUIStore.ts';

export default function MainView() {
const visualMode = useAppConfigStore((s) => s.visual_mode);
const view = useUIStore((s) => s.view);

return (
<DashboardContainer $visualModeOff={!visualMode}>
<SidebarNavigation />
<Dashboard />
{view === 'mining' ? (
<Dashboard />
) : (
<div>
<h1>{`hello i am a wallet view`}</h1>
</div>
)}
</DashboardContainer>
);
}
37 changes: 29 additions & 8 deletions src/containers/main/SidebarNavigation/Sidebars/SidebarMini.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { memo, useState } from 'react';
import * as m from 'motion/react-m';

import OpenSettingsButton from '@app/containers/floating/Settings/components/OpenSettingsButton.tsx';
import { CubeOutlineSVG } from '@app/assets/icons/cube-outline.tsx';
Expand All @@ -10,36 +11,56 @@ import { useUIStore } from '@app/store/useUIStore.ts';
import { setAnimationProperties } from '@app/visuals.ts';
import { IconButton } from '@app/components/elements/buttons/IconButton.tsx';
import { TariOutlineSVG } from '@app/assets/icons/tari-outline.tsx';
import { IoChevronForwardOutline } from 'react-icons/io5';

const SidebarMini = memo(function SidebarMini() {
const setSidebarOpen = useUIStore((s) => s.setSidebarOpen);
const sidebarOpen = useUIStore((s) => s.sidebarOpen);
const [activesection, setActiveSection] = useState<'main' | 'wallet'>('main');
const setView = useUIStore((s) => s.setView);
const view = useUIStore((s) => s.view);

const miningActive = view === 'mining';

const [minerHovered, setMinerHovered] = useState(false);

function handleMiningClick() {
if (activesection !== 'main') {
setActiveSection('main');
if (!miningActive) {
setView('mining');
} else {
setSidebarOpen(!sidebarOpen);
const offset = ((sidebarOpen ? SB_MINI_WIDTH : SB_WIDTH) + SB_SPACING) / window.innerWidth;
setAnimationProperties([{ property: 'cameraOffsetX', value: offset }]);
}
}
const rotate = sidebarOpen ? '180deg' : '0deg';
const minerIcon =
minerHovered && miningActive ? (
<m.div
animate={{ rotate, transition: { type: 'spring' } }}
style={{ display: 'flex', alignItems: 'center', justifyContent: 'center', rotate }}
>
<IoChevronForwardOutline size={28} />
</m.div>
) : (
<CubeOutlineSVG />
);
return (
<SidebarWrapper style={{ width: SB_MINI_WIDTH }}>
<MinimizedWrapper>
<LogoWwrapper>
<TariOutlineSVG />
</LogoWwrapper>
<CTAWrapper>
<IconButton variant="secondary" active={activesection === 'main'} onClick={handleMiningClick}>
<CubeOutlineSVG />
</IconButton>
<IconButton
variant="secondary"
active={activesection === 'wallet'}
onClick={() => setActiveSection('wallet')}
active={view === 'mining'}
onClick={handleMiningClick}
onMouseEnter={() => setMinerHovered(true)}
onMouseLeave={() => setMinerHovered(false)}
>
{minerIcon}
</IconButton>
<IconButton variant="secondary" active={view === 'wallet'} onClick={() => setView('wallet')}>
<WalletOutlineSVG />
</IconButton>
</CTAWrapper>
Expand Down
3 changes: 1 addition & 2 deletions src/store/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export type viewType = 'setup' | 'tribes' | 'mining';
export type backgroundType = 'onboarding' | 'idle' | 'determining' | 'loading' | 'mining' | 'loser' | 'winner';
export type ViewType = 'mining' | 'wallet';
export type modeType = 'Eco' | 'Ludicrous' | 'Custom';
export type displayMode = 'system' | 'dark' | 'light';
10 changes: 3 additions & 7 deletions src/store/useUIStore.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { create } from './create';
import { backgroundType, viewType } from './types.ts';
import { ViewType } from './types.ts';
import { Theme } from '@app/theme/types.ts';
import { setAnimationProperties } from '@app/visuals.ts';
import { useAppConfigStore } from './useAppConfigStore.ts';
Expand All @@ -10,8 +10,7 @@ type DialogType = DialogTypeTuple[number];

interface State {
theme: Theme;
background: backgroundType;
view: viewType;
view: ViewType;
latestVersion?: string;
sidebarOpen: boolean;
showExperimental: boolean;
Expand All @@ -23,7 +22,6 @@ interface State {
adminShow?: 'setup' | 'main' | 'shutdown' | 'orphanChainWarning' | null;
}
interface Actions {
setBackground: (background: State['background']) => void;
setView: (view: State['view']) => void;
setSidebarOpen: (sidebarOpen: State['sidebarOpen']) => void;
setShowExperimental: (showExperimental: boolean) => void;
Expand All @@ -38,8 +36,7 @@ const initialDarkMode = window.matchMedia && window.matchMedia('(prefers-color-s
const initialState: State = {
isWebglNotSupported: false,
theme: initialDarkMode ? 'dark' : 'light',
background: 'onboarding',
view: 'setup',
view: 'mining',
sidebarOpen: false,
dialogToShow: null,
showExperimental: false,
Expand All @@ -50,7 +47,6 @@ const initialState: State = {

export const useUIStore = create<UIStoreState>()((set) => ({
...initialState,
setBackground: (background) => set({ background }),
setView: (view) => set({ view }),
setSidebarOpen: (sidebarOpen) => set({ sidebarOpen }),
setShowExperimental: (showExperimental) => set({ showExperimental }),
Expand Down

0 comments on commit 883bae8

Please sign in to comment.