From a2b1d2109f193528a8148d877c2c68758a29da92 Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 7 Jun 2022 16:30:16 +0430 Subject: [PATCH] Added Dark/Light mode feature. --- src/App.js | 21 +++-- src/componets/AddItem.js | 4 +- src/componets/EditItem.js | 6 +- src/componets/List.js | 6 +- src/componets/Loader.js | 4 +- src/componets/TagSelection.js | 83 +++++++++---------- src/styles/App.css | 23 ++---- src/styles/Filters.css | 3 - src/styles/List.css | 31 ++++---- src/styles/SendItem.css | 11 +-- src/styles/Sort.css | 9 +-- src/styles/index.css | 146 +++++++++++++++++++++++++++++++++- 12 files changed, 237 insertions(+), 110 deletions(-) diff --git a/src/App.js b/src/App.js index 08535ed..9f54883 100644 --- a/src/App.js +++ b/src/App.js @@ -22,7 +22,8 @@ function App() { [descriptionChecked, setDescriptionChecked] = useState(true), [tagsChecked, setTagsChecked] = useState(true), [sortBy, setSortBy] = useState('Default'), - [loader, setLoader] = useState(false); + [loader, setLoader] = useState(false), + [lightMode, setLightMode] = useState(false); function SetLoader(x) { setLoader(x) @@ -57,7 +58,7 @@ function App() { } function sortByFunc(e) { - setSortBy(e) + setSortBy(e); } const filteredData = filter(data, searchQuery, nameChecked, tagsChecked, descriptionChecked); @@ -80,6 +81,14 @@ function App() { useEffect(() => { setNumberOfResults(filteredData.length); }, [filteredData]); + + useEffect(() => { + if (lightMode) { + document.body.classList.add("light"); + } else { + document.body.classList.remove("light"); + } + }, [lightMode]); return (
@@ -87,13 +96,14 @@ function App() {
+

{numberOfResults > 0 ? numberOfResults + ' Bookmarks found' : null}

- + - + {numberOfResults === 0 ? : null} @@ -116,10 +126,11 @@ function App() { SetLoader={SetLoader} onExit={exitAdding} reFetch={fetchData} + lightMode={lightMode} tags={() => tags} /> : null} - {loader ? : null} + {loader ? : null}
); diff --git a/src/componets/AddItem.js b/src/componets/AddItem.js index bda66db..4687ba5 100644 --- a/src/componets/AddItem.js +++ b/src/componets/AddItem.js @@ -3,7 +3,7 @@ import '../styles/SendItem.css'; import TagSelection from './TagSelection'; import addItem from '../modules/send'; -const AddItem = ({onExit, reFetch, tags, SetLoader}) => { +const AddItem = ({onExit, reFetch, tags, SetLoader, lightMode}) => { const [name, setName] = useState(''); const [link, setLink] = useState(''); const [tag, setTag] = useState([]); @@ -43,7 +43,7 @@ const AddItem = ({onExit, reFetch, tags, SetLoader}) => {

Name: (Optional)

Tags: (Optional)

- + diff --git a/src/componets/EditItem.js b/src/componets/EditItem.js index 12a0728..4a1b11c 100644 --- a/src/componets/EditItem.js +++ b/src/componets/EditItem.js @@ -4,7 +4,7 @@ import '../styles/SendItem.css'; import TagSelection from './TagSelection'; import editItem from '../modules/send'; -const EditItem = ({tags, item, onExit, SetLoader, reFetch}) => { +const EditItem = ({tags, item, onExit, SetLoader, reFetch, lightMode }) => { const [name, setName] = useState(item.name); const [tag, setTag] = useState(item.tag); @@ -40,7 +40,7 @@ const EditItem = ({tags, item, onExit, SetLoader, reFetch}) => {
Edit bookmark - +

Link: {url.hostname}

{item.title}

@@ -48,7 +48,7 @@ const EditItem = ({tags, item, onExit, SetLoader, reFetch}) => {

Name: (Optional)

Tags: (Optional)

- +
diff --git a/src/componets/List.js b/src/componets/List.js index a163cbf..09402b9 100644 --- a/src/componets/List.js +++ b/src/componets/List.js @@ -4,7 +4,7 @@ import ViewArchived from './ViewArchived'; import EditItem from './EditItem'; import { useState } from 'react' -const List = ({data, tags, reFetch, SetLoader}) => { +const List = ({data, tags, reFetch, SetLoader, lightMode}) => { const [editBox, setEditBox] = useState(false) const [editIndex, setEditIndex] = useState(0) @@ -42,7 +42,7 @@ const List = ({data, tags, reFetch, SetLoader}) => {
- +
) @@ -50,7 +50,7 @@ const List = ({data, tags, reFetch, SetLoader}) => { console.log(e); } })} - {editBox ? tags} onExit={exitEditing} SetLoader={SetLoader} reFetch={reFetch} item={data[editIndex]} /> : null} + {editBox ? tags} onExit={exitEditing} SetLoader={SetLoader} reFetch={reFetch} item={data[editIndex]} /> : null} ) } diff --git a/src/componets/Loader.js b/src/componets/Loader.js index 1afc0ad..944b066 100644 --- a/src/componets/Loader.js +++ b/src/componets/Loader.js @@ -2,10 +2,10 @@ import '../styles/Loader.css'; import { InfinitySpin } from 'react-loader-spinner' -const Loader = () => { +const Loader = ({ lightMode }) => { return (
- +
) } diff --git a/src/componets/TagSelection.js b/src/componets/TagSelection.js index 510a385..a2e7797 100644 --- a/src/componets/TagSelection.js +++ b/src/componets/TagSelection.js @@ -1,48 +1,49 @@ import CreatableSelect from "react-select/creatable"; -const customStyles = { - placeholder: (provided) => ({ - ...provided, - color: '#a9a9a9', +// lightMode ? "Black" : "White" +export default function TagSelection({setTags, tags, tag=[], lightMode}) { + const customStyles = { + placeholder: (provided) => ({ + ...provided, + color: '#a9a9a9', + }), + + multiValueRemove: (provided) => ({ + ...provided, + color: 'gray', + }), + + indicatorSeparator: (provided) => ({ + ...provided, + display: 'none', + }), + + menu: (provided) => ({ + ...provided, + border: 'solid', + borderWidth: '1px', + borderRadius: '0px', + borderColor: 'rgb(141, 141, 141)', + opacity: '90%', + color: 'gray', + background: lightMode ? "lightyellow" : "#273949", + boxShadow: 'rgba(0, 0, 0, 0.16) 0px 3px 6px, rgba(0, 0, 0, 0.23) 0px 3px 6px', + }), + + input: (provided) => ({ + ...provided, + color: lightMode ? "rgb(64, 64, 64)" : "white", }), + + control: (provided, state) => ({ + ...provided, + background: lightMode ? "lightyellow" : "#273949", + border: 'none', + borderRadius: '0px', + boxShadow: state.isFocused ? 'rgba(0, 0, 0, 0.16) 0px 3px 6px, rgba(0, 0, 0, 0.23) 0px 3px 6px' : 'rgba(0, 0, 0, 0.4) 0px 2px 4px, rgba(0, 0, 0, 0.3) 0px 7px 13px -3px, rgba(0, 0, 0, 0.2) 0px -3px 0px inset', + }), + } - multiValueRemove: (provided) => ({ - ...provided, - color: 'gray', - }), - - indicatorSeparator: (provided) => ({ - ...provided, - display: 'none', - }), - - menu: (provided) => ({ - ...provided, - border: 'solid', - borderWidth: '1px', - borderRadius: '0px', - borderColor: 'rgb(141, 141, 141)', - opacity: '90%', - color: 'gray', - background: '#273949', - boxShadow: 'rgba(0, 0, 0, 0.16) 0px 3px 6px, rgba(0, 0, 0, 0.23) 0px 3px 6px', - }), - - input: (provided) => ({ - ...provided, - color: 'white', -}), - - control: (provided, state) => ({ - ...provided, - background: '#273949', - border: 'none', - borderRadius: '0px', - boxShadow: state.isFocused ? 'rgba(0, 0, 0, 0.16) 0px 3px 6px, rgba(0, 0, 0, 0.23) 0px 3px 6px' : 'rgba(0, 0, 0, 0.4) 0px 2px 4px, rgba(0, 0, 0, 0.3) 0px 7px 13px -3px, rgba(0, 0, 0, 0.2) 0px -3px 0px inset', - }), -} - -export default function TagSelection({setTags, tags, tag=[]}) { const data = tags().map((e) => { return { value: e, label: e } }) diff --git a/src/styles/App.css b/src/styles/App.css index f3e7a7b..57c01f0 100644 --- a/src/styles/App.css +++ b/src/styles/App.css @@ -1,7 +1,5 @@ .App { min-height: 100vh; - background-color: #1f2c38; - color: white; display: flex; } @@ -25,8 +23,6 @@ border: none; width: 35%; min-width: 300px; - color: white; - background-color:#273949; box-shadow: rgba(0, 0, 0, 0.4) 0px 2px 4px, rgba(0, 0, 0, 0.3) 0px 7px 13px -3px, rgba(0, 0, 0, 0.2) 0px -3px 0px inset; } @@ -44,24 +40,17 @@ font-size: 1.1rem; cursor: pointer; box-shadow: rgba(0, 0, 0, 0.4) 0px 2px 4px, rgba(0, 0, 0, 0.3) 0px 7px 13px -3px, rgba(0, 0, 0, 0.2) 0px -3px 0px inset; - color: #ffffffb6; background-color:#273949; border: none; transition: background-color 0.1s; } +.btn:active { box-shadow: 0px 0px 10px rgb(83, 143, 255); } + .add-btn { margin-left: auto; } -.btn:hover { - background-color: rgb(76, 117, 170); -} - -.btn:active { - box-shadow: 0px 0px 10px rgb(83, 143, 255); -} - textarea:focus, input:focus{ outline: none; } @@ -75,7 +64,11 @@ textarea:focus, input:focus{ text-align: center; padding-top: 5%; padding-bottom: 5%; - background-color:#273949; box-shadow: rgba(0, 0, 0, 0.4) 0px 2px 4px, rgba(0, 0, 0, 0.3) 0px 7px 13px -3px, rgba(0, 0, 0, 0.2) 0px -3px 0px inset; - margin: 20px; + margin-top: 10px; +} + +.dark-light-btn { + margin-left: 10px; + font-size: 1.3em; } \ No newline at end of file diff --git a/src/styles/Filters.css b/src/styles/Filters.css index ff086ed..c7369ec 100644 --- a/src/styles/Filters.css +++ b/src/styles/Filters.css @@ -18,7 +18,6 @@ display: flex; flex-direction: column; box-shadow: rgba(0, 0, 0, 0.16) 0px 3px 6px, rgba(0, 0, 0, 0.23) 0px 3px 6px; - background-color: #1f2c38; padding: 5px; top: 15%; left: 30%; @@ -42,8 +41,6 @@ font-size: 1.1rem; cursor: pointer; box-shadow: rgba(0, 0, 0, 0.4) 0px 2px 4px, rgba(0, 0, 0, 0.3) 0px 7px 13px -3px, rgba(0, 0, 0, 0.2) 0px -3px 0px inset; - color: #ffffffb6; - background-color:#273949; border: none; } diff --git a/src/styles/List.css b/src/styles/List.css index 95ed725..af26225 100644 --- a/src/styles/List.css +++ b/src/styles/List.css @@ -28,7 +28,6 @@ display: flex; justify-content: space-between; align-items: center; - background-color:#273949; box-shadow: rgba(0, 0, 0, 0.4) 0px 2px 4px, rgba(0, 0, 0, 0.3) 0px 7px 13px -3px, rgba(0, 0, 0, 0.2) 0px -3px 0px inset; } @@ -50,7 +49,6 @@ font-family: 'Font Awesome 5 Free'; pointer-events: all; text-decoration: none; - color: rgb(194, 193, 193); font-size: 1rem; } @@ -66,20 +64,10 @@ .edit-btn { - position: relative; - border-radius: 100%; margin: 20px 20px 20px 0px; - font-family: 'Font Awesome 5 Free'; width: 50px; height: 50px; - padding: 10px; - font-size: 1.3rem; - cursor: pointer; - box-shadow: rgba(0, 0, 0, 0.4) 0px 2px 4px, rgba(0, 0, 0, 0.3) 0px 7px 13px -3px, rgba(0, 0, 0, 0.2) 0px -3px 0px inset; - color: #ffffffb6; - background-color: #1f2c38; - border: none; - transition: background-color 0.1s; + font-size: 1.5rem; } .edit-btn:hover { @@ -106,7 +94,6 @@ .tags div { margin-right: 10px; - color: rgb(126, 208, 255); } .tags div::before { @@ -125,15 +112,29 @@ } .delete { + margin: 20px 20px 20px 0px; background-color:#273949; float: right; font-size: 1.1rem; width: 40px; height: 40px; + position: relative; + border-radius: 100%; + font-family: 'Font Awesome 5 Free'; + width: 40px; + height: 40px; + padding: 10px; + font-size: 1.1rem; + cursor: pointer; + box-shadow: rgba(0, 0, 0, 0.4) 0px 2px 4px, rgba(0, 0, 0, 0.3) 0px 7px 13px -3px, rgba(0, 0, 0, 0.2) 0px -3px 0px inset; + background-color:#273949; + border: none; + transition: background-color 0.1s; } .delete:hover { - background-color: rgba(255, 65, 65, 0.8); + background-color: rgba(255, 75, 75, 0.8); + color: #d8d8d8; } .delete:active { diff --git a/src/styles/SendItem.css b/src/styles/SendItem.css index b27a20f..3a160e7 100644 --- a/src/styles/SendItem.css +++ b/src/styles/SendItem.css @@ -57,8 +57,6 @@ padding: 10px; cursor: pointer; box-shadow: rgba(0, 0, 0, 0.4) 0px 2px 4px, rgba(0, 0, 0, 0.3) 0px 7px 13px -3px, rgba(0, 0, 0, 0.2) 0px -3px 0px inset; - color: #ffffffb6; - background-color:#273949; border: none; margin-top: 20px; display: block; @@ -67,13 +65,7 @@ transition: background-color 0.1s; } -.send-btn:hover { - background-color: rgb(76, 117, 170); -} - -.send-btn:active { - box-shadow: 0px 0px 10px rgb(83, 143, 255); -} +.send-btn:active { box-shadow: 0px 0px 10px rgb(83, 143, 255); } @keyframes fadein { from { opacity: 0%; } @@ -87,6 +79,5 @@ } .title { - color: darkgray; font-size: 0.9em; } \ No newline at end of file diff --git a/src/styles/Sort.css b/src/styles/Sort.css index aba8e0d..6108a00 100644 --- a/src/styles/Sort.css +++ b/src/styles/Sort.css @@ -18,7 +18,6 @@ display: flex; flex-direction: column; box-shadow: rgba(0, 0, 0, 0.16) 0px 3px 6px, rgba(0, 0, 0, 0.23) 0px 3px 6px; - background-color: #1f2c38; padding: 5px; top: 15%; left: 25%; @@ -41,16 +40,10 @@ font-size: 1.1rem; cursor: pointer; box-shadow: rgba(0, 0, 0, 0.4) 0px 2px 4px, rgba(0, 0, 0, 0.3) 0px 7px 13px -3px, rgba(0, 0, 0, 0.2) 0px -3px 0px inset; - color: #ffffffb6; - background-color:#273949; border: none; transition: background-color 0.1s; } - -.sort-by-btn:hover { - background-color: rgb(76, 117, 170); -} - + .sort-by-btn:active { box-shadow: 0px 0px 10px rgb(83, 143, 255); } diff --git a/src/styles/index.css b/src/styles/index.css index a0e413d..2180aec 100644 --- a/src/styles/index.css +++ b/src/styles/index.css @@ -6,9 +6,149 @@ body { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; background-color: #1f2c38; - text-shadow: 0px 1px 1px #1f2c38; + text-shadow: 0px 1px 2px #000000; + color: white; + transition: background-color 0.1s; } *::selection { - background-color: rgba(115, 192, 255, 0.9); -} \ No newline at end of file + background-color: rgba(120, 120, 120, 0.9); + color: white; + text-shadow: none; +} + +/* Dark Mode settings (Default) */ + +.delete { + background-color: #1f2c38; + color: #ffffffb6; +} + +.no-results { + background-color: #1f2c38; +} + +.send-btn { + background-color:#273949; + color: #ffffffb6; +} + +.sort { + background-color: #1f2c38; +} + +.sort-by-btn { + background-color:#273949; + color: #ffffffb6; +} + +.btn:hover, .sort-by-btn:hover, .send-btn:hover { + background-color: rgb(76, 117, 170); +} + +.tags div { + color: rgb(126, 208, 255); +} + +.title { + color: darkgray; +} + +.list a { + color: rgb(194, 193, 193); +} + +.btn { + color: #ffffffb6; +} + +.no-results, .list-row { + transition: background-color 0.1s; + background-color:#273949; +} + +.search { + transition: background-color 0.1s; + background-color:#273949; + color: white; +} + +.filter { + background-color: #1f2c38; +} + +.filter > label { + background-color:#273949; + color: #ffffffb6; +} + +/* Light Mode settings */ + +.light { + text-shadow: 0px 1px 2px #ffffff; + background-color:rgb(233, 220, 179); + color: rgb(64, 64, 64); +} + +.light .list-row { + background-color: lightyellow; +} + +.light .btn { + background-color: lightyellow; + color: gray; +} + +.light .delete { + background-color: lightyellow; + color: rgb(176, 176, 176); +} + +.light input { + background-color: lightyellow; + color: black; +} + +.light .box, .light .edit-btn { + background-color:rgb(233, 220, 179); +} + +.light .title { + color: rgb(105, 105, 105); +} + +.light .list a { + color: rgb(102, 102, 102); +} + +.light .tags div { + color: rgb(9, 139, 214); +} + +.light .filter, .light .sort { + background-color: rgb(233, 220, 179); +} + +.light .filter > label { + background-color: lightyellow; + color: #4b4b4bb6; +} + +.light .sort-by-btn { + background-color:lightyellow; + color: #4b4b4bb6; +} + +.light .send-btn { + background-color: lightyellow; + color: #717171b6; +} + +.light .sort-by-btn:hover, .light .btn:hover, .light .send-btn:hover { + background-color: rgb(55, 131, 237); + color: #d8d8d8; +} + +.light .no-results { + background-color: lightyellow; +} \ No newline at end of file