bluehost

Showing posts with label beginner guide.. Show all posts
Showing posts with label beginner guide.. Show all posts

Saturday, 24 June 2023

Adding a Dark Mode to Your Website: Enhancing User Experience with Ease

photo    courtesy




Introduction:

In the contemporary digital environment, incorporating a dark mode feature into your website can significantly enhance the user experience. Dark mode creates a visually appealing and relaxing browsing environment, lessening eye fatigue and enhancing comprehension. This article delves into the process of incorporating a dark mode into your online presence, providing insights and useful suggestions to ensure the smooth introduction of this desired function.

photo  Google


HTML process of adding dark mode:

<!DOCTYPE html>
<html lang="en" class="light-mode">
<head>
<link rel="stylesheet" type="text/css" href="dark.css">
</head>
<body>
<!-- Page content -->
<span id="dark-mode-icon"></span>

<button id="dark-mode-toggle">Toggle Dark Mode</button>
<script src="dark.js"></script>
</body>
</html>

4. Implementing Dark Mode with CSS:

The CSS techniques used to implement dark mode effectively. Utilize media queries to detect user preferences, or provide a manual toggle option for users to switch between light and dark modes. Walk through the necessary CSS modifications for background colours, text colours, and other relevant elements.

.light-mode {
/* Light mode styles */
Colour: #000;
background-color: #fff;
}
.dark-mode {
/* Dark mode styles */
color: #fff;
background-color: #333;
}
/* Additional styles for elements in dark mode */
.dark-mode h1 {
color: #fff;
}
@media (prefers-color-scheme: dark) {
/* Styles for automatic dark mode */
html:not(.dark-mode) {
color: #fff;
background-color: #333;
}
/* Additional styles for elements in automatic dark mode */
html:not(.dark-mode) h1 {
color: #fff;
}
}
body {
/* Other body styles */
transition: background-color 0.3s ease, color 0.3s ease;
}
#dark-mode-icon {
width: 24px;
height: 24px;
background-image: url('dark.png');
background-size: cover;
/* Add other styling as needed */
}

5. The JavaScript part of dark mode:

document.addEventListener('DOMContentLoaded', () => {
const darkModeToggle = document.getElementById('dark-mode-toggle');
const html = document.querySelector('html');
const localStorageKey = 'darkMode';
// Retrieve user preference from local storage
const isDarkModeEnabled = JSON.parse(localStorage.getItem(localStorageKey));
// Apply the appropriate class based on the user's preference
if (isDarkModeEnabled) {
html.classList.add('dark-mode');
} else {
html.classList.remove('dark-mode');
}
darkModeToggle.addEventListener('click', () => {
// Toggle dark mode class
html.classList.toggle('dark-mode');
// Save user preference to local storage
localStorage.setItem(localStorageKey, html.classList.contains('dark-mode'));
});
});


Conclusion:

By incorporating a dark mode feature into your website, you can significantly enhance the user experience by providing a visually appealing, comfortable, and customizable browsing experience. Follow the steps outlined in this article, adapting them to suit your website's specific requirements. Embrace the benefits of dark mode and empower users with an immersive and enjoyable interface. Implementing dark mode can be a game-changer in providing an exceptional user experience while keeping your website up to date with modern design trends.

Tuesday, 29 June 2021

How To Increase Your Coding Skills Faster.

Programming is a process that requires a lot of time and energy if you are trying to study a new programming language. All of us need if we start something new, we take the shortest time to understand no matter which process it takes.

With that in mind, I'm going to show you how you can increase your coding skills faster respective of the programming language you are trying to study.

1. Know the data structure of the study language. Data structures will help you to make shortcodes and those many codes can make big programs the same way many sentences can make a paragraph.

2. Do simple projects.
Simple projects can range from making a code of one line up to codes of hundred lines and at the end of coding, you produce a program. Some simple project to do with python is like building a calculator, Multiplication table, stopwatch, simple website, and many more.

3. Reading other programmer's codes.
The more you read codes from other programmers, the more you get new skills and tricks of creating more appealing structures using little codes.

4. Practising regularly. 
Coding regularly makes you acquire new ideas every time you make some codes. It can take you a maximum of six months to study python programming language or two to three months or less if you decide to code every day.

5.  Always ask for help.
Make sure you have a person who you can be consulting when you have some challenges in your coding.

React vs Angular; Front-End Web Development

Angular and React  are two of the most popular Javascript tools for front-end development. React is a Javascript created by Meta...