"Create a dynamic entrance and exit effect with Tailwind CSS sliding in and out from

My goal is to create a smooth sliding animation for this div that displays details of a clicked project, transitioning in and out from the right side.

This is my attempt using Tailwind CSS:

{selectedProject !== null && (
        <div
          className={`fixed top-0 right-0 w-full h-full md:w-1/2 z-20 bg-white px-5 py-10 overflow-scroll transform transition duration-600 ${
            selectedProject !== null ? 'translate-x-0' : 'translate-x-full'
          }`}
        >
           <div
              className="flex items-center justify-between w-full px-1 py-2"
              onClick={closeDetails}
          >
             <div>
                <Image
                  src={back}
                  alt={back}
                  quality={100}
                  height={30}
                  width={30}
                  placeholder="blur"
                  className="cursor-pointer"
                />
              </div>
              <Link href="#projects">
                 <div onClick={closeDetails} className="font-bold cursor-pointer">
                    Back to projects
                 </div>
              </Link>
          </div>
          <hr className="pb-10" />
          <p className="text-lg font-extrabold text-black pb-1">{projects[selectedProject].name}</p>
          <p className="text-gray-700 text-base pb-4 ">{projects[selectedProject].details}</p>
          <Image
            src={projects[selectedProject].image}
            alt={`${projects[selectedProject].name} screenshot`}
            quality={100}
            placeholder="blur"
            blurDataURL="iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mOMzoyuBwAD5gGgL5NkuQAAAABJRU5ErkJggg=="
            className="h-72 md:h-80 max-w-auto rounded-lg"
          />
          <p className="text-base font-bold text-black pb-1 pt-7">About</p>
          <p className="text-xs md:text-base">{projects[selectedProject].details}</p>
          <p className="text-base font-bold text-black pb-1 pt-7">
            Technologies
          </p>
          <div className="mt-5">
            <div className="flex flex-wrap gap-3 mt-3">
              {projects[selectedProject].skills.map((skill, skillIndex) => (
                <span
                  key={skillIndex}
                  className="w-fit inline-flex items-center rounded-md bg-indigo-50 px-2 py-1 text-sm font-medium text-black ring-1 ring-inset ring-indigo-700/10"
                >
                  {skill}
                </span>
              ))}
            </div>
          </div>
          <div className="w-fit gap-1 flex items-center">
            <Image
              src={earth}
              alt="earth icon"
              quality={100}
              height={20}
              width={20}
              placeholder="blur"
              className="cursor-pointer"
            />
            <p className="text-base font-bold text-black pb-1 pt-7">Website</p>
          </div>
          <Link href={projects[selectedProject].link}>
            {projects[selectedProject].link}
          </Link>
          <div className="w-fit gap-3 flex items-center">
            <Image
              src={github}
              alt="github icon"
              quality={100}
              height={20}
              width={20}
              placeholder="blur"
              className="cursor-pointer"
            />
            <p className="text-base font-bold text-black pb-1 pt-7">Github</p>
          </div>
          <Link href={projects[selectedProject].github}>
            {projects[selectedProject].github}
          </Link>
        </div>
      )}

I am struggling to achieve the desired functionality with this code. The same issue persists when applying a similar feature to my menu bar as well, so finding a solution here should solve multiple problems.

Answer №1

To achieve the desired outcome, consider removing the conditional statement that surrounds the component and focusing solely on styling.

Another option is to utilize a tool like Headless UI transitions for this purpose. If your content relies heavily on the conditional statement,

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Looking for specific data in AngularJS using a filter

I'm facing a situation where I have to search based on filtered values. Below is the code snippet var app = angular.module('MainModule', []); app.controller('MainCtrl', function($scope) { $scope.searchText = '& ...

MUI: reveal multiple selection when hovering & prevent dropdown from moving around

