Skip to content

Commit

Permalink
feat(visualizator-fe): Add option to upload custom skybox ✨
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeldev5 authored and dudo50 committed Aug 21, 2024
1 parent 27e8e60 commit ce80e4b
Show file tree
Hide file tree
Showing 21 changed files with 545 additions and 231 deletions.
6 changes: 3 additions & 3 deletions apps/landing-page/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
"lint": "eslint --fix ."
},
"dependencies": {
"@mantine/core": "^7.12.0",
"@mantine/form": "^7.12.0",
"@mantine/hooks": "^7.12.0",
"@mantine/core": "^7.12.1",
"@mantine/form": "^7.12.1",
"@mantine/hooks": "^7.12.1",
"@mantinex/dev-icons": "^1.0.2",
"@tabler/icons-react": "^3.12.0",
"react": "^18.3.1",
Expand Down
6 changes: 3 additions & 3 deletions apps/playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
"lint": "eslint --fix ."
},
"dependencies": {
"@mantine/core": "^7.11.2",
"@mantine/form": "^7.11.2",
"@mantine/hooks": "^7.11.2",
"@mantine/core": "^7.12.1",
"@mantine/form": "^7.12.1",
"@mantine/hooks": "^7.12.1",
"@paraspell/sdk": "workspace:*",
"@paraspell/xcm-analyser": "workspace:*",
"@paraspell/xcm-router": "workspace:*",
Expand Down
12 changes: 7 additions & 5 deletions apps/visualizator-fe/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@
"@apollo/client": "^3.11.1",
"@graphql-codegen/cli": "^5.0.2",
"@graphql-typed-document-node/core": "^3.2.0",
"@mantine/charts": "^7.11.2",
"@mantine/core": "^7.11.2",
"@mantine/dates": "^7.11.2",
"@mantine/form": "^7.11.2",
"@mantine/hooks": "^7.11.2",
"@mantine/charts": "^7.12.1",
"@mantine/core": "^7.12.1",
"@mantine/dates": "^7.12.1",
"@mantine/form": "^7.12.1",
"@mantine/hooks": "^7.12.1",
"@mantine/notifications": "^7.12.1",
"@paraspell/sdk": "workspace:*",
"@polkadot/api": "^12.2.2",
"@polkadot/apps-config": "^0.142.1",
Expand All @@ -39,6 +40,7 @@
"highcharts-react-official": "^3.2.1",
"i18next": "^23.12.2",
"i18next-browser-languagedetector": "^8.0.0",
"idb": "^8.0.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-i18next": "^15.0.0",
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
2 changes: 2 additions & 0 deletions apps/visualizator-fe/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { useSpring, animated } from '@react-spring/web';
import CollapseButton from './components/CollapseButton';
import EcosystemSelectContainer from './components/EcosystemSelect/EcosystemSelect.container';
import { PageRoute } from './PageRoute';
import { Notifications } from '@mantine/notifications';

const App = () => {
const [width, setWidth] = useState('40%');
Expand All @@ -29,6 +30,7 @@ const App = () => {
<WalletProvider>
<SelectedParachainProvider>
<MantineProvider>
<Notifications />
<Flex h="100%">
<Group flex={1} w="60%" h="100%" pos="relative">
<Scene3d />
Expand Down
67 changes: 5 additions & 62 deletions apps/visualizator-fe/src/components/Footer/Footer.tsx
Original file line number Diff line number Diff line change
@@ -1,81 +1,24 @@
import { Box, Button, ColorInput, Group, Modal, Paper, Select, Stack } from '@mantine/core';
import { Box, Button, Group, Paper } from '@mantine/core';
import { useSelectedParachain } from '../../context/SelectedParachain/useSelectedParachain';
import ParachainSelector from '../ParachainSelector';
import DateRangePicker from '../DateRangePicker';
import { useDisclosure } from '@mantine/hooks';
import { CountOption } from '../../gql/graphql';
import { useTranslation } from 'react-i18next';
import OptionsModal from '../Options/OptionsModal';

const Footer = () => {
const { t } = useTranslation();
const {
parachains,
setParachains,
dateRange,
setDateRange,
primaryChannelColor,
setPrimaryChannelColor,
highlightedChannelColor,
setHighlightedChannelColor,
secondaryChannelColor,
setSecondaryChannelColor,
selectedChannelColor,
setSelectedChannelColor,
parachainArrangement,
setParachainArrangement
} = useSelectedParachain();
const { parachains, setParachains, dateRange, setDateRange } = useSelectedParachain();
const [opened, { open, close }] = useDisclosure(false);

const onParachainArrangementChange = (value: string | null) => {
setParachainArrangement(value as CountOption);
};

return (
<Box pos="absolute" bottom={0} left={0} p="xl" w="100%">
<Paper w="100%" p="md" pt="sm" pb="sm" radius="md" bg="rgba(255,255,255,0.8)">
<Group align="flex-end">
<ParachainSelector value={parachains} onCustomChange={setParachains} flex={1} />
<DateRangePicker value={dateRange} setValue={setDateRange} />
<Modal opened={opened} onClose={close} title={t('editOptions')}>
<Stack gap="sm">
<ColorInput
label={t('primaryChannelColor')}
placeholder={t('selectColor')}
value={primaryChannelColor}
onChange={setPrimaryChannelColor}
/>
<ColorInput
label={t('highlightedChannelColor')}
placeholder={t('selectColor')}
value={highlightedChannelColor}
onChange={setHighlightedChannelColor}
/>
<ColorInput
label={t('secondaryChannelColor')}
placeholder={t('selectColor')}
value={secondaryChannelColor}
onChange={setSecondaryChannelColor}
/>
<ColorInput
label={t('selectedChannelColor')}
placeholder={t('selectColor')}
value={selectedChannelColor}
onChange={setSelectedChannelColor}
/>
<Select
label={t('arrangement')}
placeholder={t('selectArrangement')}
data={[
{ value: CountOption.ORIGIN, label: t('byOrigin') },
{ value: CountOption.DESTINATION, label: t('byDestination') },
{ value: CountOption.BOTH, label: t('byBoth') }
]}
value={parachainArrangement}
onChange={onParachainArrangementChange}
/>
</Stack>
</Modal>
<Button onClick={open}>{t('options')}</Button>
<OptionsModal opened={opened} close={close} />
<Button onClick={open}>{t('options.title')}</Button>
</Group>
</Paper>
</Box>
Expand Down
66 changes: 66 additions & 0 deletions apps/visualizator-fe/src/components/Options/GeneralOptions.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import { ColorInput, Select, Stack } from '@mantine/core';
import { useTranslation } from 'react-i18next';
import { useSelectedParachain } from '../../context/SelectedParachain/useSelectedParachain';
import { CountOption } from '../../gql/graphql';

const Options = () => {
const { t } = useTranslation();
const {
primaryChannelColor,
setPrimaryChannelColor,
highlightedChannelColor,
setHighlightedChannelColor,
secondaryChannelColor,
setSecondaryChannelColor,
selectedChannelColor,
setSelectedChannelColor,
parachainArrangement,
setParachainArrangement
} = useSelectedParachain();

const onParachainArrangementChange = (value: string | null) => {
setParachainArrangement(value as CountOption);
};

return (
<Stack gap="sm" pr="lg">
<ColorInput
label={t('primaryChannelColor')}
placeholder={t('selectColor')}
value={primaryChannelColor}
onChange={setPrimaryChannelColor}
/>
<ColorInput
label={t('highlightedChannelColor')}
placeholder={t('selectColor')}
value={highlightedChannelColor}
onChange={setHighlightedChannelColor}
/>
<ColorInput
label={t('secondaryChannelColor')}
placeholder={t('selectColor')}
value={secondaryChannelColor}
onChange={setSecondaryChannelColor}
/>
<ColorInput
label={t('selectedChannelColor')}
placeholder={t('selectColor')}
value={selectedChannelColor}
onChange={setSelectedChannelColor}
/>
<Select
label={t('arrangement')}
placeholder={t('selectArrangement')}
data={[
{ value: CountOption.ORIGIN, label: t('byOrigin') },
{ value: CountOption.DESTINATION, label: t('byDestination') },
{ value: CountOption.BOTH, label: t('byBoth') }
]}
value={parachainArrangement}
onChange={onParachainArrangementChange}
/>
</Stack>
);
};

export default Options;
44 changes: 44 additions & 0 deletions apps/visualizator-fe/src/components/Options/Options.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { Grid, Text, Title } from '@mantine/core';
import GeneralOptions from './GeneralOptions';
import SkyboxUploadForm from './SkyboxUploadForm';
import { useTranslation } from 'react-i18next';

const Options = () => {
const { t } = useTranslation('translation', {
keyPrefix: 'options'
});
return (
<Grid gutter="xl">
<Grid.Col
span={{
base: 12,
md: 6
}}
>
<Title order={5} mb="xs" pr="lg">
{t('generalTitle')}
</Title>
<Text size="sm" mb="md" c="dimmed" pr="lg">
{t('generalOptionsDesc')}
</Text>
<GeneralOptions />
</Grid.Col>
<Grid.Col
span={{
base: 12,
md: 6
}}
>
<Title order={5} mb="xs">
{t('customSkyboxTitle')}
</Title>
<Text size="sm" mb="md" c="dimmed">
{t('customSkyboxDesc')}
</Text>
<SkyboxUploadForm />
</Grid.Col>
</Grid>
);
};

export default Options;
29 changes: 29 additions & 0 deletions apps/visualizator-fe/src/components/Options/OptionsModal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { FC } from 'react';
import { Modal, Title } from '@mantine/core';
import Options from './Options';
import { useTranslation } from 'react-i18next';

type Props = {
opened: boolean;
close: () => void;
};

const OptionsModal: FC<Props> = ({ opened, close }) => {
const { t } = useTranslation();
return (
<Modal.Root opened={opened} onClose={close} size="xl">
<Modal.Overlay backgroundOpacity={0.55} blur={3} />
<Modal.Content>
<Modal.Header pb="xs">
<Title order={4}>{t('editOptions')}</Title>
<Modal.CloseButton />
</Modal.Header>
<Modal.Body p="lg">
<Options />
</Modal.Body>
</Modal.Content>
</Modal.Root>
);
};

export default OptionsModal;
Loading

0 comments on commit ce80e4b

Please sign in to comment.