-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4a329ba
commit c06d246
Showing
5 changed files
with
150 additions
and
10 deletions.
There are no files selected for viewing
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
export const tickerData = [ | ||
{ | ||
type: 'text', | ||
content: 'Technical Events', | ||
}, | ||
{ | ||
type: 'image', | ||
content: 'https://res.cloudinary.com/dhnkuonev/image/upload/v1695746152/Group_3_x0pceh.png', | ||
}, | ||
{ | ||
type: 'text', | ||
content: 'Exhibitions', | ||
}, | ||
{ | ||
type: 'image', | ||
content: 'https://res.cloudinary.com/dhnkuonev/image/upload/v1695746152/Group_3_x0pceh.png', | ||
}, | ||
{ | ||
type: 'text', | ||
content: 'Fun Events', | ||
}, | ||
{ | ||
type: 'image', | ||
content: 'https://res.cloudinary.com/dhnkuonev/image/upload/v1695746152/Group_3_x0pceh.png', | ||
}, | ||
{ | ||
type: 'text', | ||
content: 'Workshops', | ||
}, | ||
{ | ||
type: 'image', | ||
content: 'https://res.cloudinary.com/dhnkuonev/image/upload/v1695746152/Group_3_x0pceh.png', | ||
}, | ||
{ | ||
type: 'text', | ||
content: 'Lectures', | ||
}, | ||
]; |
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,49 @@ | ||
import React from 'react'; | ||
|
||
import { tickerData } from '../../../config/content/TickerData'; | ||
import { TickerContainer, TickerMover, ItemContainer, TickerIcon } from './styles'; | ||
import { Heading1 } from '../shared'; | ||
|
||
function generateTickerItems() { | ||
return tickerData.map((item, index) => { | ||
let key; | ||
if (item.type === 'text') { | ||
key = `text-${item.content}`; | ||
} else { | ||
key = `image-${index}`; | ||
} | ||
|
||
return ( | ||
<ItemContainer key={key}> | ||
{item.type === 'text' ? ( | ||
<Heading1>{item.content}</Heading1> | ||
) : ( | ||
<TickerIcon style={{ paddingTop: '20px' }} src={item.content} alt={`divider-${index}`} /> | ||
)} | ||
</ItemContainer> | ||
); | ||
}); | ||
} | ||
|
||
function Ticker() { | ||
return ( | ||
<div> | ||
<TickerContainer> | ||
<TickerMover> | ||
{generateTickerItems()} | ||
{generateTickerItems()} | ||
{generateTickerItems()} | ||
</TickerMover> | ||
</TickerContainer> | ||
<TickerContainer> | ||
<TickerMover reverse> | ||
{generateTickerItems()} | ||
{generateTickerItems()} | ||
{generateTickerItems()} | ||
</TickerMover> | ||
</TickerContainer> | ||
</div> | ||
); | ||
} | ||
|
||
export default Ticker; |
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,61 @@ | ||
import styled, { keyframes } from 'styled-components'; | ||
import tw from 'twin.macro'; | ||
|
||
export const TickerContainer = styled.div` | ||
${tw` | ||
w-full | ||
overflow-hidden | ||
py-1 | ||
`} | ||
`; | ||
|
||
export const ItemContainer = styled.div` | ||
${tw` | ||
inline-block | ||
mx-12 | ||
h-10 | ||
`} | ||
@media (max-width: 768px) { | ||
margin: 0.5rem 0.5rem; | ||
} | ||
`; | ||
|
||
export const TickerIcon = styled.img` | ||
${tw` | ||
my-auto | ||
`} | ||
@media (max-width: 720px) { | ||
width: 30px; | ||
} | ||
`; | ||
const ticker = keyframes` | ||
0% { | ||
transform: translate(0, 0); | ||
} | ||
100% { | ||
transform: translate(-200%, 0); | ||
} | ||
`; | ||
const reverseTicker = keyframes` | ||
0% { | ||
transform: translate(-100%, 0); | ||
} | ||
100% { | ||
transform: translate(200%, 0); | ||
} | ||
`; | ||
|
||
export const TickerMover = styled.div` | ||
${tw` | ||
inline-block | ||
whitespace-nowrap | ||
`} | ||
&:hover { | ||
animation-play-state: paused; | ||
} | ||
animation: ${({ reverse }) => (reverse ? reverseTicker : ticker)} 70s linear infinite; | ||
@media (max-width: 720px) { | ||
animation: ${({ reverse }) => (reverse ? reverseTicker : ticker)} 50s linear infinite; | ||
} | ||
`; |
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