View gist:4bcdaca88789dc74a0beadcf9fe438dc
This file has been truncated, but you can view the full file.
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
fetch("https://wb-api.ethz.ch/MFT/api/upload/v1/UploadChunk", { | |
"headers": { | |
"accept": "application/json", | |
"accept-language": "en-US,en;q=0.9,nl;q=0.8,de;q=0.7", | |
"authorization": "....", | |
"cache-control": "no-cache", | |
"content-type": "application/json", | |
"pragma": "no-cache", | |
"sec-fetch-dest": "empty", | |
"sec-fetch-mode": "cors", |
View .storybook\main.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
module.exports = { | |
stories: ["../src/**/*.stories.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"], | |
addons: [ | |
"@storybook/addon-a11y", | |
"@storybook/addon-links", | |
"@storybook/addon-essentials", | |
"@storybook/preset-create-react-app", | |
], | |
}; |
View index.njk
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
<span>Page {{ pagination.pageNumber + 1 }} of {{ pagination.pages.length }}:</span> | |
{% if page.url !== pagination.href.first %}<a href="{{ pagination.href.first }}"><i class="ion-ios-skipbackward"></i></a>{% endif %} | |
{% if pagination.href.previous %}<a href="{{ pagination.href.previous }}"><i class="ion-arrow-left-b"></i></a>{% endif %} | |
{%- for pageEntry in pagination.pages %} | |
{%- if (loop.index0 - pagination.pageNumber) | abs <= 3 %} | |
<a href="{{ pagination.hrefs[ loop.index0 ] -}}" | |
{%- if page.url === pagination.hrefs[ loop.index0 ] %} class="active"{% endif %}> | |
{{- loop.index -}} | |
</a> | |
{%- endif %} |
View PersonType.ts
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
type Person = yup.InferType<typeof personSchema>; |
View person.ts
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
const person: Person; |
View Person.ts
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
type Person = { | |
firstName: string; | |
nickName: string | null; | |
email?: string | null; | |
birthDate: Date; | |
}; |
View person.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
const person = { | |
firstName: "Matt", | |
nickName: "The Hammer", | |
email: "matt@the-hammer.com", | |
birthDate: new Date(1976, 9, 5) | |
}; | |
console.log(personSchema.isValidSync(person)); |
View personSchema.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
const personSchema = yup.object({ | |
firstName: yup.string(), | |
nickName: yup.string().nullable(), | |
email: yup | |
.string() | |
.nullable() | |
.notRequired() | |
.email(), | |
birthDate: yup | |
.date() |
View fetch-jokes.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
import React from 'react'; | |
import ListGroup from 'react-bootstrap/ListGroup'; | |
import { url } from '../../shared/jokes-api'; | |
import Loading from '../../shared/loading'; | |
function reducer(state, action) { | |
switch (action.type) { | |
case 'loaded': | |
return { ...state, loading: false, jokes: action.payload }; |
View Joke.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
import React, { useState } from 'react'; | |
import useAbortableFetch from './useAbortableFetch'; | |
const Joke = () => { | |
const { json: joke, loading, error, abort } = useAbortableFetch( | |
'http://api.icndb.com/jokes/random/?limitTo=[nerdy]&escape=javascript' | |
); | |
if (loading) return 'Loading...'; | |
if (error) return 'Error: ' + error; |
NewerOlder