-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Implement image slider component!
Signed-off-by: Souptik Datta <souptikdatta2001@gmail.com>
- Loading branch information
1 parent
78245c1
commit 92f1881
Showing
7 changed files
with
191 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { Box, Icon, useToast, Image } from "@chakra-ui/react"; | ||
import he from 'he'; | ||
import { useEffect, useState, Children } from "react"; | ||
import { BiCopy } from 'react-icons/bi'; | ||
import { FaAngleLeft, FaAngleRight } from "react-icons/fa"; | ||
import '@travelopia/web-components/dist/slider/style.css'; | ||
|
||
const Slider = ({blocks, ...props}) => { | ||
|
||
useEffect(() => { | ||
function loadWebComponent() { | ||
import("@travelopia/web-components/dist/slider") | ||
} | ||
loadWebComponent(); | ||
}, []); | ||
|
||
let slides = []; | ||
let slideNavItems = []; | ||
|
||
blocks.forEach((block, index) => { | ||
slides.push( | ||
<tp-slider-slide key={index}> | ||
<Image src={block.attributes.url} alt={block.attributes.alt} height={block?.attributes?.height ?? 'auto'} width={block?.attributes?.width ?? 'auto'} /> | ||
{ | ||
block?.attributes?.caption !== '' | ||
&& | ||
<Box className="caption">{block?.attributes?.caption}</Box> | ||
} | ||
</tp-slider-slide> | ||
); | ||
|
||
slideNavItems.push( | ||
<tp-slider-nav-item key={index}></tp-slider-nav-item> | ||
) | ||
}); | ||
|
||
|
||
return ( | ||
<div className="slider-container"> | ||
<tp-slider flexible-height="yes" infinite="yes" swipe="yes"> | ||
<tp-slider-track> | ||
<tp-slider-arrow direction="previous"><button><FaAngleLeft /></button></tp-slider-arrow> | ||
<tp-slider-arrow direction="next"><button><FaAngleRight /></button></tp-slider-arrow> | ||
<tp-slider-slides> | ||
{slides} | ||
</tp-slider-slides> | ||
</tp-slider-track> | ||
<tp-slider-nav> | ||
{slideNavItems} | ||
</tp-slider-nav> | ||
</tp-slider> | ||
</div> | ||
); | ||
|
||
} | ||
|
||
export default Slider; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.test { | ||
height: 10px; | ||
width: 10px; | ||
color: white; | ||
content: "\00B7"; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
92f1881
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
souptik2001-github-io – ./
souptik2001-github-io-git-master-souptik2001.vercel.app
souptik2001-github-io-souptik2001.vercel.app
souptik2001-github-io.vercel.app
souptik.dev
www.souptik.dev