Skip to content
This repository has been archived by the owner on Aug 7, 2024. It is now read-only.

Implemented the Dark/Light-Mode feature #1852

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## [0.76.5](https://github.com/EddieHubCommunity/LinkFree/compare/v0.76.4...v0.76.5) (2022-10-01)


### Bug Fixes

* update hacktoberfest-invalid label to invalid ([#1850](https://github.com/EddieHubCommunity/LinkFree/issues/1850)) ([b20e5a8](https://github.com/EddieHubCommunity/LinkFree/commit/b20e5a86e5904a661b9612ea492d526988d5eda3))



## [0.76.4](https://github.com/EddieHubCommunity/LinkFree/compare/v0.76.3...v0.76.4) (2022-09-30)


Expand Down Expand Up @@ -34,12 +43,3 @@



# [0.76.0](https://github.com/EddieHubCommunity/LinkFree/compare/v0.75.1...v0.76.0) (2022-09-16)


### Features

* label PR for nextjs ([#1757](https://github.com/EddieHubCommunity/LinkFree/issues/1757)) ([6f6a5bc](https://github.com/EddieHubCommunity/LinkFree/commit/6f6a5bc99c8309d803b551a2fce15d0c80c7818a))



265 changes: 244 additions & 21 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "linkfree",
"version": "0.76.4",
"version": "0.76.5",
"private": false,
"homepage": "https://linkfree.eddiehub.org",
"dependencies": {
Expand All @@ -10,6 +10,7 @@
"primeflex": "^3.1.2",
"primeicons": "^5.0.0",
"primereact": "^6.5.1",
"prop-types": "^15.8.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-icons": "^4.3.1",
Expand Down Expand Up @@ -102,4 +103,4 @@
"eslint --ext [.json,.js] --fix"
]
}
}
}
13 changes: 11 additions & 2 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,22 @@ import Footer from './Components/Footer'
import User from './Components/UserProfile/User'
import Home from './Components/Home'
import Search from './Components/Search/Search'

import user from './config/user.json'
import { useTheme } from './ThemeContext'

function App() {
const darkTheme = useTheme()
const body = document.querySelector('body')

const theme = {
color: `${darkTheme ? 'white' : 'black'}`,
}

body.style.backgroundColor = `${darkTheme ? '#202023' : 'white'}`

return (
<Router>
<div className="p-2 md:p-4 max-h-screen">
<div className="p-2 md:p-4 max-h-screen" style={theme}>
{user.username && <User singleUser={user} />}
{!user.username && (
<Switch>
Expand Down
8 changes: 7 additions & 1 deletion src/Components/Footer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ import React, { useState, useEffect } from 'react'
import { Link } from 'react-router-dom'
import GetIcons from './Icons/GetIcons'
import ScrollToTopBtn from './ScrollToTopBtn'
import { useTheme } from '../ThemeContext'

function Footer() {
const darkTheme = useTheme()
const [version, setVersion] = useState('')
useEffect(() => {
fetch('/app.json')
Expand All @@ -25,7 +27,11 @@ function Footer() {
className="mr-2"
aria-label="LinkFree repository on GitHub"
>
<GetIcons className="text-gray-900" iconName="github" size={16} />
<GetIcons
className={`${darkTheme ? 'text-white' : 'text-gray-900'}`}
iconName="github"
size={16}
/>
</Link>
<span>v{version}</span>
</p>
Expand Down
10 changes: 8 additions & 2 deletions src/Components/Home.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
import React from 'react'
import { Link } from 'react-router-dom'
import './Home.css'

import Navbar from './Navbar'
import GetIcons from './Icons/GetIcons'
import { useTheme } from '../ThemeContext'

function Home() {
const darkTheme = useTheme()

return (
<>
<header>
<Navbar
start={
<Link to="/search" aria-label="Search">
<GetIcons iconName="search" size={20} />
<GetIcons
iconName="search"
className={`${darkTheme ? 'text-white' : 'text-gray-900'}`}
size={20}
/>
</Link>
}
/>
Expand Down
6 changes: 6 additions & 0 deletions src/Components/Icons/GetIcons.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ import {
FaLink,
FaLinkedin,
FaMicrosoft,
FaMoon,
FaNodeJs,
FaPaypal,
FaSearch,
FaSlack,
FaSnapchat,
FaSun,
FaStackOverflow,
FaTelegram,
FaTiktok,
Expand Down Expand Up @@ -97,6 +99,8 @@ function GetIcons({ iconName, ...restProps }) {
return <SiMedium {...restProps} />
case 'microsoft':
return <FaMicrosoft {...restProps} />
case 'moon':
return <FaMoon {...restProps} />
case 'node-js':
return <FaNodeJs {...restProps} />
case 'open-source':
Expand All @@ -115,6 +119,8 @@ function GetIcons({ iconName, ...restProps }) {
return <FaSnapchat {...restProps} />
case 'stackoverflow':
return <FaStackOverflow {...restProps} />
case 'sun':
return <FaSun {...restProps} />
case 'telegram':
return <FaTelegram {...restProps} />
case 'tiktok':
Expand Down
10 changes: 8 additions & 2 deletions src/Components/Links.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import './Links.css'

import React from 'react'
import PropTypes from 'prop-types'
import StyledLink from './StyledLink'
import GetIcons from './Icons/GetIcons'
import { IconContext } from 'react-icons/lib'
import linksConfig from '../config/links.json'
import { useTheme } from '../ThemeContext'

function Links({ links }) {
const colors = linksConfig.validIcons
const darkTheme = useTheme()

function MouseOver(e, color) {
e.target.style.background = color
Expand All @@ -29,7 +30,12 @@ function Links({ links }) {
onMouseOver={(e) => MouseOver(e, colors[link.icon])}
onMouseOut={MouseOut}
className={`p-3 my-2 p-button-outlined ${link.icon}`}
style={{ color: colors[link.icon] }}
style={{
color:
colors[link.icon] === 'links' || darkTheme
? 'white'
: colors[link.icon],
}}
href={link.url}
>
<IconContext.Provider
Expand Down
5 changes: 5 additions & 0 deletions src/Components/Navbar.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
display: none !important;
}

.theme--button {
margin-left: 1rem;
cursor: pointer;
}

@media screen and (max-width: 320px) {
.p-menubar-end {
font-size: 12px;
Expand Down
43 changes: 34 additions & 9 deletions src/Components/Navbar.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import './Navbar.css'

import React, { useState, useEffect } from 'react'

import './Navbar.css'
import GetIcons from './Icons/GetIcons'
import PropTypes from 'prop-types'

import { Link } from 'react-router-dom'

import { Menubar } from 'primereact/menubar'

import GetIcons from './Icons/GetIcons'
import { useTheme, useThemeUpdate } from '../ThemeContext'

function Navbar({ items, start, end }) {
const [version, setVersion] = useState('')
const darkTheme = useTheme()
const toggleTheme = useThemeUpdate()

const theme = {
color: `${darkTheme ? 'white' : 'black'}`,
}

useEffect(() => {
fetch('/app.json')
Expand All @@ -32,10 +34,29 @@ function Navbar({ items, start, end }) {
className="mr-2"
aria-label="LinkFree repository on GitHub"
>
<GetIcons className="text-gray-900" iconName="github" size={16} />
<GetIcons
className={`${darkTheme ? 'text-white' : 'text-gray-900'}`}
iconName="github"
size={16}
/>
</Link>

<div>v{version}</div>
<div style={theme}>v{version}</div>

<div className="theme--button">
{darkTheme
? (
<GetIcons
iconName="moon"
className="text-white"
onClick={toggleTheme}
size={20}
/>
)
: (
<GetIcons iconName="sun" onClick={toggleTheme} size={20} />
)}
</div>
</div>
)
}
Expand All @@ -45,6 +66,10 @@ function Navbar({ items, start, end }) {
model={items}
start={start}
end={end}
style={{
backgroundColor: `${darkTheme ? '#181818' : 'white'}`,
border: `${darkTheme ? 'none' : '1px solid #dee2e6'}`,
}}
className="mb-4 flex-wrap justify-content-center"
/>
)
Expand Down
10 changes: 10 additions & 0 deletions src/Components/Search/Placeholders.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,17 @@ import React from 'react'
import PropTypes from 'prop-types'

import { Skeleton } from 'primereact/skeleton'
import { useTheme } from '../../ThemeContext'

function Placeholder({ list }) {
const darkTheme = useTheme()

const theme = {
backgroundColor: `${darkTheme ? '#333333' : 'white'}`,
border: `${darkTheme ? 'none' : 'white'}`,
color: `${darkTheme ? 'gray' : 'grey'}`,
}

return (
<>
<Skeleton shape="rectangle" height="3.2rem" className="mb-4" />
Expand All @@ -16,6 +25,7 @@ function Placeholder({ list }) {
borderRadius="2rem"
className="m-2 mr-2"
key={`skeleton-${key}`}
style={theme}
/>
)
})}
Expand Down
18 changes: 11 additions & 7 deletions src/Components/Search/Search.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import './Search.css'

import React, { useState, useEffect, useRef } from 'react'
import { Link } from 'react-router-dom'
import { Toast } from 'primereact/toast'

import Placeholders from './Placeholders'
import Users from './Users'
import Navbar from '../Navbar'
import Placeholders from './Placeholders'
import GetIcons from '../Icons/GetIcons'
import Users from './Users'
import { Link } from 'react-router-dom'
import { Toast } from 'primereact/toast'
import { useTheme } from '../../ThemeContext'

function Search() {
const [list, setList] = useState([])
const [skeleton, setskeleton] = useState(true)
const toast = useRef(null)
const darkTheme = useTheme()

useEffect(() => {
fetch('/list.json')
Expand Down Expand Up @@ -45,7 +45,11 @@ function Search() {
<Navbar
start={
<Link to="/" aria-label="Go back to Home">
<GetIcons iconName="arrowLeft" size={20} />
<GetIcons
iconName="arrowLeft"
size={20}
className={`${darkTheme ? 'text-white' : 'text-gray-900'}`}
/>
</Link>
}
/>
Expand Down
10 changes: 10 additions & 0 deletions src/Components/Search/Searchbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,17 @@ import PropTypes from 'prop-types'
import { InputText } from 'primereact/inputtext'
import GetIcons from '../Icons/GetIcons'
import './Search.css'
import { useTheme } from '../../ThemeContext'

const Searchbar = ({ searchHandler, searchTerm }) => {
const darkTheme = useTheme()

const theme = {
backgroundColor: `${darkTheme ? '#333333' : 'white'}`,
border: `${darkTheme ? 'none' : '1px solid #ced4da'}`,
color: `${darkTheme ? 'white' : 'grey'}`,
}

return (
<div className="search-section">
<span className="p-input-icon-left">
Expand All @@ -18,6 +27,7 @@ const Searchbar = ({ searchHandler, searchTerm }) => {
id="search-input"
placeholder="Search user..."
autoFocus
style={theme}
/>
</span>
</div>
Expand Down
10 changes: 9 additions & 1 deletion src/Components/Search/Users.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,21 @@ import { Link } from 'react-router-dom'
import PropTypes from 'prop-types'
import { Chip } from 'primereact/chip'
import { Message } from 'primereact/message'

import { useTheme } from '../../ThemeContext'
import Searchbar from './Searchbar'
import ProfileTypeFilter from './filterProfileType'

function Users({ list }) {
const [profileType, setProfileType] = useState('all')
const [searchTerm, setSearchTerm] = useState('')
const [filteredList, setFilteredList] = useState(list)
const darkTheme = useTheme()

const theme = {
backgroundColor: `${darkTheme ? '#333333' : '#dee2e6'}`,
// border: `${darkTheme ? 'none' : '1px solid black'}`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this commented out code required?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry my bad.

color: `${darkTheme ? 'white' : 'grey'}`,
}

const typeHandler = (value) => {
setProfileType(value)
Expand Down Expand Up @@ -69,6 +76,7 @@ function Users({ list }) {
filteredList.map((user, key) => (
<Link to={user.username} key={`avatar-${key}`}>
<Chip
style={theme}
className="m-2 w-16rem px-3 py-2 transition-all transition-duration-300"
template={
<span className="text-overflow-ellipsis white-space-nowrap overflow-hidden">
Expand Down
Loading