Skip to main content

How to Build a Dynamic Website from Scratch with WordPress FOR FREE

Are you looking to build a dynamic website from scratch without breaking the bank? WordPress is an excellent choice for creating a powerful and versatile website, and the best part is, it can be done for free. In this article, we will guide you through the step-by-step process of building a dynamic website using WordPress, without any coding knowledge required. Let's get started! Table of Contents Introduction to WordPress Setting Up Your Local Development Environment Installing WordPress Choosing a Theme Customizing Your Website Design Adding Essential Plugins Creating Pages and Navigation Setting Up a Blog Optimizing Your Website for SEO Enhancing Functionality with Plugins Securing Your Website Testing and Launching Your Website Maintaining and Updating Your Website Monetizing Your Website Conclusion 1. Introduction to WordPress WordPress is a popular content management system (CMS) that allows users to create and manage websites easily. It offers a user-friendly interface, a wi...

React Tailwind(css) Alert Component

React Tailwind(css) Alert Component

1. What is React tailwindcss Alert component?

React and tailwindcss are popular frameworks and libraries in modern web development. React is a JavaScript library for building user interfaces, and tailwindcss is a CSS framework for styling. You can combine the two to create a React tailwindcss notification component.

Notification components are used to convey important information to users or to encourage interaction. For example, you can display warnings, success messages, notification messages, and more. These notifications help improve the user experience of your web application and provide users with the information they need.

2. Why use React and tailwindcss together?

Using React with tailwindcss provides developers with a number of advantages.

First, React uses a Virtual DOM to improve performance. The virtual DOM only applies changes to the real DOM, eliminating the need to re-render the entire page. This helps to efficiently handle dynamic elements such as notification components.

Second, tailwindcss makes styling easier by providing predefined style utility classes. By combining classes, you can easily apply the style you want, and you can easily implement responsive design. This helps in flexible configuration of the notification component's appearance and layout.

3. Component example (code)

alert component

Alert Component

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

interface IAlertProps {
    icon: JSX.Element;
    headline: string;
    headlineColor: 'text-green-600' | 'bg-red-600';
    content: JSX.Element;
    hideClose?: boolean;
    bgColor: 'bg-green-100' | 'bg-red-100';
    timer?: number;
}

const Alert = ({ icon, headline, headlineColor, hideClose, timer, bgColor, content }: IAlertProps) => {
    const [isAlertOpen, setAlert] = useState(true);

    useEffect(() => {
        if (timer) {
            const timeId = setTimeout(() => {
                // After xx seconds set the show value to false, if exist timer as props
                setAlert(false);
            }, timer);

            return () => {
                clearTimeout(timeId);
            };
        }
    }, [timer]);

    const closeAlert = () => {
        setAlert(false);
    };

    return (
        <>
            {isAlertOpen && (
                <div className="fixed max-w-fit top-0 right-0 left-0 mx-auto mt-4 z-50">
                    <div className={`relative flex w-full rounded-lg p-4 ${bgColor}`}>
                        {!hideClose && (
                            <div
                                role="button"
                                className="absolute rounded-lg p-1 right-0 top-0 mr-2 mt-2"
                                onClick={closeAlert}
                            >
                                <svg
                                    xmlns="http://www.w3.org/2000/svg"
                                    className="h-6 w-6"
                                    viewBox="0 0 24 24"
                                    stroke="currentColor"
                                    stroke-width="2"
                                >
                                    <path
                                        stroke-linecap="round"
                                        stroke-linejoin="round"
                                        d="M6 18L18 6M6 6l12 12"
                                    ></path>
                                </svg>
                            </div>
                        )}

                        <div className={`flex w-8 h-8 ${headlineColor}`}>{icon}</div>
                        <div className="px-2">
                            <span className={`mb-2 font-bold ${headlineColor}`}>{headline}</span>
                            <div>{content}</div>
                        </div>
                    </div>
                </div>
            )}
        </>
    );
};

export default Alert;

Props explained

icon: It is literally an icon in svg format. In the example screen, it means a check mark icon.

headline & headlineColor: Put the title in string format, and decorate the color with tailwindcss `text...`. (required, can be modified)

content: Content can be entered in any format as long as it is jsx, and must be entered.

hideClose : It can also be disabled with the close button on the right.

bgColor : As the background color of the Alert window, you can also enter it using tailwincss `bg...`.

timer: SetTimeout & clearTimeout means how long the window disappears. In the example, 3 seconds (3000) were entered.

