forked from MystenLabs/sui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds Tailwind CSS, Mock Transaction Data, Search Function and Transac…
…tion Results Page (MystenLabs#471) * Implements a Tailwind CSS approach that compartmentalizes styling * Adds a mock transaction JSON dataset for testing and to facilitate work on the UI while API is in development (see `./explorer/client/src/utils/transaction_mock.json`) * Adds the Search Function * Adds the Transaction Results page * Implements 'Japanese Streetwear' look with Yoshimichi Ohira fonts from Google Fonts * Updates the tests to reflect the new functionality * Implements a logical structure to the `src` code with `pages` for complete pages and `components` for things that are part of a page
- Loading branch information
Showing
28 changed files
with
559 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import { render, screen, fireEvent } from '@testing-library/react'; | ||
import { createMemoryHistory } from 'history'; | ||
import { | ||
MemoryRouter, | ||
unstable_HistoryRouter as HistoryRouter, | ||
} from 'react-router-dom'; | ||
|
||
import App from '../app/App'; | ||
|
||
function expectHome() { | ||
expect(screen.getByText(/Latest Transactions/i)).toBeInTheDocument(); | ||
} | ||
|
||
function searchText(text: string) { | ||
fireEvent.change( | ||
screen.getByPlaceholderText(/Search transactions by ID/i), | ||
{ target: { value: text } } | ||
); | ||
fireEvent.submit(screen.getByRole('form', { name: /search form/i })); | ||
} | ||
|
||
function expectTransactionStatus(result: 'fail' | 'success') { | ||
expect(screen.getByTestId('transaction-status')).toHaveTextContent(result); | ||
} | ||
|
||
describe('App component', () => { | ||
it('renders the home page', () => { | ||
render(<App />, { wrapper: MemoryRouter }); | ||
expectHome(); | ||
}); | ||
it('redirects to home for every unknown path', () => { | ||
render( | ||
<MemoryRouter initialEntries={['/anything']}> | ||
<App /> | ||
</MemoryRouter> | ||
); | ||
expectHome(); | ||
}); | ||
it('redirects to home for unknown path by replacing the history', () => { | ||
const history = createMemoryHistory({ initialEntries: ['/anything'] }); | ||
render( | ||
<HistoryRouter history={history}> | ||
<App /> | ||
</HistoryRouter> | ||
); | ||
expectHome(); | ||
expect(history.index).toBe(0); | ||
}); | ||
it('redirects to transaction details', () => { | ||
render(<App />, { wrapper: MemoryRouter }); | ||
searchText( | ||
'A1dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd' | ||
); | ||
expect(screen.getByText('Transaction ID')).toBeInTheDocument(); | ||
expectTransactionStatus('success'); | ||
}); | ||
it('complains when transaction cannot be found', () => { | ||
render(<App />, { wrapper: MemoryRouter }); | ||
searchText( | ||
'A1ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddde' | ||
); | ||
expect( | ||
screen.getByText('This transaction could not be found:') | ||
).toBeInTheDocument(); | ||
}); | ||
it('details a transaction failure', () => { | ||
render(<App />, { wrapper: MemoryRouter }); | ||
searchText( | ||
'A2dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd' | ||
); | ||
expectTransactionStatus('fail'); | ||
}); | ||
|
||
it('redirects to search result', () => { | ||
render(<App />, { wrapper: MemoryRouter }); | ||
searchText('Mysten Labs'); | ||
expect( | ||
screen.getByText('Search results for "Mysten Labs"') | ||
).toBeInTheDocument(); | ||
}); | ||
it('returns home when Home is clicked', () => { | ||
render(<App />, { wrapper: MemoryRouter }); | ||
searchText('Mysten Labs'); | ||
fireEvent.click(screen.getByRole('link', { name: /home button/i })); | ||
expectHome(); | ||
}); | ||
it('returns home when Title Logo is clicked', () => { | ||
render(<App />, { wrapper: MemoryRouter }); | ||
searchText('Mysten Labs'); | ||
fireEvent.click(screen.getByRole('link', { name: /logo/i })); | ||
expectHome(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
.app { | ||
@apply font-sans w-screen; | ||
} | ||
|
||
.search > h2 { | ||
@apply ml-[5vw] mb-[1vh]; | ||
} | ||
|
||
.search { | ||
@apply bg-black text-white pb-4 w-[100vw]; | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
explorer/client/src/components/external-link/ExternalLink.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
function ExternalLink({ href, label }: { href: string; label: string }) { | ||
return ( | ||
<a href={href} target="_blank" rel="noreferrer noopener"> | ||
{label} | ||
</a> | ||
); | ||
} | ||
|
||
export default ExternalLink; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.footer { | ||
@apply fixed bottom-0 bg-black w-full px-[5vw]; | ||
} | ||
|
||
.links > a { | ||
@apply text-white no-underline hover:underline leading-[5vh] mr-[5vw]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { Link } from 'react-router-dom'; | ||
|
||
import ExternalLink from '../external-link/ExternalLink'; | ||
import styles from './Footer.module.css'; | ||
|
||
function Footer() { | ||
return ( | ||
<footer className={styles.footer}> | ||
<nav className={styles.links}> | ||
<Link to="/" aria-label="home button"> | ||
Home | ||
</Link> | ||
<ExternalLink | ||
href="https://mystenlabs.com/" | ||
label="Mysten Labs" | ||
/> | ||
<ExternalLink | ||
href="https://devportal-30dd0.web.app/" | ||
label="Developer Hub" | ||
/> | ||
</nav> | ||
</footer> | ||
); | ||
} | ||
|
||
export default Footer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
.logo { | ||
@apply font-advanced text-2xl lg:text-4xl text-black | ||
no-underline; | ||
} | ||
|
||
.nav { | ||
@apply mt-[1vh] ml-[5vw]; | ||
} | ||
|
||
header { | ||
@apply h-[2rem]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Link } from 'react-router-dom'; | ||
|
||
import styles from './Header.module.css'; | ||
|
||
const Header = () => { | ||
return ( | ||
<header> | ||
<nav className={styles.nav}> | ||
<Link to="/" aria-label="logo" className={styles.logo}> | ||
Mysten Labs | ||
</Link> | ||
</nav> | ||
</header> | ||
); | ||
}; | ||
|
||
export default Header; |
Oops, something went wrong.