Skip to content

Commit

Permalink
frontend: Add files for library components.
Browse files Browse the repository at this point in the history
Added starter files for input, button etc.
Updated the docs with the changes.
  • Loading branch information
kuv2707 committed May 30, 2024
1 parent 9276376 commit c701629
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CONVENTIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
## For React Components
- Use functional components with hooks instead of class based components.
- Avoid copy pasting code. If you find yourself copying and pasting code, consider refactoring it into a reusable component or function. Use array methods like `map`, `filter`, and `reduce` to avoid duplicating code.
- Try to use tailwind for css styling as much as possible. If you need to write custom css, use CSS modules. Avoid using global styles, unless they actually need to be global. Take `input.tsx` as reference.


## Commit Message Guidelines
Expand Down Expand Up @@ -53,5 +54,6 @@
- Avoid unnecessary code duplication and strive for code reusability.
- Write clear and concise documentation for public APIs and important functions. Do not over-document trivial functions.
- We are using TypeScript in a very lenient and flexible setting. The project can have both JS and TS files, and one of the goals would be to convert all files to TS eventually. Where you are not using types.
- Try to keep the use of external dependencies to a minimum. This is because the purpose of project is first to learn and then to build. So, we will try to build as much as possible from scratch.
Remember to review and adhere to these conventions to maintain a clean and consistent codebase.
3 changes: 2 additions & 1 deletion frontend/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { useState } from 'react';
import './App.css';
import Navbar from './Navbar';

function App() {
const [count, setCount] = useState(0);
const a = 5;
console.log(a);
return (
<>
<h1>UNO!!!</h1>
<Navbar></Navbar>
<p>Lets play a game of UNO! Click the button to draw a card.</p>
<p>Card: {count}</p>
<button onClick={() => setCount(count + 1)}>Draw a card</button>
Expand Down
9 changes: 9 additions & 0 deletions frontend/src/Navbar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
function Navbar() {
return (
<div>
UNO!!!
</div>
)
}

export default Navbar
17 changes: 17 additions & 0 deletions frontend/src/library/button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Design a flexible reusable button component that can be used in different parts of the application.
// The button component should have the following features:
// - Customize background color, text color, and border color
// - Customize the size of the button (small, medium, large)
// - Customize the shape of the button (rectangle, rounded, circle)
// - Handles click events


function Button() {
return (
<div>

</div>
)
}

export default Button
Empty file.
2 changes: 2 additions & 0 deletions frontend/src/library/input.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

/* rules defined in this file are scoped to the js/ts file importing this. */
15 changes: 15 additions & 0 deletions frontend/src/library/input.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import styles from './input.module.css';

type InputComponentProps = {
placeholder?: string;
};

function Input({ placeholder }: InputComponentProps) {
return (
<div>
<input style={styles} placeholder={placeholder}></input>
</div>
);
}

export default Input;

0 comments on commit c701629

Please sign in to comment.