Skip to content

Commit 30bd40f

Browse files
committed
Improve playground action buttons on mobile
1 parent 7ff7662 commit 30bd40f

13 files changed

+127
-157
lines changed

src/components/BlogEntry.astro

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
import type { CollectionEntry } from "astro:content"
33
import TypographyContainer from "./TypographyContainer.astro";
4-
import ArrowLeft from "./icons/ArrowLeft.astro";
4+
import ArrowLeftIcon from "./icons/ArrowLeftIcon.astro";
55
import GithubIcon from "./icons/GithubIcon.astro";
66
import type { BlogAuthor } from "../types";
77
import { Image } from "astro:assets";
@@ -17,7 +17,7 @@ const { entry } = Astro.props;
1717

1818
<div class="max-w-[48rem] mx-auto px-4 py-6 md:p-8">
1919
<a href="/blog" class="flex gap-6 font-semibold">
20-
<ArrowLeft class="w-6" />
20+
<ArrowLeftIcon class="w-6" />
2121
Back to Blog
2222
</a>
2323
<h1 class="text-3xl font-bold pt-8 md:pt-14">{entry.data.title}</h1>

src/components/IconLinks.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import GithubIcon from "./icons/GithubIcon.astro";
1414
<DiscordIcon class="fill-gray-30 hover:fill-gray-40 h-6 lg:h-4 dark:fill-gray-50 dark:hover:fill-gray-40" />
1515
</a>
1616
<a
17-
class="my-auto"
17+
class="my-auto pb-[1px]"
1818
href="https://x.com/grain_lang"
1919
aria-label="X link"
2020
target="_blank"

