Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add events name ticker #68

Merged
merged 7 commits into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions .env.sample
ashutosh-rath02 marked this conversation as resolved.
Show resolved Hide resolved

This file was deleted.

42 changes: 42 additions & 0 deletions config/content/TickerData.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
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_2_tuocil.png',
},
{
type: 'text',
content: 'Fun Events',
},
{
type: 'image',
content: 'https://res.cloudinary.com/dhnkuonev/image/upload/v1695746152/Group_1_mlxhs3.png',
},
{
type: 'text',
content: 'Workshops',
},
{
type: 'image',
content: 'https://res.cloudinary.com/dhnkuonev/image/upload/v1695746152/Group_2_1_ddiagd.png',
},
{
type: 'text',
content: 'Lectures',
},
{
type: 'image',
content: 'https://res.cloudinary.com/dhnkuonev/image/upload/v1695746152/Group_3_x0pceh.png',
},
];
49 changes: 49 additions & 0 deletions src/components/Ticker/Ticker.jsx
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()}
ashutosh-rath02 marked this conversation as resolved.
Show resolved Hide resolved
{generateTickerItems()}
{generateTickerItems()}
</TickerMover>
</TickerContainer>
<TickerContainer>
<TickerMover reverse>
{generateTickerItems()}
{generateTickerItems()}
{generateTickerItems()}
</TickerMover>
</TickerContainer>
</div>
);
}

export default Ticker;
63 changes: 63 additions & 0 deletions src/components/Ticker/styles.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
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-16
mb-4
`}
@media (max-width: 768px) {
margin: 0.5rem 0.5rem;
height: 2.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)} 160s linear infinite;

@media (max-width: 720px) {
animation: ${({ reverse }) => (reverse ? reverseTicker : ticker)} 110s linear infinite;
}
`;
4 changes: 2 additions & 2 deletions src/pages/playground.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable jsx-a11y/click-events-have-key-events */
import React from 'react';
import { Helmet } from 'react-helmet';
import FAQSection from '../components/FAQSection/FAQSection';
import Ticker from '../components/Ticker/Ticker';

const Playground = () => (
<>
Expand All @@ -10,7 +10,7 @@ const Playground = () => (
<title>Playground</title>
<meta name='description' content='This is playground' />
</Helmet>
<FAQSection />
<Ticker />
</>
);

Expand Down