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

[ENH] Implemented landing view #37

Merged
merged 6 commits into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { defineConfig } from 'cypress';
import codeCoverageTask from '@cypress/code-coverage/task';

export default defineConfig({
viewportWidth: 1280,
viewportHeight: 720,
e2e: {
experimentalStudio: true,
baseUrl: 'http://localhost:5173',
Expand Down
9 changes: 7 additions & 2 deletions cypress/component/Landing.cy.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import Landing from '../../src/components/Landing';

describe('Landing', () => {
it('should render correctly', () => {
it('should render the content of Landing view correctly', () => {
cy.mount(<Landing />);
cy.contains('Welcome');
cy.contains('Welcome to the Neurobagel Annotation Tool');
cy.get('img[alt="Neurobagel Logo"]').should('be.visible');
cy.get('img[alt="Neurobagel Logo"]').should('have.attr', 'alt', 'Neurobagel Logo');
cy.get('img[alt="Landing emoji"]').should('be.visible');
cy.get('img[alt="Landing emoji"]').should('have.attr', 'alt', 'Landing emoji');
cy.get('[data-cy="get started-button"]').should('be.visible');
});
});
8 changes: 4 additions & 4 deletions cypress/e2e/Simple.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ describe('Simlpe e2e test', () => {
it('Steps through different app views', () => {
cy.visit('http://localhost:5173');
cy.contains('Welcome');
cy.contains('Start - Upload').click();
cy.get('[data-cy="get started-button"]').click();
cy.contains('Upload');
cy.contains('Next - Column Annotation').click();
cy.get('[data-cy="next - column annotation-button"]').click();
cy.contains('Column Annotation');
cy.contains('Next - Value Annotation').click();
cy.get('[data-cy="next - value annotation-button"]').click();
cy.contains('Value Annotation');
// reload to make sure the currentView persists
cy.reload();
cy.contains('Value Annotation');
cy.contains('Next - Download').click();
cy.get('[data-cy="next - download-button"]').click();
cy.contains('Download');
});
});
Binary file added src/assets/landing-emoji.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 23 additions & 3 deletions src/components/Landing.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,30 @@
import { Typography } from '@mui/material';
import NavigationButton from './NavigationButton';
import logo from '../assets/logo.svg';
import landingEmoji from '../assets/landing-emoji.png';

function Landing() {
return (
<div className="flex flex-col items-center">
<h1>Welcome</h1>
<NavigationButton label="Start - Upload" viewToNavigateTo="upload" />
<div className="flex min-h-screen flex-col items-center justify-center overflow-hidden">
<img src={logo} alt="Neurobagel Logo" className="mb-6 h-36 w-36 animate-spin-slow" />

<div className="text-center">
<div className="flex items-center space-x-4">
<img src={landingEmoji} alt="Landing emoji" className="mb-6 h-24 w-24" />
<Typography variant="h3" component="h1" className="font-bold">
Welcome to the Neurobagel Annotation Tool
</Typography>
</div>

<Typography variant="subtitle1" className="text-gray-600">
This tool allows you to create a machine-readable BIDS data dictionary in .json format for
a tabular phenotypic file in .tsv format.
</Typography>
</div>

<div className="mt-8">
<NavigationButton label="Get Started" viewToNavigateTo="upload" />
</div>
</div>
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/NavigationButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function NavigationButton({
};

return (
<Button variant="contained" onClick={handleClick}>
<Button data-cy={`${label.toLowerCase()}-button`} variant="contained" onClick={handleClick}>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that might be a bit risky as a cypress selector, no? What if we change the label, should that break the tests? Not sure what the best solution here is. Maybe numeric identifiers for the views you can navigate to? That might change less frequently

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmm what would that look like?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question. I guess the goal would be to have persistent and unique identifiers for each page/view you can navigate to. Numeric identifiers are easy to make unique and persistent, but they are hard to read and debug. So maybe just a string identifier like column_annotation and multi_column_annotation and so on. Presumably such a list would have to live in the central store of the app.

But maybe let's discuss this first in an issue and then make a decision and implement.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, let's do that cause I'm not sure if it's a good idea to keep that in the store. Could you please open the issue?

{label}
</Button>
);
Expand Down
12 changes: 11 additions & 1 deletion tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,17 @@
export default {
content: ['./index.html', './src/**/*.{js,ts,jsx,tsx}'],
theme: {
extend: {},
extend: {
keyframes: {
'spin-slow': {
'0%': { transform: 'rotate(0deg)' },
'100%': { transform: 'rotate(360deg)' },
},
},
animation: {
'spin-slow': 'spin-slow 5s linear infinite',
},
},
},
plugins: [],
corePlugins: {
Expand Down
Loading