src/components/Playground.svelte

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import * as store from "../store";
77
import { codeExamples } from "../examples";
88
import ButtonLink from "./ButtonLink.svelte";
9+
import ShareIcon from "./icons/ShareIcon.svelte";
10+
import ListBulletsIcon from "./icons/ListBulletsIcon.svelte";
911
import LoadingSpinner from "./LoadingSpinner.svelte";
1012
import Tooltip from "./Tooltip.svelte";
1113
import * as monaco from "monaco-editor";
@@ -69,13 +71,18 @@
6971
editor.layout();
7072
}
7173
74+
let examplesToggled = false;
75+
function toggleExamples(): void {
76+
examplesToggled = !examplesToggled;
77+
}
78+
7279
let showCopiedMessage = false;
7380
let existingCopyMessageTimeout: NodeJS.Timeout;
7481
function copyCode(): void {
7582
navigator.clipboard.writeText(window.location.href);
7683
showCopiedMessage = true;
7784
clearTimeout(existingCopyMessageTimeout);
78-
existingCopyMessageTimeout = setTimeout(() => showCopiedMessage = false, 750);
85+
existingCopyMessageTimeout = setTimeout(() => showCopiedMessage = false, 1000);
7986
}
8087
8188
const switchCodeExample = (compressedCode: string) => () => {
@@ -137,13 +144,22 @@
137144
138145
</script>
139146

140-
<div>
141-
<div class="flex text-lg justify-between items-center px-4 lg:px-16 py-4">
142-
<ButtonLink onClick={compile} disabled={loadingState} className="w-full justify-center md:w-fit dark:disabled:bg-gray-variant-50 disabled:bg-[#9B9B9B]">Run</ButtonLink>
143-
<div class="hidden md:flex gap-6">
144-
<div class="relative">
145-
<div class="peer cursor-pointer hover:text-color-accent px-6 py-2">Examples</div>
146-
<div class="absolute z-10 left-1/2 -translate-x-1/2 hidden hover:grid peer-hover:grid grid-cols-2 px-2 py-2 rounded border border-gray-20 dark:border-purple-70 bg-white dark:bg-purple-90 w-96">
147+
<div class="overflow-x-hidden">
148+
<div class="flex text-lg justify-between items-center px-4 lg:px-16 py-4 relative md:static">
149+
<ButtonLink
150+
onClick={compile}
151+
disabled={loadingState}
152+
className="w-full justify-center md:w-fit dark:disabled:bg-gray-variant-50 disabled:bg-[#9B9B9B] mr-4"
153+
>
154+
Run
155+
</ButtonLink>
156+
<div class="flex gap-6">
157+
<div class="md:relative">
158+
<button on:click={toggleExamples} class="peer cursor-pointer hover:text-color-accent md:px-6 py-2">
159+
<span class="hidden md:inline-block">Examples</span>
160+
<ListBulletsIcon class="text-color-dim md:hidden" />
161+
</button>
162+
<div class={`absolute z-10 left-0 md:left-1/2 md:-translate-x-1/2 ${examplesToggled ? "grid" : "hidden"} hover:grid peer-hover:grid grid-cols-2 px-2 py-2 rounded border border-gray-20 dark:border-purple-70 bg-white dark:bg-purple-90 w-screen md:w-96`}>
147163
{#each codeExamples as example}
148164
<button
149165
on:click={switchCodeExample(lzString.compressToEncodedURIComponent(example.code))}
@@ -155,8 +171,15 @@
155171
</div>
156172
</div>
157173
<div class="relative">
158-
<button on:click={copyCode} class="peer cursor-pointer hover:text-color-accent pl-6 pr-5 py-2">Share</button>
159-
<Tooltip>{showCopiedMessage ? "Copied!" : "Copy URL"}</Tooltip>
174+
<button on:click={copyCode} class="peer cursor-pointer hover:text-color-accent md:pl-6 md:pr-5 py-2">
175+
<span class="hidden md:inline-block">
176+
Share
177+
</span>
178+
<ShareIcon class="text-color-dim md:hidden" />
179+
</button>
180+
<div class={`${showCopiedMessage ? "opacity-100" : "hidden md:opacity-0 md:block"} md:peer-hover:opacity-100 transition`}>
181+
<Tooltip>{showCopiedMessage ? "URL copied!" : "Copy URL"}</Tooltip>
182+
</div>
160183
</div>
161184
</div>
162185
</div>

src/components/Tooltip.svelte

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<div class="hidden peer-hover:block absolute z-10 top-full left-1/2 -translate-x-1/2 w-5 h-5 rotate-45 bg-gray-90"></div>
2-
<div class="hidden peer-hover:block absolute z-10 top-full left-1/2 -translate-x-1/2 text-white bg-gray-90 px-2 py-1 text-xs rounded whitespace-nowrap">
3-
<slot />
1+
<div>
2+
<div class="absolute z-10 top-full left-1/2 -translate-x-1/2 w-5 h-5 rotate-45 bg-gray-90"></div>
3+
<div class="absolute z-10 top-full left-1/2 -translate-x-1/2 text-white bg-gray-90 px-2 py-1 text-xs rounded whitespace-nowrap">
4+
<slot />
5+
</div>
46
</div>

src/components/icons/DesktopIcon.astro

Lines changed: 0 additions & 17 deletions
This file was deleted.

src/components/icons/HashIcon.astro

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<!--
2+
MIT License
3+
4+
Copyright (c) 2020 Phosphor Icons
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in all
14+
copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
SOFTWARE.
23+
-->
24+
<svg
25+
xmlns="http://www.w3.org/2000/svg"
26+
width="32"
27+
height="32"
28+
fill="currentColor"
29+
viewBox="0 0 256 256"
30+
{...$$props}
31+
>
32+
<path d="M80,64a8,8,0,0,1,8-8H216a8,8,0,0,1,0,16H88A8,8,0,0,1,80,64Zm136,56H88a8,8,0,0,0,0,16H216a8,8,0,0,0,0-16Zm0,64H88a8,8,0,0,0,0,16H216a8,8,0,0,0,0-16ZM44,52A12,12,0,1,0,56,64,12,12,0,0,0,44,52Zm0,64a12,12,0,1,0,12,12A12,12,0,0,0,44,116Zm0,64a12,12,0,1,0,12,12A12,12,0,0,0,44,180Z"></path>
33+
</svg>
34+
<!-- <svg
35+
xmlns="http://www.w3.org/2000/svg"
36+
width="32"
37+
height="32"
38+
fill="#000000"
39+
viewBox="0 0 256 256"
40+
{...$$props}
41+
>
42+
<path d="M76,64A12,12,0,0,1,88,52H216a12,12,0,0,1,0,24H88A12,12,0,0,1,76,64Zm140,52H88a12,12,0,0,0,0,24H216a12,12,0,0,0,0-24Zm0,64H88a12,12,0,0,0,0,24H216a12,12,0,0,0,0-24ZM44,112a16,16,0,1,0,16,16A16,16,0,0,0,44,112Zm0-64A16,16,0,1,0,60,64,16,16,0,0,0,44,48Zm0,128a16,16,0,1,0,16,16A16,16,0,0,0,44,176Z"></path>
43+
</svg> -->

src/components/icons/MoonIcon.astro

Lines changed: 0 additions & 16 deletions
This file was deleted.

src/components/icons/SearchIcon.astro

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)