-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7bd6b65
commit 5db2b32
Showing
96 changed files
with
4,422 additions
and
268 deletions.
There are no files selected for viewing
37 changes: 12 additions & 25 deletions
37
exercises/01.start/01.problem.ssr/src/ship-search-results.js
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 |
---|---|---|
@@ -1,42 +1,29 @@ | ||
import { createElement as h } from 'react' | ||
import { getImageUrlForShip } from './img-utils.js' | ||
|
||
const shipFallbackSrc = '/img/fallback-ship.png' | ||
|
||
export function SearchResults({ shipId: currentShipId, shipResults }) { | ||
return shipResults.ships.map(ship => | ||
h( | ||
export function SearchResults({ shipId: currentShipId, shipResults, search }) { | ||
return shipResults.ships.map(ship => { | ||
const href = [ | ||
`/${ship.id}`, | ||
search ? `search=${encodeURIComponent(search)}` : null, | ||
] | ||
.filter(Boolean) | ||
.join('?') | ||
return h( | ||
'li', | ||
{ key: ship.name }, | ||
h( | ||
'a', | ||
{ | ||
style: { fontWeight: ship.id === currentShipId ? 'bold' : 'normal' }, | ||
href: `/${ship.id}`, | ||
href, | ||
}, | ||
h('img', { | ||
src: getImageUrlForShip(ship.id, { size: 20 }), | ||
alt: ship.name, | ||
}), | ||
ship.name, | ||
), | ||
), | ||
) | ||
} | ||
|
||
export function SearchResultsFallback() { | ||
return Array.from({ | ||
length: 12, | ||
}).map((_, i) => | ||
h( | ||
'li', | ||
{ key: i }, | ||
h( | ||
'a', | ||
{ href: '#' }, | ||
h('img', { src: shipFallbackSrc, alt: 'loading' }), | ||
'... loading', | ||
), | ||
), | ||
) | ||
) | ||
}) | ||
} |
37 changes: 12 additions & 25 deletions
37
exercises/01.start/01.solution.ssr/src/ship-search-results.js
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 |
---|---|---|
@@ -1,42 +1,29 @@ | ||
import { createElement as h } from 'react' | ||
import { getImageUrlForShip } from './img-utils.js' | ||
|
||
const shipFallbackSrc = '/img/fallback-ship.png' | ||
|
||
export function SearchResults({ shipId: currentShipId, shipResults }) { | ||
return shipResults.ships.map(ship => | ||
h( | ||
export function SearchResults({ shipId: currentShipId, shipResults, search }) { | ||
return shipResults.ships.map(ship => { | ||
const href = [ | ||
`/${ship.id}`, | ||
search ? `search=${encodeURIComponent(search)}` : null, | ||
] | ||
.filter(Boolean) | ||
.join('?') | ||
return h( | ||
'li', | ||
{ key: ship.name }, | ||
h( | ||
'a', | ||
{ | ||
style: { fontWeight: ship.id === currentShipId ? 'bold' : 'normal' }, | ||
href: `/${ship.id}`, | ||
href, | ||
}, | ||
h('img', { | ||
src: getImageUrlForShip(ship.id, { size: 20 }), | ||
alt: ship.name, | ||
}), | ||
ship.name, | ||
), | ||
), | ||
) | ||
} | ||
|
||
export function SearchResultsFallback() { | ||
return Array.from({ | ||
length: 12, | ||
}).map((_, i) => | ||
h( | ||
'li', | ||
{ key: i }, | ||
h( | ||
'a', | ||
{ href: '#' }, | ||
h('img', { src: shipFallbackSrc, alt: 'loading' }), | ||
'... loading', | ||
), | ||
), | ||
) | ||
) | ||
}) | ||
} |
37 changes: 12 additions & 25 deletions
37
exercises/01.start/02.problem.server-context/src/ship-search-results.js
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 |
---|---|---|
@@ -1,42 +1,29 @@ | ||
import { createElement as h } from 'react' | ||
import { getImageUrlForShip } from './img-utils.js' | ||
|
||
const shipFallbackSrc = '/img/fallback-ship.png' | ||
|
||
export function SearchResults({ shipId: currentShipId, shipResults }) { | ||
return shipResults.ships.map(ship => | ||
h( | ||
export function SearchResults({ shipId: currentShipId, shipResults, search }) { | ||
return shipResults.ships.map(ship => { | ||
const href = [ | ||
`/${ship.id}`, | ||
search ? `search=${encodeURIComponent(search)}` : null, | ||
] | ||
.filter(Boolean) | ||
.join('?') | ||
return h( | ||
'li', | ||
{ key: ship.name }, | ||
h( | ||
'a', | ||
{ | ||
style: { fontWeight: ship.id === currentShipId ? 'bold' : 'normal' }, | ||
href: `/${ship.id}`, | ||
href, | ||
}, | ||
h('img', { | ||
src: getImageUrlForShip(ship.id, { size: 20 }), | ||
alt: ship.name, | ||
}), | ||
ship.name, | ||
), | ||
), | ||
) | ||
} | ||
|
||
export function SearchResultsFallback() { | ||
return Array.from({ | ||
length: 12, | ||
}).map((_, i) => | ||
h( | ||
'li', | ||
{ key: i }, | ||
h( | ||
'a', | ||
{ href: '#' }, | ||
h('img', { src: shipFallbackSrc, alt: 'loading' }), | ||
'... loading', | ||
), | ||
), | ||
) | ||
) | ||
}) | ||
} |
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
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
Oops, something went wrong.