Skip to content

Commit d83b3b6

Browse files
committed
Make the gist playgrounds better
1 parent 98333ca commit d83b3b6

File tree

4 files changed

+44
-4
lines changed

4 files changed

+44
-4
lines changed

packages/playground/src/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,12 @@ export const setupPlayground = (
9292
const showNav = () => {
9393
const right = document.getElementsByClassName("playground-sidebar").item(0)!
9494
const middle = document.getElementById("editor-container")!
95-
middle.style.width = `calc(100% - ${right.clientWidth + 180}px)`
95+
middle.style.width = `calc(100% - ${right.clientWidth + 210}px)`
9696

9797
leftNav.style.display = "block"
98-
leftNav.style.width = "180px"
99-
leftNav.style.minWidth = "180px"
100-
leftNav.style.maxWidth = "180px"
98+
leftNav.style.width = "210px"
99+
leftNav.style.minWidth = "210px"
100+
leftNav.style.maxWidth = "210px"
101101
dragBarLeft.style.display = "block"
102102
}
103103

packages/playground/src/navigation.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ export const gistPoweredNavBar = (sandbox: Sandbox, ui: UI, showNav: () => void)
1010
const gistHash = location.hash.split("#gist/")[1]
1111
const [gistID, gistStoryIndex] = gistHash.split("-")
1212

13+
// @ts-ignore
14+
window.appInsights && window.appInsights.trackEvent({ name: "Loaded Gist Playground", properties: { id: gistID } })
15+
1316
sandbox.editor.updateOptions({ readOnly: true })
1417
ui.flashInfo(`Opening Gist ${gistID} as a Docset`, 2000)
1518

@@ -100,9 +103,12 @@ export const gistPoweredNavBar = (sandbox: Sandbox, ui: UI, showNav: () => void)
100103
return ui.flashInfo(`Error with getting your gist: ${response.display}.`, 3000)
101104
}
102105

106+
// If the API response is a single code file, just throw that in
103107
if (response.type === "code") {
104108
sandbox.setText(response.code)
105109
sandbox.setCompilerSettings(response.params)
110+
111+
// If it's multi-file, then there's work to do
106112
} else if (response.type === "story") {
107113
showNav()
108114

@@ -113,6 +119,7 @@ export const gistPoweredNavBar = (sandbox: Sandbox, ui: UI, showNav: () => void)
113119
title.textContent = response.title
114120
nav.appendChild(title)
115121

122+
// Make all the sidebar elements
116123
const ul = document.createElement("ul")
117124
response.files.forEach((element: StoryContent, i: number) => {
118125
const li = document.createElement("li")

packages/typescriptlang-org/src/style/globals.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// The CSS Vars live in main.scss
2+
13
$ts-main-blue-color: #3178c6;
24
$ts-main-blue-darker-color: #235a97;
35
$ts-main-blue-lighter-color: #358ef1;

packages/typescriptlang-org/src/templates/play.scss

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,37 @@ main #editor-toolbar {
379379
border-radius: 3px;
380380
}
381381

382+
details[open] {
383+
padding-left: 1rem;
384+
border-left: 2px solid var(--blue-tinged-strong);
385+
386+
summary {
387+
margin-left: -0.5rem;
388+
}
389+
}
390+
391+
summary {
392+
&:hover {
393+
cursor: pointer;
394+
background-color: var(--background-minor-highlight-color);
395+
}
396+
}
397+
398+
kbd {
399+
background-color: #f7f7f7;
400+
border: 1px solid #ccc;
401+
border-radius: 3px;
402+
box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2), 0 0 0 2px #fff inset;
403+
color: #333;
404+
display: inline-block;
405+
font-family: Arial, Helvetica, sans-serif;
406+
font-size: 11px;
407+
line-height: 1.4;
408+
margin: 0 0.1em;
409+
padding: 0.1em 0.6em;
410+
text-shadow: 0 1px 0 #fff;
411+
}
412+
382413
.highlight {
383414
font-size: 14px;
384415
margin-bottom: 16px;

0 commit comments

Comments
 (0)