Utilizing material ui, I am facing two issues with a multiple select component that I cannot seem to resolve: While selecting an item, the dropdown moves around (I have already attempted solutions like MenuProps={{ variant: "menu", getContentAnc ...

Grouping items by a key in Vue and creating a chart to visualize similarities among those keys

I am working with an object that has the following structure; { SensorA: [ { id: 122, valueA: 345, "x-axis": 123344 }, { id: 123, valueA: 125, "x-axis": 123344 }, { id: 123, valueA: 185, "x-axis": 123344 }, { ...

Navigating from an error page to the homepage with Next.JS 13: A quick and easy guide

I'm currently working on implementing a feature that allows users to easily go back to the main page from an error page within the app folder. Specifically, in my weather app project, if a user enters an incorrect city, they should have the option to ...

How can not-found.tsx be utilized within the [lang] directory in Next.js 14?

Currently facing an issue with my Next.js 14 project that utilizes the app router. I have organized my pages, including page.tsx and layout.tsx, inside a [lang] folder for localization purposes. Here's an example of how I pass locale to all my pages: ...

The point in the vector data is incorrectly positioned on the map in OpenLayers

I am looking to display a world map using the default OpenLayers WMS, along with a single point on it that will have interactive events like onhover. Below is my code snippet: var options = { projection: ...

An error has occurred: Noty (notification library) is not defined in this AngularJS Web Application

I am currently diving into the world of AngularJS and building a web application from scratch. As a newbie to AngularJS, I want to point out that I might be missing something crucial. An issue has arisen: After installing the Noty library (npm install no ...

"The issue with Firebase Realtime Database arises when using NextJS after the build process, resulting in an error of 'Maximum call

Utilizing Firebase Realtime Database with Next.js for the backend implementation has been my approach. I have included the code snippet below. However, it seems to function properly only in a local environment, failing when deployed to production. I inten ...

Is there a more efficient method to achieve the desired effect without making multiple calls to jQuery ajaxSuccess?

Currently, I am working on creating an effect that involves a quick fade-out followed by a fade-in of the element once the request is successful. Since jQuery processes elements in a routine manner (top to bottom), I have managed to achieve my desired eff ...

Retrieving column values from a Datatable is limited to the first 10 rows

Trying to extract the values from column 1. I followed the instructions provided in the datatable documentation: var data = table.column( 0 ).data(); Table setup: var datatable = table.dataTable({ "scrollX" : "100%", "scrollY" ...

Implementing a constant loop repeatedly in NextJs

I am seeking assistance with printing the <Icon /> 700 times on a single page. As a newcomer to NextJs, I have successfully used a for loop to console.log the icons but am unsure of how to actually display them. Any help would be greatly appreciated. ...

Looking for a substitute for iframes when using jQuery UI tabs?

I currently have a Spring-based web application that integrates with jQuery Tabs. What I'm doing is building a data string with specific parameters and appending it to a URL: var hrefData = "?" + item1 + "&" + item2 + "&" + item3; var href = ...

Unspecified parameter for Next.js dynamic route

Currently, I am developing an e-commerce application using next.js with Typescript and MongoDB. To better understand my project, let's take a look at my existing file structure: https://i.stack.imgur.com/tZqVm.png The mainPage.tsx file is responsibl ...

The Angular scope remains stagnant even after applying changes

Having trouble updating a variable in the ng-repeat loop <div ng-controller="MapViewCtrl"> <a class="item item-avatar" ng-href="#/event/tabs/mapView" > <img src="img/location.jpg"/> <span cl ...

looping through the iteration

Here is a link to my original plunker demonstration: http://plnkr.co/edit/9UBZ9E4uxAo1TXXghm1T?p=preview. In the case of div 4 (ng-if="show==4"), I am looking for a way to hide the particular div when the list is empty. Currently, each div is displayed fo ...

Tips for switching the status of each item as I navigate the page with the tab key

I am facing an issue with my list of items that have hidden content appearing on hover. I want to achieve the same functionality while tabbing through my page, but currently, all hidden content appears at once. Check out a live example of my code here jQ ...

Exploring client-server relationships within the Express framework

Is there a way to transfer an object to JavaScript on the client side? I previously asked this question and received an answer, but because I was unable to check it on my computer, I accepted the response. You can view the details here: Client receive jso ...

Has the Angular 2 community established a standardized ecosystem?

As a developer specializing in Angular 1, I am now eager to dive into the world of Angular 2. However, navigating through the changes and rewrites can feel like traversing a confusing maze. All of the comprehensive guides I have come across date back to l ...

Search for elements with a specific substring in their class names using the querySelectorAll() method

I'm working with a custom component in app.js return ( {cards.map((index) => { return <Card key={index} /> ) Within the Card component, I assigned a specific className return ( <ListItem id="root" className="find-card"&g ...

The CORS policy is preventing the AJAX request from functioning properly on localhost

Recently, I have been working on an Angular application that requires interaction with an API. To test it out, I set up an API on my localhost and made a request using AJAX. However, I encountered the dreaded CORS error. Despite trying various solutions fo ...