React to print fixed footer overlapping contents - css

I am using a react-to-print library to print some reports that are dynamic. The problem is I need a fixed footer on every page while printing and I have a fixed footer which overlaps the content before going to new page . I know how position:fixed works and would have solved if reports weren't dynamic. What can be the possible fix here?
My PrintingComponenet is
<div className="page-footer">
<hr />
<p className="pt-1">For screening purposes only. Not for use in diagnostic procedures</p>
<div className="flex w-full items-center justify-between">
<div>
Printed By ( <span className="text-primary-700">{!isServer && window.location.hostname}</span>{" "}
) on {moment(new Date()).format("MMM Do YYYY, h:mm:ss A")}
</div>
<span>{member.member_code}</span>
</div>
</div>
<div className="w-full">
{Object.keys(test).map((el, index) => (
<div key={el}>
<div style={{ height: "100px" }} />
<div className=" bg-gray-700 mt-4 px-3 capitalize py-4 text-xl text-white font-medium space-y-2 whitespace-nowrap">
{el} Test Report
</div>
{el === "Body Mass Index" ? (
<>
<div className="flex mt-3 border-b pb-3">
<div className="text-gray-600 flex-1 text-2xl">Test Date</div>
<div className="text-gray-600 flex-1 text-2xl">Temperature</div>
<div className="text-gray-600 flex-1 text-2xl">Test Result</div>
</div>
{test[el].map((el: any, index: number) => (
<div key={el.test_date} className="flex mt-4 border-b pb-2 last:border-0 ">
<div className=" flex-1 text-xl">
<span className="block">{moment(utcDateToLocal(el.test_date)).format("MM/DD/YYYY")}</span>
<span className="block">{moment(utcDateToLocal(el.test_date)).format("h:mm A")}</span>
</div>
<div className=" flex-1 text-xl">
{el.temperature} {el.temperature && <>° F</>}{" "}
</div>
<div className=" flex-1 text-xl ">Test</div>
</div>
))}
</>
) : (
<>
<div className="flex mt-3 border-b pb-3">
<div className="text-gray-600 flex-1 text-2xl">Test Date</div>
<div className="text-gray-600 flex-1 text-2xl ">Test Result</div>
</div>
{test[el].map((el: any, index: number) => (
<div key={el.test_date} className="flex mt-4 border-b pb-2 last:border-0 ">
<div className=" flex-1 text-xl">
<span className="block">{moment(utcDateToLocal(el.test_date)).format("MM/DD/YYYY")}</span>
<span className="block">{moment(utcDateToLocal(el.test_date)).format("h:mm A")}</span>
</div>
<div className=" flex-1 text-xl ">
<div>Test Result</div>
<div>Test Result</div>
<div>Test Result</div>
<div>Test Result</div>
<div>Test Result</div>
</div>
</div>
))}
</>
)}
</div>
CSS for footer is
.page-footer {
height: 30px;
position: fixed;
bottom: 0;
width: 100%;
}
#media print {
.page-footer {
page-break-after: always;
}
}

Related

Center profile photo between top cover and left column

I am trying to center the rounded full image between the main cover photo and the left column. For some reason I cannot get it to move from the top left corner and I cannot see what I am doing wrong. I am using Tailwind CSS.
<Head :title="profile.name" />
<div class="relative w-full max-h-screen bg-gray-900 flex justify-start items-center rounded-lg">
<div class="relative flex w-full h-48 bg-gray-700">
<img :src="profile.cover_photo_path" class="cover-bg w-full "/>
<div class="absolute inset-0 bottom-0 left-0">
<img :src="profile.profile_photo_path" class="w-48 h-48 rounded-full border-2 border-red-600"/>
</div>
</div>
</div>
<div class="flex flex-row">
<!-- Left Column -->
<div class="bg-gray-900 w-1/3 h-96 z-0">
</div>
<!-- Right Column -->
<div class="bg-gray-900 w-2/3 h-48 z-0">
<div class="flex flex-row justify-between px-2 items-center h-12 border-b border-red-700">
<div class="text-white text-center font-normal"> Feed </div>
<div class="text-white text-center font-normal"> About </div>
<div class="text-white text-center font-normal"> Photos </div>
<div class="text-white text-center font-normal"> Videos </div>
<div class="text-white text-center font-normal"> Events </div>
<div class="text-white text-center font-normal"> Groups </div>
<div class="text-white text-center font-normal"> Pages </div>
<div class="text-white text-center font-normal"> Followers </div>
<div class="text-white text-center font-normal"> Following </div>
</div>
</div>
</div>
</template>
As far as I understood , you want the circle rounded image in the middle of cover and left sidebar vertically and over them.
So I had created this ,please verify if you want. Else I would rather suggest you to attach a screenshot of what you want .
<script src="https://cdn.tailwindcss.com"></script>
<div class="relative flex max-h-screen w-full items-center justify-start rounded-lg bg-gray-900">
<div class="relative flex h-48 w-full bg-gray-700">
<img src="http://codeskulptor-demos.commondatastorage.googleapis.com/GalaxyInvaders/back05.jpg" class="cover-bg w-full" />
<div class="absolute inset-0 top-1/2 left-10 z-10">
<img src="http://codeskulptor-demos.commondatastorage.googleapis.com/pang/IHXoEES.png" class="h-48 w-48 rounded-full border-2 border-red-600" />
</div>
</div>
</div>
<div class="flex flex-row">
<!-- Left Column -->
<div class="z-0 h-96 w-1/3 bg-gray-900"></div>
<!-- Right Column -->
<div class="z-0 h-48 w-2/3 bg-gray-800">
<div class="flex h-12 flex-row items-center justify-between border-b border-red-700 px-2">
<div class="text-center font-normal text-white">Feed</div>
<div class="text-center font-normal text-white">About</div>
<div class="text-center font-normal text-white">Photos</div>
<div class="text-center font-normal text-white">Videos</div>
<div class="text-center font-normal text-white">Events</div>
<div class="text-center font-normal text-white">Groups</div>
<div class="text-center font-normal text-white">Pages</div>
<div class="text-center font-normal text-white">Followers</div>
<div class="text-center font-normal text-white">Following</div>
</div>
</div>
</div>

I want to use next/image to fill half width in div container

i'm learning nextjs and tailwind css.
I want to fill half width using next/image.
but, it's using full width
function Slider() {
return (
<div className="w-full h-screen flex relative">
<div className="Arrow left-[10px]">
<ArrowLeftOutlined />
</div>
<div className="Wrapper h-full flex">
<div className=" w-screen h-screen flex items-center">
<div className="ImgContainer h-full flex-1 ">
<Image
className=""
src=""
layout="fill"
/>
</div>
<div className="Info flex-1 p-[50px]"></div>
</div>
</div>
<div className="Arrow right-[10px]">
<ArrowRightOutlined />
</div>
</div>
);
}
This is my code, plz let me know..
Set position: relative for the wrapping div
function Slider() {
return (
<div className="w-full h-screen flex relative">
<div className="Arrow left-[10px]">
<ArrowLeftOutlined />
</div>
<div className="Wrapper h-full flex">
<div className=" w-screen h-screen flex items-center">
<div className="ImgContainer h-full flex-1 relative">
<Image
className=""
src=""
layout="fill"
/>
</div>
<div className="Info flex-1 p-[50px]"></div>
</div>
</div>
<div className="Arrow right-[10px]">
<ArrowRightOutlined />
</div>
</div>
);
}

Is there a way to put these bars behind the circles?

I couldn't understand how to put these bars behind the circles:
REPL: https://play.tailwindcss.com/peSieAptHf
I'm trying with z-index but it doesn't work!
Is there an alternative way?
<div class="flex w-full p-20">
<div class="w-full">
<div class="flex mx-auto w-8 h-8 bg-gray-300 rounded-full"></div>
</div>
<div class="w-full">
<div class="relative">
<div class="flex mx-auto w-8 h-8 bg-blue-300 rounded-full"></div>
<div class="absolute inset-0 flex items-center -translate-x-2/4">
<div class="h-0.5 w-full bg-green-500"></div>
</div>
</div>
</div>
<div class="w-full">
<div class="relative">
<div class="mx-auto w-8 h-8 bg-blue-500 rounded-full"></div>
<div class="absolute inset-0 flex items-center -translate-x-2/4">
<div class="h-0.5 w-full bg-gray-700"></div>
</div>
</div>
</div>
<div class="w-full">
<div class="relative">
<div class="mx-auto w-8 h-8 bg-green-500 rounded-full"></div>
<div class="absolute inset-0 flex items-center -translate-x-2/4">
<div class="h-0.5 w-full bg-red-500"></div>
</div>
</div>
</div>
</div>
z-index can be triggered on the rounds if you reset the static position to relative via classes : relative z-10 .
<link href="https://cdnjs.cloudflare.com/ajax/libs/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet"/>
<div class="flex w-full p-20">
<div class="w-full">
<div class="flex mx-auto w-8 h-8 bg-gray-300 rounded-full relative z-10"></div>
</div>
<div class="w-full">
<div class="relative">
<div class="flex mx-auto w-8 h-8 bg-blue-300 rounded-full relative z-10"></div>
<div class="absolute inset-0 flex items-center -translate-x-2/4">
<div class="h-0.5 w-full bg-green-500"></div>
</div>
</div>
</div>
<div class="w-full">
<div class="relative">
<div class="mx-auto w-8 h-8 bg-blue-500 rounded-full relative z-10"></div>
<div class="absolute inset-0 flex items-center -translate-x-2/4 ">
<div class="h-0.5 w-full bg-gray-700"></div>
</div>
</div>
</div>
<div class="w-full">
<div class="relative">
<div class="mx-auto w-8 h-8 bg-green-500 rounded-full relative z-10"></div>
<div class="absolute inset-0 flex items-center -translate-x-2/4">
<div class="h-0.5 w-full bg-red-500"></div>
</div>
</div>
</div>
</div>
You need to set negative z-index to the bars.
To set negative z-index, check the docs at https://tailwindcss.com/docs/z-index#negative-values
After adding the negative z-index setup, your code should look like this:
<div class="flex w-full p-20">
<div class="w-full">
<div class="flex mx-auto w-8 h-8 bg-gray-300 rounded-full"></div>
</div>
<div class="w-full">
<div class="relative">
<div class="flex mx-auto w-8 h-8 bg-blue-300 rounded-full"></div>
<div class="-z-10 absolute inset-0 flex items-center -translate-x-2/4">
<div class="h-0.5 w-full bg-green-500"></div>
</div>
</div>
</div>
<div class="w-full">
<div class="relative">
<div class="mx-auto w-8 h-8 bg-blue-500 rounded-full"></div>
<div class="-z-10 absolute inset-0 flex items-center -translate-x-2/4">
<div class="h-0.5 w-full bg-gray-700"></div>
</div>
</div>
</div>
<div class="w-full">
<div class="relative">
<div class="mx-auto w-8 h-8 bg-green-500 rounded-full"></div>
<div class="-z-10 absolute inset-0 flex items-center -translate-x-2/4">
<div class="h-0.5 w-full bg-red-500"></div>
</div>
</div>
</div>
</div>
I tried doing it with css and it worked out:
.container {
width: 100px;
height: 100px;
background: red;
z-index: 9999;
}
.bar {
background: blue;
width: 200px;
height: 10px;
position: fixed;
margin-top: 50px;
margin-left: 80px;
z-index: -1;
}
Html:
<div class="bar"></div>
<div class="container"></div>

Aligning Content in Tailwind CSS

I need to align the image and the Orange and fruit on the center.
How will I do it the proper and correct way. It needs to align together with others.
Check my playground here CLICK HERE
expected output
<div class="bg-black overflow-auto h-screen pb-24 px-4 md:px-6">
<div class="flex flex-col w-full p-12">
<div class="flex flex-col w-full text-center items-center">
<div class="btc">
<button class="btn btn-back">Back</button>
<div class="flex gap-4">
<img src="https://picsum.photos/200/300" class="w-12 h-12" />
<div class="text-left text-white">
<p class="font-bold">Orange</p>
<p class="text-grey">fruit</p>
</div>
</div>
</div>
<h1 class="text-4xl text-white mb-5">
<span class="text-sm font-bold">Food</span>
</h1>
<div class="flex flex-row mt-8 gap-4">
<button class="btn btn-primary">Send Food</button>
<button class="btn btn-yellow">Receive Food</button>
</div>
<div class="flex flex-row mt-8 mb-16">
<button class="btn btn-change flex justify-center items-center">
<span class="w-5 h-5 bg-blue-button-bg rounded-full mr-2"></span>
<span>Change Food</span>
</button>
</div>
</div>
</div>
</div>
.btc {
#apply w-full mb-16;
display: grid;
grid-gap: 1rem;
grid-template-columns: auto;
justify-content: center;
position: relative;
}
.btn {
#apply text-white text-sm bg-transparent font-normal rounded-full border-2 h-10 w-52;
}
.btn-back {
#apply border-green-500 w-24;
}
.btn-primary {
#apply border-red-700;
}
.btn-yellow {
#apply border-yellow-300;
}
.btn-change {
#apply bg-blue-300 border-0 font-bold;
}
.btn-class {
position: absolute;
left: 0;
top: 0;
}
<div class="bg-black overflow-auto h-screen pb-24 px-4 md:px-6">
<div class="flex flex-col w-full p-12">
<div class="flex flex-col w-full text-center items-center">
<div class="btc">
<button class="btn btn-back btn-class">Back</button>
<div class="flex gap-4 new-div-class">
<img src="https://picsum.photos/200/300" class="w-12 h-12" />
<div class="text-left text-white">
<p class="font-bold">Orange</p>
<p class="text-grey">fruit</p>
</div>
</div>
</div>
<h1 class="text-4xl text-white mb-5">
<span class="text-sm font-bold">Food</span>
</h1>
<div class="flex flex-row mt-8 gap-4">
<button class="btn btn-primary">Send Food</button>
<button class="btn btn-yellow">Receive Food</button>
</div>
<div class="flex flex-row mt-8 mb-16">
<button class="btn btn-change flex justify-center items-center">
<span class="w-5 h-5 bg-blue-button-bg rounded-full mr-2"></span>
<span>Change Food</span>
</button>
</div>
</div>
</div>
</div>
I have edited your play. Here is the new link https://play.tailwindcss.com/qrDlxDYWW3

Using Hex colors with inline Styles with React from a graphQL query

I am trying to replicate the pinned repos on a github profile, to display my own within my website.
I have a working query, and a working component. However the color outputted via the query is a hex colour.
return (
<div className="grid grid-cols-1 gap-3 sm:grid-cols-2 mb-8">
{data.github.user.pinnedItems.edges.map(({node}) => (
<div className="flex flex-col justify-around border rounded-md">
<div className="p-4">
<div className="flex items-center mb-4">
<span className="h-3 w-3 mr-2"><GoRepo/></span>
<h2 className="font-semibold text-sm m-0">
{node.name}
</h2>
</div>
<div>
<p className="text-xs font-sans">{node.description}</p>
</div>
<div className="flex items-center mt-4">
<span className="bg-yellow-600 rounded-full h-3 w-3"></span>
<span className="text-xs ml-2 font-sans text-gray-600">{node.primaryLanguage.name}</span>
</div>
</div>
</div>
))}
</div>
)
The hex color is generated via {node.primaryLanguage.color} how can i use that hex color inline on the following?
<span className="bg-yellow-600 rounded-full h-3 w-3"></span> As I am currently just using bg-yellow-600 before I can figure it out.
I have tried the following:
const bgColor = {
backgroundColor: "{node.primaryLanguage.color}"
}
return (...
<span style={bgColor} className="rounded-full h-3 w-3"></span>
I was hoping to use the string as once it's run in map, it will fill the hex code but nothing.
import React from 'react'
import { graphql, useStaticQuery } from 'gatsby'
import { GoRepo } from "react-icons/go";
const PinnedRepos = () => {
const data = useStaticQuery(graphql`
query{
github {
user(login: "mrpbennett") {
pinnedItems(first: 6, types: REPOSITORY) {
edges {
node {
... on GitHub_Repository {
name
description
url
primaryLanguage {
name
color
}
}
}
}
}
}
}
}
`)
{data.github.user.pinnedItems.edges.map(({node}) => {
const bgColor = {
backgroundColor: node.primaryLanguage.color
}
return (
<div className="grid grid-cols-1 gap-4 sm:grid-cols-2">
<div className="flex flex-col justify-around border rounded-md">
<div className="p-4">
<div className="flex items-center mb-4">
<span className="h-3 w-3 mr-2"><GoRepo/></span>
<h2 className="font-semibold text-sm m-0">
{node.name}
</h2>
</div>
<div>
<p className="text-xs font-sans">{node.description}</p>
</div>
<div className="flex items-center mt-4">
<span stlye={bgColor} className="rounded-full h-3 w-3"></span>
<span className="text-xs ml-2 font-sans text-gray-600">{node.primaryLanguage.name}</span>
</div>
</div>
</div>
</div>
)
})}
}
export default PinnedRepos
Don't forget that what is wrapped between { } in React is real JavaScript. What I mean is that your .map() is just a function, where you can add any additional logic.
You just have to transform the arrow function from shorthand return to function body:
return (
<div className="grid grid-cols-1 gap-3 sm:grid-cols-2 mb-8">
{data.github.user.pinnedItems.edges.map(({node}) => {
const bgColor = {
backgroundColor: node.primaryLanguage.color
}
return (
<div className="flex flex-col justify-around border rounded-md">
<div className="p-4">
<div className="flex items-center mb-4">
<span className="h-3 w-3 mr-2"><GoRepo/></span>
<h2 className="font-semibold text-sm m-0">
{node.name}
</h2>
</div>
<div>
<p className="text-xs font-sans">{node.description}</p>
</div>
<div className="flex items-center mt-4">
<span style={bgColor} className="rounded-full h-3 w-3"></span>
<span className="text-xs ml-2 font-sans text-gray-600">{node.primaryLanguage.name}</span>
</div>
</div>
</div>
)})}
</div>
)

Resources