Compare commits

...

7 commits

6 changed files with 97 additions and 0 deletions

View file

@ -0,0 +1,43 @@
# Frontend Prompt Template
Follow the existing patterns in this codebase to:
- xxxxxxxx
Requirements:
- xxxxx
Process (TDD - Test Driven Development):
1. Write a test first
2. Run the test to confirm it fails
3. Implement the code to make the test pass
4. Run the test to confirm it passes
5. Repeat for each new behavior
Code patterns to follow:
- First, explore the codebase to understand existing entity patterns
- Look at similar pages for reference
- Tests: follow existing patterns in cypress/e2e/
- Lines should not exceed 80 columns, but should use up to 80 columns when possible — do not split lines unnecessarily
- Imports: always put imports at the top of the file
- Variable names: use explicit, descriptive names — never single-letter or abbreviated variables (e.g., use sponsorship not s, event not e)
Git commit style:
- Present tense, imperative mood (add, create, test, fix)
- Lowercase
- Short (3-6 words)
- Match patterns found in git history
Git commits:
- Tests should be committed first, before implementation
- One commit per file - each new file gets its own commit
- Make commits SMALL and FREQUENT - every meaningful change should be a commit
- Commits are for reviewing and documenting the development of code
- A commit can be as simple as adding one import, one getter, one property, etc.
- Don't wait to commit - commit as you go
Branch naming:
- Use kebab-case (e.g., node-page text-page)
- Use descriptive feature names
- NEVER work directly on master - always create and work on a branch
Do not push anything. Make commits as you go.

View file

@ -29,4 +29,12 @@ class ViewController
return $response;
}
public function home(Response $response): Response
{
$html = file_get_contents(__DIR__ . '/../../views/templates/home.php', true);
$response->getBody()->write($html);
return $response;
}
}

View file

@ -13,6 +13,7 @@ $app = Bridge::create($container);
// change first param to false for production
$app->addErrorMiddleware(true, true, true);
$app->get('/home', [ViewController::class, 'home']);
$app->get('/admin', [ViewController::class, 'admin']);
$app->get('/admin/texts', [ViewController::class, 'texts']);
$app->get('/admin/texts/{textId}', [ViewController::class, 'text']);

20
cypress/e2e/home.cy.js Normal file
View file

@ -0,0 +1,20 @@
describe('The home page', () => {
beforeEach(() => {
cy.exec('npm run db:seed')
})
afterEach(() => {
cy.exec('npm run db:wipe')
})
it('displays heading', () => {
cy.visit('/home')
cy.get('h1').should('contain', 'Home')
})
it('displays texts from api', () => {
cy.intercept('GET', '/api/texts').as('getTexts')
cy.visit('/home')
cy.wait('@getTexts')
cy.get('#texts-list').should('contain', 'Tanach')
})
})

13
public/js/home.js Normal file
View file

@ -0,0 +1,13 @@
document.addEventListener('DOMContentLoaded', () => {
const textsList = document.getElementById('texts-list');
async function loadTexts() {
const response = await fetch('/api/texts');
const texts = await response.json();
textsList.innerHTML = texts
.map(text => '<li>' + text.name + '</li>')
.join('');
}
loadTexts();
});

12
views/templates/home.php Normal file
View file

@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<head>
<title>Daily Goals - Home</title>
</head>
<body>
<h1>Home</h1>
<ul id="texts-list">
</ul>
<script src="/js/home.js"></script>
</body>
</html>