Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #33

Merged
merged 3 commits into from
Feb 27, 2023
Merged

Dev #33

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions components/Logo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ const Logo: React.FC<{ size?: "xs" | "sm" | "xl" | "2xl" }> = ({
const getIconClassesBySize = () => {
switch (size) {
case "xs":
return "h-3 w-3";
return "h-4 w-4 mr-1";
case "sm":
return "h-5 w-5";
return "h-5 w-5 mr-1";
case "xl":
return "h-7 w-7";
return "h-7 w-7 mr-2";
case "2xl":
return "h-9 w-9";
return "h-9 w-9 mr-2";
default:
return "h-7 w-7";
return "h-7 w-7 mr-2";
}
};

Expand All @@ -45,7 +45,7 @@ const Logo: React.FC<{ size?: "xs" | "sm" | "xl" | "2xl" }> = ({
)}
>
<CommandLineIcon
className={clsx("inset-0 mr-2", getIconClassesBySize() || "")}
className={clsx("inset-0", getIconClassesBySize() || "")}
/>
<span className="inline-flex items-center">
Snippng
Expand Down
11 changes: 11 additions & 0 deletions components/editor/SnippngCodeArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
InformationCircleIcon,
} from "@heroicons/react/24/outline";
import { addDoc, collection, doc, updateDoc } from "firebase/firestore";
import Logo from "../Logo";

const SnippngCodeArea = () => {
const editorRef = useRef<HTMLDivElement>(null); // useRef to persist existing ref. Might be useful when dealing with background image in future
Expand Down Expand Up @@ -63,6 +64,7 @@ const SnippngCodeArea = () => {
uid,
bgImageVisiblePatch,
bgBlur,
watermark,
} = editorConfig;

const saveSnippet = async () => {
Expand Down Expand Up @@ -219,6 +221,15 @@ const SnippngCodeArea = () => {
<SnippngWindowControls type={editorWindowControlsType} />
</div>
</CodeMirror>
{watermark ? (
<div
title="Remove watermark from the settings"
className="absolute bottom-1 text-white drop-shadow-[0_1px_1.2px_rgba(0,0,0,0.8)] opacity-50 right-2 text-[10px] inline-flex items-center"
>
<span className="mr-1">created using</span>{" "}
<Logo size="xs" />
</div>
) : null}
</div>
</div>
<div className="w-full mt-8 flex md:flex-row flex-col gap-4 justify-start items-center">
Expand Down
12 changes: 12 additions & 0 deletions components/editor/SnippngControlHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ const SnippngControlHeader: React.FC<{
snippetsName,
bgBlur = 0,
bgImageVisiblePatch,
watermark,
} = editorConfig;

const downloadImage = (type: SelectOptionInterface) => {
Expand Down Expand Up @@ -223,6 +224,17 @@ const SnippngControlHeader: React.FC<{
<ArrowsUpDownIcon className="h-5 w-5 mr-2" /> Import or export
config
</Menu.Button>
<div className="py-1 px-2">
<Checkbox
label="Watermark"
id="watermark"
data-testid="watermark"
checked={watermark}
onChange={() => {
handleConfigChange("watermark")(!watermark);
}}
/>
</div>
<div className="py-1 px-2">
<Checkbox
label="Line count"
Expand Down
1 change: 1 addition & 0 deletions lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,7 @@ const getConfig = (): SnippngEditorConfigInterface => {
editorWidth: 0,
bgImageVisiblePatch: null,
bgBlur: 0,
watermark: true,
};
};

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "snippng",
"version": "1.2.0",
"version": "1.2.2",
"private": true,
"scripts": {
"dev": "next dev",
Expand Down
1 change: 1 addition & 0 deletions types/editor-ti.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const SnippngWindowControlsType = t.union(t.lit("mac-left"), t.lit("mac-r
export const SnippngEditorConfigInterface = t.iface([], {
"ownerUid": t.opt("string"),
"uid": t.opt("string"),
"watermark": t.opt("boolean"),
"code": "string",
"editorFontSize": "number",
"editorWidth": "number",
Expand Down
6 changes: 5 additions & 1 deletion types/editor.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { SelectOptionInterface } from "./tsx";
export interface SelectOptionInterface {
id: string;
label: string;
}

export type SnippngWindowControlsType =
| "mac-left"
Expand All @@ -9,6 +12,7 @@ export type SnippngWindowControlsType =
export interface SnippngEditorConfigInterface {
ownerUid?: string;
uid?: string;
watermark?: boolean;
code: string;
editorFontSize: number;
editorWidth: number;
Expand Down
1 change: 0 additions & 1 deletion types/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import exportedTypeSuite from "./editor-ti";

export * from "./tsx";
export * from "./editor";
export * from "./toast";

Expand Down
4 changes: 0 additions & 4 deletions types/tsx.ts

This file was deleted.