Skip to content

Instantly share code, notes, and snippets.

@omirobarcelo
omirobarcelo / create.pcss
Created April 17, 2021 10:57
WebHero - 6 - Create responsive styling
.create-container {
@apply px-2 py-2 flex flex-col items-center;
}
form {
@apply w-full pt-6 pb-8 mb-4;
max-width: 768px;
}
.img-title-area {
@omirobarcelo
omirobarcelo / Contact.pcss
Created April 17, 2021 10:55
WebHero - 6 - Contact responsive styling
.contact-container {
@apply px-2 py-2 flex flex-col items-center;
}
@screen sm {
.contact-container {
@apply px-4 py-6;
}
}
@omirobarcelo
omirobarcelo / layout.pcss
Created April 17, 2021 10:48
WebHero - 6 - Layout responsive styling
.main-content {
@apply flex flex-col;
}
.ads {
@apply flex-auto;
min-width: 120px;
min-height: 100px;
max-width: 100%;
max-height: 100px;
@omirobarcelo
omirobarcelo / Nav.pcss
Created April 17, 2021 10:45
WebHero - 6 - Navbar responsive styling
nav {
@apply w-full flex items-center justify-between flex-wrap bg-orange-600 p-4;
}
.logo-container {
@apply flex items-center flex-shrink-0 text-white mr-6;
order: 0;
}
input[type="search"] {
@omirobarcelo
omirobarcelo / Nav.svelte
Created April 17, 2021 10:22
WebHero - 6 - Disable and navigation of search bar
<script lang="ts">
export let segment: string;
$: if (segment === 'create') {
search.update('');
// If navigating directly to create, this executes before the onMount
if (searchElem) {
searchElem.value = '';
}
}
@omirobarcelo
omirobarcelo / use-alert.svelte
Created April 11, 2021 17:02
WebHero - 5 - Using the alert
{#if serverRes}
{#if serverRes.successful}
<Alert type="success" message="Your game has been successfully saved and it's awaiting review!" />
{:else}
<Alert
type="error"
message={serverRes.errorMsg ? serverRes.errorMsg : 'There was a problem sending your game entry. Please, try again.'}
/>
{/if}
{/if}
<script lang="ts">
export let type: 'success' | 'error';
export let message: string;
const CHECK = 'M0.5,8 L4,11.5 L11.5,3';
const CROSS = 'M0.5,0.5 L11.5,11.5 M11.5,0.5 L0.5,11.5';
</script>
<div class="alert {type}" role="alert">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 12 12">
@omirobarcelo
omirobarcelo / create.ts
Created April 11, 2021 16:50
WebHero - 5 - Create endpoint
export async function post(req: Request, res: Response, next: NextFunction) {
const { name, altNames, image, vote, comment } = req.body;
let game: IGameDocument;
try {
game = new models.Game({
name,
altNames,
image,
positiveVotes: vote === 'positive' ? 1 : 0,
negativeVotes: vote === 'negative' ? 1 : 0,
@omirobarcelo
omirobarcelo / contact.svelte
Created April 3, 2021 17:26
WebHero - 4 - Succinct feedback
{#if serverRes}
<div class="alert success" role="alert">
<img
src={serverRes.successful ? 'check.svg' : 'cross.svg'}
alt={serverRes.successful ? 'success icon' : 'error icon'}
/>
<p>
{
serverRes.successful
? 'Your contact request was successfully received!'
@omirobarcelo
omirobarcelo / contact.svelte
Created April 3, 2021 17:25
WebHero - 4 - Backend response feedback
{#if serverRes}
{#if serverRes.successful}
<div class="alert success" role="alert">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 12 12">
<path stroke-width="2" stroke="white" fill="none" d="M0.5,8 L4,11.5 L11.5,3" />
</svg>
<p>Your contact request was successfully received!</p>
</div>
{:else}
<div class="alert error" role="alert">