From c3a1469a4e133dbe07d2bc24f82cc4e4b76da401 Mon Sep 17 00:00:00 2001 From: Yashash Date: Sat, 6 Nov 2021 23:26:55 +0530 Subject: [PATCH] svg icons for better dark mode : ) --- src/components/menu/index.js | 104 +++++++------- src/reducers/menu.js | 16 +-- src/utils/icons.js | 262 ++++++++++++++++++++++++----------- 3 files changed, 241 insertions(+), 141 deletions(-) diff --git a/src/components/menu/index.js b/src/components/menu/index.js index 8a43b6b6..bc1af0e6 100644 --- a/src/components/menu/index.js +++ b/src/components/menu/index.js @@ -1,98 +1,98 @@ -import React, {useState, useEffect} from 'react'; -import {useSelector, useDispatch} from 'react-redux'; -import {Icon} from '../../utils/general'; -import './menu.scss'; +import React, { useState, useEffect } from "react"; +import { useSelector, useDispatch } from "react-redux"; +import { Icon } from "../../utils/general"; +import "./menu.scss"; -import * as Actions from '../../actions'; +import * as Actions from "../../actions"; -export const ActMenu = ()=>{ - const menu = useSelector(state=>state.menus); - const {abpos, isLeft} = useSelector(state=>{ +export const ActMenu = () => { + const menu = useSelector((state) => state.menus); + const { abpos, isLeft } = useSelector((state) => { var acount = state.menus.menus[state.menus.opts].length; var tmpos = { - 'top': state.menus.top, - 'left': state.menus.left - }, tmpleft = false; + top: state.menus.top, + left: state.menus.left, + }, + tmpleft = false; var wnwidth = window.innerWidth, - wnheight = window.innerHeight; + wnheight = window.innerHeight; var ewidth = 312, - eheight = acount*28; + eheight = acount * 28; - tmpleft = (wnwidth - tmpos.left) > 504; - if(wnwidth - tmpos.left < ewidth){ + tmpleft = wnwidth - tmpos.left > 504; + if (wnwidth - tmpos.left < ewidth) { tmpos.right = wnwidth - tmpos.left; tmpos.left = null; } - if(wnheight - tmpos.top < eheight){ + if (wnheight - tmpos.top < eheight) { tmpos.bottom = wnheight - tmpos.top; tmpos.top = null; } return { abpos: tmpos, - isLeft: tmpleft + isLeft: tmpleft, }; - }) + }); const dispatch = useDispatch(); - const clickDispatch = (event)=>{ + const clickDispatch = (event) => { event.stopPropagation(); var action = { type: event.target.dataset.action, - payload: event.target.dataset.payload + payload: event.target.dataset.payload, }; - if(action.type){ - if(action.type!=action.type.toUpperCase()){ - Actions[action.type](action.payload,menu); - }else{ + if (action.type) { + if (action.type != action.type.toUpperCase()) { + Actions[action.type](action.payload, menu); + } else { dispatch(action); } - dispatch({type: "MENUHIDE"}); + dispatch({ type: "MENUHIDE" }); } - } + }; - const menuobj = (data)=>{ + const menuobj = (data) => { var mnode = []; - data.map(opt=>{ - if(opt.type=="hr"){ + data.map((opt) => { + if (opt.type == "hr") { mnode.push(
); - }else{ - mnode.push(
-
- {opt.icon?:null} + } else { + mnode.push( +
+
{opt.icon ? : null}
+
{opt.name}
+ {opt.opts ? : null} + {opt.dot ? : null} + {opt.check ? : null} + {opt.opts ?
{menuobj(opt.opts)}
: null}
-
{opt.name}
- {opt.opts?:null} - {opt.dot?:null} - {opt.check?:null} - {opt.opts?( -
- {menuobj(opt.opts)} -
- ):null} -
) + ); } }); return mnode; - } + }; return ( -
+
{menuobj(menu.menus[menu.opts])}
); -} +}; export default ActMenu; diff --git a/src/reducers/menu.js b/src/reducers/menu.js index 5c610702..85ad360f 100644 --- a/src/reducers/menu.js +++ b/src/reducers/menu.js @@ -9,7 +9,7 @@ const defState = { desk: [ { name: "View", - icon: "ui/view", + icon: "view", opts: [ { name: "Large icons", @@ -39,7 +39,7 @@ const defState = { }, { name: "Sort by", - icon: "ui/sort", + icon: "sort", opts: [ { name: "Name", @@ -61,13 +61,14 @@ const defState = { { name: "Refresh", action: "refresh", + icon: "refresh", }, { type: "hr", }, { name: "New", - icon: "ui/new", + icon: "New", // dsb: true, opts: [ { @@ -89,12 +90,11 @@ const defState = { }, { name: "Display settings", - icon: "ui/display", + icon: "display", }, { name: "Personalize", - icon: "ui/personalize", - // dsb: true, + icon: "personalize", }, { type: "hr", @@ -112,9 +112,9 @@ const defState = { { name: "About", action: "DESKABOUT", - icon: "win/info", + icon: "info", payload: true, - } + }, ], task: [ { diff --git a/src/utils/icons.js b/src/utils/icons.js index e4d329e7..67303f9c 100644 --- a/src/utils/icons.js +++ b/src/utils/icons.js @@ -1,127 +1,227 @@ -'use babel'; -import React from 'react' +"use babel"; +import React from "react"; export const home = (props) => { return ( - - - - ) -} + + + + ); +}; export const shuffle = (props) => { return ( - + - ) -} + ); +}; export const previous = (props) => { return ( - + - ) -} + ); +}; export const next = (props) => { return ( - + - ) -} + ); +}; export const repeat = (props) => { return ( - + - ) -} + ); +}; export const play = (props) => { return ( - + - ) -} + ); +}; export const pause = (props) => { return ( - + - ) -} + ); +}; export const search = (props) => { return ( -