Example of using Alert Component (import)

            <Alert
                timer={3000}
                headline="Success"
                headlineColor="text-green-600"
                bgColor="bg-green-100"
                content={<span className="text-sm">Login succesful</span>}
                icon={
                    <svg
                        clip-rule="evenodd"
                        fill-rule="evenodd"
                        stroke-linejoin="round"
                        stroke-miterlimit="2"
                        viewBox="0 0 24 24"
                        xmlns="http://www.w3.org/2000/svg"
                        fill="currentColor"
                        stroke="currentColor"
                    >
                        <path
                            d="m11.998 2.005c5.517 0 9.997 4.48 9.997 9.997 0 5.518-4.48 9.998-9.997 9.998-5.518 0-9.998-4.48-9.998-9.998 0-5.517 4.48-9.997 9.998-9.997zm0 1.5c-4.69 0-8.498 3.807-8.498 8.497s3.808 8.498 8.498 8.498 8.497-3.808 8.497-8.498-3.807-8.497-8.497-8.497zm-5.049 8.886 3.851 3.43c.142.128.321.19.499.19.202 0 .405-.081.552-.242l5.953-6.509c.131-.143.196-.323.196-.502 0-.41-.331-.747-.748-.747-.204 0-.405.082-.554.243l-5.453 5.962-3.298-2.938c-.144-.127-.321-.19-.499-.19-.415 0-.748.335-.748.746 0 .205.084.409.249.557z"
                            fill-rule="nonzero"
                        />
                    </svg>
                }
            />

Codesandbox


reference

https://tailwindcomponents.com/component/alert-messages



Comments

Popular Posts

React Intersection Observer: Enhancing Web Development with Scroll-Based Interactions

  Table of Contents Introduction What is the Intersection Observer API? How does the Intersection Observer API work? Implementing the Intersection Observer API in React Benefits of using React Intersection Observer Examples of scroll-based interactions Best practices for using React Intersection Observer Conclusion FAQs 1. Introduction In the ever-evolving world of web development, creating engaging and interactive user experiences is essential. One technique that has gained popularity is scroll-based interactions, where elements on a webpage respond or animate based on the user's scrolling behavior. To achieve this functionality efficiently in a React application, developers often turn to the  React Intersection Observer  library. This article will explore the ins and outs of the React Intersection Observer and how it can enhance web development. 2. What is the Intersection Observer API? The Intersection Observer API is a browser API that allows developers to efficiently...

WordPress Page, Category, and Post: Understanding the Differences

  WordPress Page, Category, and Post: Understanding the Differences Table of Contents Introduction What is WordPress? Pages in WordPress 3.1 Creating Pages 3.2 Page Attributes 3.3 Parent Pages Categories in WordPress 4.1 Creating Categories 4.2 Assigning Categories 4.3 Category Organization Posts in WordPress 5.1 Creating Posts 5.2 Post Categories and Tags 5.3 Post Format Differences Between Pages, Categories, and Posts 6.1 Purpose and Structure 6.2 Navigation and Hierarchy 6.3 Content and Presentation Conclusion FAQs 1. Introduction WordPress is a popular content management system (CMS) that allows users to create and manage websites easily. It provides various tools and features to build a website, including the ability to create pages, categories, and posts. Understanding the differences between these three elements is essential for effectively organizing and presenting content on a WordPress site. 2. What is WordPress? WordPress is a versatile CMS used by millions of website ow...

Centering an image with media queries when in mobile mode

Centering an image with media queries when in mobile mode To center an image vertically and horizontally on a web page using CSS, you can use the following CSS code: .container { display : flex; justify-content : center; align-items : center; height : 100vh ; /* Adjust this value as needed */ } .container img { max-width : 100% ; max-height : 100% ; } In this example, we create a container element with the class name "container" that will hold the image. The container is styled as a flex container using  display: flex , which allows us to use flexbox properties for alignment. The  justify-content: center  property horizontally centers the image within the container, and  align-items: center  vertically centers the image. The  height: 100vh  sets the height of the container to 100% of the viewport height, but you can adjust this value as needed. The  img  selector inside the container sets  max-width: 100%  and ...

Enabling HTTPS on WordPress instances in Amazon Lightsail

  Enabling HTTPS on WordPress instances in Amazon Lightsail Introduction In today's digital landscape, ensuring the security of your website is of paramount importance. Hypertext Transfer Protocol Secure (HTTPS) is a protocol that provides secure communication over the internet, safeguarding sensitive data and building trust with your users. If you have a WordPress website hosted on Amazon Lightsail, this article will guide you through the process of enabling HTTPS to protect your website and enhance its credibility. Table of Contents What is HTTPS? Benefits of Enabling HTTPS Requirements for Enabling HTTPS on WordPress Instances in Amazon Lightsail Obtaining an SSL Certificate Installing an SSL Certificate Configuring WordPress for HTTPS Testing and Verifying HTTPS Setup Redirecting HTTP Traffic to HTTPS Updating Internal Links and Content Monitoring and Maintaining HTTPS Common Issues and Troubleshooting Best Practices for HTTPS Implementation Conclusion FAQs What is HTTPS? HTTPS...

