Compare commits
2 Commits
fix/cloud-
...
feat/add-h
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d75910972f | ||
|
|
589c604a12 |
@@ -171,16 +171,6 @@ export const StyledButton = styled("button", {
|
|||||||
color: "$textMuted",
|
color: "$textMuted",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
isDisabled: {
|
|
||||||
true: {
|
|
||||||
opacity: 0.6,
|
|
||||||
// pointerEvents: "none",
|
|
||||||
cursor: "auto",
|
|
||||||
"&:hover": {
|
|
||||||
boxShadow: "inherit",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
outline: {
|
outline: {
|
||||||
true: {
|
true: {
|
||||||
backgroundColor: "transparent",
|
backgroundColor: "transparent",
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ import {
|
|||||||
import NewWindow from "react-new-window";
|
import NewWindow from "react-new-window";
|
||||||
import { signOut, useSession } from "next-auth/react";
|
import { signOut, useSession } from "next-auth/react";
|
||||||
import { useSnapshot } from "valtio";
|
import { useSnapshot } from "valtio";
|
||||||
import toast from "react-hot-toast";
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
createNewFile,
|
createNewFile,
|
||||||
@@ -49,7 +48,7 @@ import Flex from "./Flex";
|
|||||||
import Stack from "./Stack";
|
import Stack from "./Stack";
|
||||||
import Input from "./Input";
|
import Input from "./Input";
|
||||||
import Text from "./Text";
|
import Text from "./Text";
|
||||||
import Tooltip from "./Tooltip";
|
import toast from "react-hot-toast";
|
||||||
import {
|
import {
|
||||||
AlertDialog,
|
AlertDialog,
|
||||||
AlertDialogContent,
|
AlertDialogContent,
|
||||||
@@ -368,7 +367,6 @@ const EditorNavigation = ({ showWat }: { showWat?: boolean }) => {
|
|||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Tooltip content="Download as ZIP">
|
|
||||||
<Button
|
<Button
|
||||||
isLoading={snap.zipLoading}
|
isLoading={snap.zipLoading}
|
||||||
onClick={downloadAsZip}
|
onClick={downloadAsZip}
|
||||||
@@ -378,8 +376,6 @@ const EditorNavigation = ({ showWat }: { showWat?: boolean }) => {
|
|||||||
>
|
>
|
||||||
<DownloadSimple size="16px" />
|
<DownloadSimple size="16px" />
|
||||||
</Button>
|
</Button>
|
||||||
</Tooltip>
|
|
||||||
<Tooltip content="Copy share link to clipboard">
|
|
||||||
<Button
|
<Button
|
||||||
outline
|
outline
|
||||||
size="sm"
|
size="sm"
|
||||||
@@ -393,26 +389,13 @@ const EditorNavigation = ({ showWat }: { showWat?: boolean }) => {
|
|||||||
>
|
>
|
||||||
<Share size="16px" />
|
<Share size="16px" />
|
||||||
</Button>
|
</Button>
|
||||||
</Tooltip>
|
|
||||||
<Tooltip
|
|
||||||
content={
|
|
||||||
session && session.user
|
|
||||||
? snap.gistOwner === session?.user.username
|
|
||||||
? "Sync to Gist"
|
|
||||||
: "Create as a new Gist"
|
|
||||||
: "You need to be logged in to sync with Gist"
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<Button
|
<Button
|
||||||
outline
|
outline
|
||||||
size="sm"
|
size="sm"
|
||||||
isDisabled={!session || !session.user}
|
disabled={!session || !session.user}
|
||||||
isLoading={snap.gistLoading}
|
isLoading={snap.gistLoading}
|
||||||
css={{ alignItems: "center" }}
|
css={{ alignItems: "center" }}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
if (!session || !session.user) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (snap.gistOwner === session?.user.username) {
|
if (snap.gistOwner === session?.user.username) {
|
||||||
syncToGist(session);
|
syncToGist(session);
|
||||||
} else {
|
} else {
|
||||||
@@ -420,13 +403,8 @@ const EditorNavigation = ({ showWat }: { showWat?: boolean }) => {
|
|||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{snap.gistOwner === session?.user.username ? (
|
|
||||||
<CloudArrowUp size="16px" />
|
<CloudArrowUp size="16px" />
|
||||||
) : (
|
|
||||||
<FilePlus size="16px" />
|
|
||||||
)}
|
|
||||||
</Button>
|
</Button>
|
||||||
</Tooltip>
|
|
||||||
|
|
||||||
<DropdownMenu>
|
<DropdownMenu>
|
||||||
<DropdownMenuTrigger asChild>
|
<DropdownMenuTrigger asChild>
|
||||||
|
|||||||
@@ -1,89 +0,0 @@
|
|||||||
import React from "react";
|
|
||||||
import { styled, keyframes } from "../stitches.config";
|
|
||||||
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
|
|
||||||
|
|
||||||
const slideUpAndFade = keyframes({
|
|
||||||
"0%": { opacity: 0, transform: "translateY(2px)" },
|
|
||||||
"100%": { opacity: 1, transform: "translateY(0)" },
|
|
||||||
});
|
|
||||||
|
|
||||||
const slideRightAndFade = keyframes({
|
|
||||||
"0%": { opacity: 0, transform: "translateX(-2px)" },
|
|
||||||
"100%": { opacity: 1, transform: "translateX(0)" },
|
|
||||||
});
|
|
||||||
|
|
||||||
const slideDownAndFade = keyframes({
|
|
||||||
"0%": { opacity: 0, transform: "translateY(-2px)" },
|
|
||||||
"100%": { opacity: 1, transform: "translateY(0)" },
|
|
||||||
});
|
|
||||||
|
|
||||||
const slideLeftAndFade = keyframes({
|
|
||||||
"0%": { opacity: 0, transform: "translateX(2px)" },
|
|
||||||
"100%": { opacity: 1, transform: "translateX(0)" },
|
|
||||||
});
|
|
||||||
|
|
||||||
const StyledContent = styled(TooltipPrimitive.Content, {
|
|
||||||
borderRadius: 4,
|
|
||||||
padding: "$2 $3",
|
|
||||||
fontSize: 12,
|
|
||||||
lineHeight: 1,
|
|
||||||
color: "$text",
|
|
||||||
backgroundColor: "$background",
|
|
||||||
boxShadow:
|
|
||||||
"hsl(206 22% 7% / 35%) 0px 10px 38px -10px, hsl(206 22% 7% / 20%) 0px 10px 20px -15px",
|
|
||||||
"@media (prefers-reduced-motion: no-preference)": {
|
|
||||||
animationDuration: "400ms",
|
|
||||||
animationTimingFunction: "cubic-bezier(0.16, 1, 0.3, 1)",
|
|
||||||
animationFillMode: "forwards",
|
|
||||||
willChange: "transform, opacity",
|
|
||||||
'&[data-state="delayed-open"]': {
|
|
||||||
'&[data-side="top"]': { animationName: slideDownAndFade },
|
|
||||||
'&[data-side="right"]': { animationName: slideLeftAndFade },
|
|
||||||
'&[data-side="bottom"]': { animationName: slideUpAndFade },
|
|
||||||
'&[data-side="left"]': { animationName: slideRightAndFade },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
".dark &": {
|
|
||||||
boxShadow:
|
|
||||||
"0px 0px 10px 2px rgba(255,255,255,.15), hsl(206 22% 7% / 35%) 0px 10px 38px -10px, hsl(206 22% 7% / 20%) 0px 10px 20px -15px",
|
|
||||||
},
|
|
||||||
".light &": {
|
|
||||||
boxShadow:
|
|
||||||
"0px 0px 10px 2px rgba(0,0,0,.15), hsl(206 22% 7% / 35%) 0px 10px 38px -10px, hsl(206 22% 7% / 20%) 0px 10px 20px -15px",
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const StyledArrow = styled(TooltipPrimitive.Arrow, {
|
|
||||||
fill: "$background",
|
|
||||||
});
|
|
||||||
|
|
||||||
interface ITooltip {
|
|
||||||
content: string;
|
|
||||||
open?: boolean;
|
|
||||||
defaultOpen?: boolean;
|
|
||||||
onOpenChange?: (open: boolean) => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
const Tooltip: React.FC<ITooltip> = ({
|
|
||||||
children,
|
|
||||||
content,
|
|
||||||
open,
|
|
||||||
defaultOpen = false,
|
|
||||||
onOpenChange,
|
|
||||||
}) => {
|
|
||||||
return (
|
|
||||||
<TooltipPrimitive.Root
|
|
||||||
open={open}
|
|
||||||
defaultOpen={defaultOpen}
|
|
||||||
onOpenChange={onOpenChange}
|
|
||||||
>
|
|
||||||
<TooltipPrimitive.Trigger asChild>{children}</TooltipPrimitive.Trigger>
|
|
||||||
<StyledContent side="bottom" align="center">
|
|
||||||
{content}
|
|
||||||
<StyledArrow offset={5} width={11} height={5} />
|
|
||||||
</StyledContent>
|
|
||||||
</TooltipPrimitive.Root>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Tooltip;
|
|
||||||
@@ -19,7 +19,6 @@
|
|||||||
"@radix-ui/react-dialog": "^0.1.1",
|
"@radix-ui/react-dialog": "^0.1.1",
|
||||||
"@radix-ui/react-dropdown-menu": "^0.1.1",
|
"@radix-ui/react-dropdown-menu": "^0.1.1",
|
||||||
"@radix-ui/react-id": "^0.1.1",
|
"@radix-ui/react-id": "^0.1.1",
|
||||||
"@radix-ui/react-tooltip": "^0.1.7",
|
|
||||||
"@stitches/react": "^1.2.6-0",
|
"@stitches/react": "^1.2.6-0",
|
||||||
"base64-js": "^1.5.1",
|
"base64-js": "^1.5.1",
|
||||||
"dinero.js": "^1.9.1",
|
"dinero.js": "^1.9.1",
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { Octokit } from "@octokit/core";
|
|||||||
import Router from "next/router";
|
import Router from "next/router";
|
||||||
import state from '../index';
|
import state from '../index';
|
||||||
import { templateFileIds } from '../constants';
|
import { templateFileIds } from '../constants';
|
||||||
|
import { hookapiH, hookmacroH, sfcodesH } from '../constants/headerTemplates';
|
||||||
|
|
||||||
|
|
||||||
const octokit = new Octokit();
|
const octokit = new Octokit();
|
||||||
@@ -24,16 +25,26 @@ export const fetchFiles = (gistId: string) => {
|
|||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
// in case of templates, fetch header file(s) and append to res
|
// in case of templates, fetch header file(s) and append to res
|
||||||
return octokit.request("GET /gists/{gist_id}", { gist_id: templateFileIds.headers }).then(({ data: { files: headerFiles } }) => {
|
const files = {
|
||||||
const files = { ...res.data.files, ...headerFiles }
|
...res.data.files,
|
||||||
res.data.files = files
|
'hookapi.h': res.data.files?.['hookapi.h'] || { filename: 'hookapi.h', content: hookapiH, language: 'C' },
|
||||||
return res
|
'hookmacro.h': res.data.files?.['hookmacro.h'] || { filename: 'hookmacro.h', content: hookmacroH, language: 'C' },
|
||||||
})
|
'sfcodes.h': res.data.files?.['sfcodes.h'] || { filename: 'sfcodes.h', content: sfcodesH, language: 'C' },
|
||||||
|
};
|
||||||
|
res.data.files = files;
|
||||||
|
return res;
|
||||||
|
// If you want to load templates from GIST instad, uncomment the code below and comment the code above.
|
||||||
|
// return octokit.request("GET /gists/{gist_id}", { gist_id: templateFileIds.headers }).then(({ data: { files: headerFiles } }) => {
|
||||||
|
// const files = { ...res.data.files, ...headerFiles }
|
||||||
|
// console.log(headerFiles)
|
||||||
|
// res.data.files = files
|
||||||
|
// return res
|
||||||
|
// })
|
||||||
})
|
})
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
if (res.data.files && Object.keys(res.data.files).length > 0) {
|
if (res.data.files && Object.keys(res.data.files).length > 0) {
|
||||||
const files = Object.keys(res.data.files).map((filename) => ({
|
const files = Object.keys(res.data.files).map((filename) => ({
|
||||||
name: res.data.files?.[filename]?.filename || "noname.c",
|
name: res.data.files?.[filename]?.filename || "untitled.c",
|
||||||
language: res.data.files?.[filename]?.language?.toLowerCase() || "",
|
language: res.data.files?.[filename]?.language?.toLowerCase() || "",
|
||||||
content: res.data.files?.[filename]?.content || "",
|
content: res.data.files?.[filename]?.content || "",
|
||||||
}));
|
}));
|
||||||
|
|||||||
1383
state/constants/headerTemplates.ts
Normal file
1383
state/constants/headerTemplates.ts
Normal file
File diff suppressed because it is too large
Load Diff
@@ -14,8 +14,7 @@ export const templateFileIds = {
|
|||||||
'carbon': 'a9fbcaf1b816b198c7fc0f62962bebf2',
|
'carbon': 'a9fbcaf1b816b198c7fc0f62962bebf2',
|
||||||
'doubler': '56b86174aeb70b2b48eee962bad3e355',
|
'doubler': '56b86174aeb70b2b48eee962bad3e355',
|
||||||
'peggy': 'd21298a37e1550b781682014762a567b',
|
'peggy': 'd21298a37e1550b781682014762a567b',
|
||||||
'headers': '9b448e8a55fab11ef5d1274cb59f9cf3'
|
'headers': '55f639bce59a49c58c45e663776b5138'
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const apiHeaderFiles = ['hookapi.h', 'sfcodes.h', 'hookmacro.h']
|
export const apiHeaderFiles = ['hookapi.h', 'sfcodes.h', 'hookmacro.h']
|
||||||
|
|||||||
36
yarn.lock
36
yarn.lock
@@ -762,27 +762,6 @@
|
|||||||
"@babel/runtime" "^7.13.10"
|
"@babel/runtime" "^7.13.10"
|
||||||
"@radix-ui/react-compose-refs" "0.1.0"
|
"@radix-ui/react-compose-refs" "0.1.0"
|
||||||
|
|
||||||
"@radix-ui/react-tooltip@^0.1.7":
|
|
||||||
version "0.1.7"
|
|
||||||
resolved "https://registry.yarnpkg.com/@radix-ui/react-tooltip/-/react-tooltip-0.1.7.tgz#6f8c00d6e489565d14abf209ce0fb8853c8c8ee3"
|
|
||||||
integrity sha512-eiBUsVOHenZ0JR16tl970bB0DafJBz6mFgSGfIGIVpflFj0LIsIDiLMsYyvYdx1KwwsIUDTEZtxcPm/sWjPzqA==
|
|
||||||
dependencies:
|
|
||||||
"@babel/runtime" "^7.13.10"
|
|
||||||
"@radix-ui/primitive" "0.1.0"
|
|
||||||
"@radix-ui/react-compose-refs" "0.1.0"
|
|
||||||
"@radix-ui/react-context" "0.1.1"
|
|
||||||
"@radix-ui/react-id" "0.1.5"
|
|
||||||
"@radix-ui/react-popper" "0.1.4"
|
|
||||||
"@radix-ui/react-portal" "0.1.4"
|
|
||||||
"@radix-ui/react-presence" "0.1.2"
|
|
||||||
"@radix-ui/react-primitive" "0.1.4"
|
|
||||||
"@radix-ui/react-slot" "0.1.2"
|
|
||||||
"@radix-ui/react-use-controllable-state" "0.1.0"
|
|
||||||
"@radix-ui/react-use-escape-keydown" "0.1.0"
|
|
||||||
"@radix-ui/react-use-previous" "0.1.1"
|
|
||||||
"@radix-ui/react-use-rect" "0.1.1"
|
|
||||||
"@radix-ui/react-visually-hidden" "0.1.4"
|
|
||||||
|
|
||||||
"@radix-ui/react-use-body-pointer-events@0.1.1":
|
"@radix-ui/react-use-body-pointer-events@0.1.1":
|
||||||
version "0.1.1"
|
version "0.1.1"
|
||||||
resolved "https://registry.yarnpkg.com/@radix-ui/react-use-body-pointer-events/-/react-use-body-pointer-events-0.1.1.tgz#63e7fd81ca7ffd30841deb584cd2b7f460df2597"
|
resolved "https://registry.yarnpkg.com/@radix-ui/react-use-body-pointer-events/-/react-use-body-pointer-events-0.1.1.tgz#63e7fd81ca7ffd30841deb584cd2b7f460df2597"
|
||||||
@@ -828,13 +807,6 @@
|
|||||||
dependencies:
|
dependencies:
|
||||||
"@babel/runtime" "^7.13.10"
|
"@babel/runtime" "^7.13.10"
|
||||||
|
|
||||||
"@radix-ui/react-use-previous@0.1.1":
|
|
||||||
version "0.1.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/@radix-ui/react-use-previous/-/react-use-previous-0.1.1.tgz#0226017f72267200f6e832a7103760e96a6db5d0"
|
|
||||||
integrity sha512-O/ZgrDBr11dR8rhO59ED8s5zIXBRFi8MiS+CmFGfi7MJYdLbfqVOmQU90Ghf87aifEgWe6380LA69KBneaShAg==
|
|
||||||
dependencies:
|
|
||||||
"@babel/runtime" "^7.13.10"
|
|
||||||
|
|
||||||
"@radix-ui/react-use-rect@0.1.1":
|
"@radix-ui/react-use-rect@0.1.1":
|
||||||
version "0.1.1"
|
version "0.1.1"
|
||||||
resolved "https://registry.yarnpkg.com/@radix-ui/react-use-rect/-/react-use-rect-0.1.1.tgz#6c15384beee59c086e75b89a7e66f3d2e583a856"
|
resolved "https://registry.yarnpkg.com/@radix-ui/react-use-rect/-/react-use-rect-0.1.1.tgz#6c15384beee59c086e75b89a7e66f3d2e583a856"
|
||||||
@@ -850,14 +822,6 @@
|
|||||||
dependencies:
|
dependencies:
|
||||||
"@babel/runtime" "^7.13.10"
|
"@babel/runtime" "^7.13.10"
|
||||||
|
|
||||||
"@radix-ui/react-visually-hidden@0.1.4":
|
|
||||||
version "0.1.4"
|
|
||||||
resolved "https://registry.yarnpkg.com/@radix-ui/react-visually-hidden/-/react-visually-hidden-0.1.4.tgz#6c75eae34fb5d084b503506fbfc05587ced05f03"
|
|
||||||
integrity sha512-K/q6AEEzqeeEq/T0NPChvBqnwlp8Tl4NnQdrI/y8IOY7BRR+Ug0PEsVk6g48HJ7cA1//COugdxXXVVK/m0X1mA==
|
|
||||||
dependencies:
|
|
||||||
"@babel/runtime" "^7.13.10"
|
|
||||||
"@radix-ui/react-primitive" "0.1.4"
|
|
||||||
|
|
||||||
"@radix-ui/rect@0.1.1":
|
"@radix-ui/rect@0.1.1":
|
||||||
version "0.1.1"
|
version "0.1.1"
|
||||||
resolved "https://registry.yarnpkg.com/@radix-ui/rect/-/rect-0.1.1.tgz#95b5ba51f469bea6b1b841e2d427e17e37d38419"
|
resolved "https://registry.yarnpkg.com/@radix-ui/rect/-/rect-0.1.1.tgz#95b5ba51f469bea6b1b841e2d427e17e37d38419"
|
||||||
|
|||||||
Reference in New Issue
Block a user