Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/orta/playground-slides

Make presentations in the TypeScript playground
https://github.com/orta/playground-slides

Last synced: 10 days ago
JSON representation

Make presentations in the TypeScript playground

Awesome Lists containing this project

README

        

## TypeScript Playground Present

A way to present your TypeScript talk in style!

This plugin adds a copy of [Reveal.js](https://github.com/hakimel/reveal.js) above the playground, slides are created
using Markdown (via [marked](https://github.com/markedjs/marked)) and have the ability to set the text in the playground.

With markdown looking like:

````md

# TSNYC Jan 2020

---

## What is TypeScript?

TypeScript extends JavaScript by adding types.

TypeScript speeds up your development experience by catching errors and providing fixes before you even run your code.

Any browser, any OS, anywhere JavaScript runs. Entirely Open Source.

---

## `import type`

### Why?

> ### Guaranteed Side-effect free syntax
>
> Tools like Babel, which don’t type-check can be certain with 100% accuracy
whether to remove the import.

// Look at the JS, this isn't included in the output
import {DangerDSLType} from "danger"

declare const myDSL: DangerDSLType

myDSL.bitbucket_cloud

// On the other hand, this one is...
import {danger} from "danger"
danger.git

// But why?

// TS keeps track of whether an import is a "JS" value
// or a TypeScript type.
import {DangerDSLJSONType, message} from "danger"
message

// Babel cannot do this!

// So now Babel knows that it can always skip these
// 'import type' statements
import type {DangerUtilsDSL} from "danger"

// Because they can't be used with "JS" values:
import type {markdown} from "danger"

---
````

This markdown would turn into 2 slides, where the showing the second would change the Playground's code.

## Examples

- [TSNY Jan 2020](./examples/tsnyc-jan-2020.md) - [gist](https://gist.github.com/orta/d7dbd4cdb8d1f99c52871fb15db620bc)

_Note: the `` element is not visible, so [view the source](https://gist.githubusercontent.com/orta/d7dbd4cdb8d1f99c52871fb15db620bc/raw/33eff5573a2a592d7be4364a791d6f0e1d557b72/index.md) please._

## Useful info for making slides

1. Get started by making a gist: https://gist.github.com
2. Make an `index.md` and add some example markdown
3. Split your slides with `---`
4. Save your gist, then tell the playground to load that gist

#### Playground support

You can change the playground support by putting your code inside the `` HTML element in the slides. This lets you use
markdown code blocks to show the code in the slides:

````md
# Network Requests

There are a few ways to get info from an API

---

# What is `await`?

```ts
const response = await fetch("mysite.com/api/dogs")
```

import fetch from "node-fetch"

const start = await () => {
const response = await fetch("https://mysite.com/api/dogs)
...
}

---

# How do Promises work?
````

#### Build In Slides

Reveal.js supports building out sections in a slide [using fragments]([https://github.com/hakimel/reveal.js#element-attributes](https://revealjs.com/fragments/))

```md
# Anyone can contribute

It takes a village to make a big OSS project
---
# Extra thanks to

- Orta Therox
- Danger McShane

---
```

## TODO

- Make it pretty
- Add a back to slides button
- Add a down to code button when playground has changed
- Are there more things we can hook into than just code?

## Contributing

You can use `yarn start` to set up both a copy of rollup to generate the JS, and serve to host it

```sh
yarn start
```

Then set up the TypeScript playground to get a plugin from from `http://localhost:5000/index.js`.