Google Blogger: Connecting with Google Search Console

Google Blogger: Connecting with Google Search Console 1. Introduction In the world of blogging, maximizing your online visibility is crucial to attracting more readers and growing your audience. One effective way to enhance your blog's performance is by connecting Google Blogger with Google Search Console. This powerful integration allows you to monitor and optimize your blog's presence on Google's search engine, helping you reach a wider audience and improve your search rankings. In this article, we will explore the process of connecting Google Blogger with Google Search Console and delve into the benefits it brings to your blogging journey. 2. What is Google Blogger? Google Blogger, also known as Blogspot, is a popular blogging platform that allows users to create and manage their blogs for free. With a user-friendly interface and a range of customizable templates, Google Blogger offers an accessible and versatile platform for bloggers of all levels of experience. It prov...

WordPress .htaccess: Optimizing Your Website's Performance and Security

  WordPress .htaccess: Optimizing Your Website's Performance and Security Introduction In the world of website development, optimizing performance and ensuring security are crucial aspects. One of the powerful tools at your disposal is the .htaccess file in WordPress. This file allows you to configure various settings that can enhance your website's performance, improve search engine rankings, and protect it from malicious attacks. In this article, we will explore the concept of .htaccess in WordPress and provide you with valuable insights on how to utilize it effectively. Table of Contents What is .htaccess? The Role of .htaccess in WordPress Creating and Locating the .htaccess File URL Redirection and Canonicalization 4.1 Redirecting WWW to Non-WWW or Vice Versa 4.2 Setting Up Custom Redirects Enabling and Disabling Directory Browsing Enhancing Security with .htaccess 6.1 Protecting wp-config.php File 6.2 Preventing Unauthorized Access to wp-admin Directory 6.3 Blocking Suspi...

Connecting to AWS Lightsail using FileZilla (SFTP)

Connecting to AWS Lightsail using FileZilla (SFTP) AWS Lightsail  is  a service  of  Amazon Web Services  that  provides a  Virtual  Private  Server  (VPS) .  FileZilla  is  a *FTP (File Transfer Protocol)  client ,  used  for  file  transfers with  remote  servers .  To connect  to your AWS Lightsail  instance  using  FileZilla ,  follow  these  steps  :   *What is FTP  (File Transfer Protocol) ? FTP  stands  for  " File  Transfer  Protocol "  FTP  is a  standard  protocol  for  transferring  files  over  computer  networks  and  defines  a communication  method  for  transferring  files  between  a client and  a server . FTP  works  based  on  a client-server   model .  Clients...

React on Event Types

  React on Event Types React is a popular JavaScript library used for building user interfaces. One of its key features is the ability to handle events efficiently and effectively. In this article, we will explore different event types in React and how to handle them. 1. Introduction to React Events In React, events are actions or occurrences that happen in the browser, such as a button click, input change, or form submission. React provides a synthetic event system that normalizes event handling across different browsers and provides additional functionality for managing UI updates and state. 2. Event Handling in React Event handling in React can be done in two main ways: using class components and functional components. 2.1 Event Handling in Class Components In class components, event handling involves creating event handler methods. For example, to handle a button click event, you can define an  onClick  event handler method: class MyComponent extends React . Compon...

WordPress Multisite Domain Redirects to Wp-Signup PHP New Multisite

  What is WordPress Multisite? WordPress Multisite is a feature that enables users to create and manage multiple websites from a single WordPress installation. It allows administrators to set up a network of websites with shared resources, such as themes, plugins, and user accounts. Each website within the network can have its own domain or subdomain, providing a centralized platform for managing multiple sites efficiently. Understanding the Domain Redirect Issue The domain redirect issue occurs when a user's domain redirects to the wp-signup.php page, which is used to create a new multisite within WordPress. This issue prevents users from accessing their intended website and instead leads them to the multisite creation page. http://www.example.com/wp-signup.php?new=example.com Solution AWS  Lightsail If you use Lightsail, you can define the primary domain for your WordPress Multisite instance in Amazon Lightsail. Sign in to the  Lightsail console . On the Lightsail home ...