Skip to content

Commit

Permalink
feat(Tests): updated example application structure
Browse files Browse the repository at this point in the history
  • Loading branch information
wialy committed Feb 4, 2021
1 parent 436dcdf commit 5ece7e1
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import React from 'react';

import { Rocket } from '~/components/rocket-launcher/Rocket';

export const App: React.FC = () => {
return <div className='container'>🚀</div>;
return (
<div className='container'>
<Rocket />
</div>
);
};
16 changes: 16 additions & 0 deletions src/components/rocket-launcher/Rocket.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from 'react';

import { useRocket } from './useRocket';

export const Rocket: React.FC = () => {
const { fire, isFired } = useRocket();

return (
<div
className='rocket'
onClick={fire}
>
{isFired ? '🔥' : '🚀'}
</div>
);
};
13 changes: 13 additions & 0 deletions src/components/rocket-launcher/useRocket.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import {
useCallback, useState,
} from 'react';

export const useRocket = () => {
const [isFired, setIsFired] = useState(false);

const fire = useCallback(() => {
setIsFired(true);
}, []);

return { fire, isFired };
};
7 changes: 6 additions & 1 deletion src/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ $color: black;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: 5em;
background-color: $color;
}

.rocket {
cursor: pointer;
font-size: 6em;
user-select: none;
}

0 comments on commit 5ece7e1

Please sign in to comment.