mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-18 23:46:03 +01:00
feat(web/menu): initial planet menu design
This commit is contained in:
@@ -12,6 +12,7 @@ import ListMenu from './features/menu/list';
|
|||||||
import Dev from './features/dev';
|
import Dev from './features/dev';
|
||||||
import { isEnvBrowser } from './utils/misc';
|
import { isEnvBrowser } from './utils/misc';
|
||||||
import SkillCheck from './features/skillcheck';
|
import SkillCheck from './features/skillcheck';
|
||||||
|
import PlanetMenu from './features/menu/planet';
|
||||||
|
|
||||||
const App: React.FC = () => {
|
const App: React.FC = () => {
|
||||||
useNuiEvent('setClipboard', (data: string) => {
|
useNuiEvent('setClipboard', (data: string) => {
|
||||||
@@ -30,6 +31,7 @@ const App: React.FC = () => {
|
|||||||
<AlertDialog />
|
<AlertDialog />
|
||||||
<ContextMenu />
|
<ContextMenu />
|
||||||
<ListMenu />
|
<ListMenu />
|
||||||
|
<PlanetMenu />
|
||||||
<SkillCheck />
|
<SkillCheck />
|
||||||
{isEnvBrowser() && <Dev />}
|
{isEnvBrowser() && <Dev />}
|
||||||
</>
|
</>
|
||||||
|
|||||||
81
web/src/features/menu/planet/index.tsx
Normal file
81
web/src/features/menu/planet/index.tsx
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
import { ActionIcon, Box, Tooltip } from '@mantine/core';
|
||||||
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||||
|
import { IconProp } from '@fortawesome/fontawesome-svg-core';
|
||||||
|
|
||||||
|
const radius = 60;
|
||||||
|
|
||||||
|
// https://codesandbox.io/embed/circular-menu-e94ug
|
||||||
|
function getTransform(index: number, totalItems: number) {
|
||||||
|
const value = index / totalItems;
|
||||||
|
|
||||||
|
const x = radius * Math.cos(Math.PI * 2 * (value - 0.25));
|
||||||
|
const y = radius * Math.sin(Math.PI * 2 * (value - 0.25));
|
||||||
|
|
||||||
|
return `translate(${x}px, ${y}px)`;
|
||||||
|
}
|
||||||
|
|
||||||
|
const items: { icon: IconProp; label: string }[] = [
|
||||||
|
{ icon: 'handcuffs', label: 'Arrest' },
|
||||||
|
{ icon: 'warehouse', label: 'Garage' },
|
||||||
|
{ icon: 'heart', label: 'Info' },
|
||||||
|
{ icon: 'handcuffs', label: 'Arrest' },
|
||||||
|
{ icon: 'warehouse', label: 'Garage' },
|
||||||
|
{ icon: 'heart', label: 'Info' },
|
||||||
|
];
|
||||||
|
|
||||||
|
const PlanetMenu: React.FC = () => {
|
||||||
|
return (
|
||||||
|
<Box
|
||||||
|
style={{
|
||||||
|
position: 'absolute',
|
||||||
|
top: '50%',
|
||||||
|
left: '50%',
|
||||||
|
transform: 'translate(-50%, -50%)',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<ActionIcon variant="filled" radius="xl" size="xl" color="primary" sx={{ zIndex: 99 }} w={50} h={50}>
|
||||||
|
<FontAwesomeIcon fixedWidth icon="xmark" size="lg" />
|
||||||
|
</ActionIcon>
|
||||||
|
<Box
|
||||||
|
sx={{
|
||||||
|
position: 'absolute',
|
||||||
|
top: '50%',
|
||||||
|
left: '50%',
|
||||||
|
transform: 'translate(-50%, -50%)',
|
||||||
|
width: 120,
|
||||||
|
height: 120,
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'center',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{items.map((item, index) => (
|
||||||
|
<Box
|
||||||
|
sx={(theme) => ({
|
||||||
|
transform: getTransform(index, items.length),
|
||||||
|
position: 'absolute',
|
||||||
|
width: 40,
|
||||||
|
height: 40,
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'center',
|
||||||
|
borderRadius: '50%',
|
||||||
|
backgroundColor: theme.colors.dark[6],
|
||||||
|
color: theme.colors.dark[0],
|
||||||
|
boxShadow: theme.shadows.sm,
|
||||||
|
padding: 12,
|
||||||
|
'&:hover': {
|
||||||
|
backgroundColor: theme.colors.dark[5],
|
||||||
|
cursor: 'pointer',
|
||||||
|
},
|
||||||
|
})}
|
||||||
|
>
|
||||||
|
<FontAwesomeIcon icon={item.icon} fixedWidth />
|
||||||
|
</Box>
|
||||||
|
))}
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default PlanetMenu;
|
||||||
Reference in New Issue
Block a user