mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-03 14:38:45 +00:00
Merge pull request #62 from project-error/feature/show-app-name-on-hover
Feature/show app name on hover
This commit is contained in:
3 files changed
+40
-23
No files matched your search
@@ -39,6 +39,16 @@ import { SelloutApp } from '../../../apps/sellout/components/SelloutApp';
|
||||
import { NotesApp } from '../../../apps/notes/NotesApp';
|
||||
import CameraApp from '../../../apps/camera/components/CameraApp';
|
||||
|
||||
export interface AppConfiguration {
|
||||
id: string;
|
||||
nameLocale: string;
|
||||
icon: JSX.Element;
|
||||
backgroundColor: string;
|
||||
color: string;
|
||||
path: string;
|
||||
Route: () => JSX.Element;
|
||||
}
|
||||
|
||||
const appsState = atom({
|
||||
key: 'apps',
|
||||
default: {
|
||||
@@ -148,7 +158,7 @@ const appsState = atom({
|
||||
|
||||
export const useApps = () => {
|
||||
const [apps, setApps] = useConfig(appsState);
|
||||
const allApps = [...apps.preinstalled];
|
||||
const allApps: AppConfiguration[] = [...apps.preinstalled];
|
||||
|
||||
const getApp = (id) => allApps.find((a) => a.id === id) || null;
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import Avatar from '@material-ui/core/Avatar';
|
||||
import { green } from '@material-ui/core/colors';
|
||||
import { Button } from '@material-ui/core';
|
||||
import Nui from '../../os/nui-events/utils/Nui';
|
||||
import { AppConfiguration } from '../../os/apps/hooks/useApps';
|
||||
|
||||
interface IStyles {
|
||||
root: any;
|
||||
@@ -29,7 +30,7 @@ const useStyles = makeStyles(
|
||||
})
|
||||
);
|
||||
|
||||
export const AppIcon = ({ id, name, icon, backgroundColor, color }) => {
|
||||
export const AppIcon = ({ id, icon, backgroundColor, color }: AppConfiguration) => {
|
||||
const classes = useStyles({
|
||||
backgroundColor: backgroundColor || green[50],
|
||||
color: color || green[400],
|
||||
@@ -42,7 +43,7 @@ export const AppIcon = ({ id, name, icon, backgroundColor, color }) => {
|
||||
return (
|
||||
<Button onClick={openAppCallback} className={classes.root}>
|
||||
<Avatar className={classes.avatar}>
|
||||
{icon || name[0].toUpperCase()}
|
||||
{icon}
|
||||
</Avatar>
|
||||
</Button>
|
||||
);
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import React, { useEffect } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { AppIcon } from './AppIcon';
|
||||
import { Grid, makeStyles } from '@material-ui/core';
|
||||
import { Grid, makeStyles, Tooltip } from '@material-ui/core';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { useKeyboard } from '../../os/keyboard/hooks/useKeyboard';
|
||||
import { AppConfiguration } from '../../os/apps/hooks/useApps';
|
||||
|
||||
const useStyles = makeStyles((theme) => ({
|
||||
root: {
|
||||
@@ -13,12 +15,18 @@ const useStyles = makeStyles((theme) => ({
|
||||
width: '20%',
|
||||
},
|
||||
tooltip: {
|
||||
bottom: -8,
|
||||
bottom: -12,
|
||||
fontSize: 12,
|
||||
},
|
||||
}));
|
||||
|
||||
export const GridMenu = ({ items, Component = AppIcon }) => {
|
||||
interface IProps {
|
||||
items: AppConfiguration[];
|
||||
Component: (...AppConfiguration) => JSX.Element;
|
||||
}
|
||||
|
||||
export const GridMenu = ({ items, Component = AppIcon }: IProps) => {
|
||||
const { t } = useTranslation();
|
||||
const setKey = useKeyboard();
|
||||
const classes = useStyles();
|
||||
|
||||
@@ -35,25 +43,23 @@ export const GridMenu = ({ items, Component = AppIcon }) => {
|
||||
{items &&
|
||||
items.length &&
|
||||
items.map((item) => (
|
||||
// <Tooltip
|
||||
// title={item.id}
|
||||
// placement='top'
|
||||
// arrow
|
||||
// classes={{ tooltip: classes.tooltip }}
|
||||
// PopperProps={{
|
||||
// anchorEl={}
|
||||
// }}
|
||||
// >
|
||||
<Grid
|
||||
<Tooltip
|
||||
key={item.id}
|
||||
item
|
||||
className={classes.item}
|
||||
component={Link}
|
||||
to={item.path}
|
||||
title={t(item.nameLocale)}
|
||||
placement="top-start"
|
||||
classes={{ tooltip: classes.tooltip }}
|
||||
arrow
|
||||
>
|
||||
<Component {...item} />
|
||||
</Grid>
|
||||
// </Tooltip>
|
||||
<Grid
|
||||
key={item.id}
|
||||
item
|
||||
className={classes.item}
|
||||
component={Link}
|
||||
to={item.path}
|
||||
>
|
||||
<Component {...item} />
|
||||
</Grid>
|
||||
</Tooltip>
|
||||
))}
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
Reference in new issue
Block a user