Skip to content

Commit

Permalink
dewi's magic page
Browse files Browse the repository at this point in the history
  • Loading branch information
dewierwan committed May 14, 2024
1 parent 1be7622 commit bb7b4cc
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 0 deletions.
Binary file added apps/frontend-example/public/aisf.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/frontend-example/public/bdi.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/frontend-example/public/bsf.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions apps/frontend-example/src/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,8 @@
html {
@apply bg-cream-normal text-bluedot-black antialiased
}

html, body {
height: 100%;
margin: 0;
}
51 changes: 51 additions & 0 deletions apps/frontend-example/src/pages/dewi.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { useState, useEffect } from 'react';
import {
H1, P,
} from '@bluedot/ui';

const Dewi = () => {
const [value, setValue] = useState(0);
const colors = ['red', 'blue', 'green', 'yellow', 'purple', 'orange']; // Add more colors as needed
const images = ["bdi.png", "aisf.png", "bsf.png"]; // Array of images

Check failure on line 9 in apps/frontend-example/src/pages/dewi.tsx

View workflow job for this annotation

GitHub Actions / ci

Strings must use singlequote

Check failure on line 9 in apps/frontend-example/src/pages/dewi.tsx

View workflow job for this annotation

GitHub Actions / ci

Strings must use singlequote

Check failure on line 9 in apps/frontend-example/src/pages/dewi.tsx

View workflow job for this annotation

GitHub Actions / ci

Strings must use singlequote

// Function to get the next color based on the current value
const getNextColor = () => colors[value % colors.length];
const getCurrentImage = () => images[value % images.length];

useEffect(() => {
// Set up an interval that updates the value every 1000 milliseconds (1 second)
const interval = setInterval(() => {
setValue((currentValue) => currentValue + 1);
}, 200);

// Clean up the interval when the component is unmounted
return () => clearInterval(interval);
}, []);

useEffect(() => {
// Update the background color of the body
document.body.style.backgroundColor = getNextColor();
// Ensure the body takes up the full height
document.body.style.height = '100%';
}, [value]); // Dependency array to run effect when value changes

return (
<>
<style>
{`
html, body {
height: 100%;
margin: 0;
}
`}
</style>
<div className="mx-8">
<H1>Dewi's magic page</H1>
<P className="mt-8">Value is {value}</P>
<img src={getCurrentImage()} alt="Dynamic Image" style={{ width: '300px' }} />

Check failure on line 45 in apps/frontend-example/src/pages/dewi.tsx

View workflow job for this annotation

GitHub Actions / ci

Redundant alt attribute. Screen-readers already announce `img` tags as an image. You don’t need to use the words `image`, `photo,` or `picture` (or any specified custom words) in the alt prop
</div>
</>
);
};

export default Dewi;

Check failure on line 51 in apps/frontend-example/src/pages/dewi.tsx

View workflow job for this annotation

GitHub Actions / ci

Newline required at end of file but not found

0 comments on commit bb7b4cc

Please sign in to comment.