From 771248be35ff9b0ea3934394c843ca93da5f51f5 Mon Sep 17 00:00:00 2001 From: Tanishq Dubey Date: Mon, 9 Sep 2024 18:08:56 -0400 Subject: [PATCH] Build success --- app/components/ColorSchemeCard.tsx | 11 ++++++-- app/components/HelpDialog.tsx | 4 +-- app/components/HistoryPopup.tsx | 4 +-- app/components/Settings.tsx | 9 ++++-- app/page.tsx | 44 ++++++++++++------------------ app/utils/colorSchemes.ts | 14 +++++----- app/utils/types.ts | 1 + 7 files changed, 43 insertions(+), 44 deletions(-) create mode 100644 app/utils/types.ts diff --git a/app/components/ColorSchemeCard.tsx b/app/components/ColorSchemeCard.tsx index caaf4fd..958d4b1 100644 --- a/app/components/ColorSchemeCard.tsx +++ b/app/components/ColorSchemeCard.tsx @@ -212,7 +212,14 @@ else fi` }; - return samples[codeSample] || samples.javascript; + type SampleLanguage = keyof typeof samples; + + // Type guard to check if codeSample is a valid key of samples + const isValidSample = (sample: string): sample is SampleLanguage => { + return sample in samples; + }; + + return isValidSample(codeSample) ? samples[codeSample] : samples.javascript; }; const handleDownload = (e: React.MouseEvent) => { @@ -289,7 +296,7 @@ fi` }} drag="x" dragConstraints={{ left: -50, right: 50 }} - onDragEnd={(e, { offset, velocity }) => { + onDragEnd={(e, { offset }) => { if (offset.x > 50) handleLike(); else if (offset.x < -50) handleDislike(); }} diff --git a/app/components/HelpDialog.tsx b/app/components/HelpDialog.tsx index 5020c32..25cf8b4 100644 --- a/app/components/HelpDialog.tsx +++ b/app/components/HelpDialog.tsx @@ -24,7 +24,7 @@ const HelpDialog: React.FC = ({ isOpen, onClose, isDarkMode })

How it works:

    -
  1. You'll be presented with color schemes one at a time.
  2. +
  3. You'll be presented with color schemes one at a time.
  4. Swipe right or click the heart icon to like a scheme.
  5. Swipe left or click the cross icon to dislike a scheme.
  6. The app learns from your preferences and generates new schemes based on what you like.
  7. @@ -39,7 +39,7 @@ const HelpDialog: React.FC = ({ isOpen, onClose, isDarkMode })

    The more you interact with TerminalTinder, the better it becomes at suggesting color schemes. All information is local, so refreshing the page refreshes learning.

    -

    Made with ❤️ by DWS - It's your internet, take it back.

    +

    It's your internet, take it back.


    All credit for any non generated color schemes goes to their original creators. Color schemes are sourced from Gogh.

    diff --git a/app/components/HistoryPopup.tsx b/app/components/HistoryPopup.tsx index ba17996..a5a3b19 100644 --- a/app/components/HistoryPopup.tsx +++ b/app/components/HistoryPopup.tsx @@ -1,4 +1,4 @@ -import React, { useState } from 'react'; +import React from 'react'; import { ColorScheme } from '../utils/colorSchemes'; import { generateYAML, generateJSON, generateXResources, generateTOML } from '../utils/exportFormats'; import Image from 'next/image'; @@ -13,8 +13,6 @@ interface HistoryPopupProps { } const HistoryPopup: React.FC = ({ likedSchemes, dislikedSchemes, onClose, isDarkMode, outputFormat }) => { - const [copiedColor, setCopiedColor] = useState(null); - const handleDownload = (scheme: ColorScheme) => { let content: string; let fileExtension: string; diff --git a/app/components/Settings.tsx b/app/components/Settings.tsx index 805e46f..353eaef 100644 --- a/app/components/Settings.tsx +++ b/app/components/Settings.tsx @@ -1,6 +1,9 @@ import React, { useState, useEffect } from 'react'; import Image from 'next/image'; +// Import the CodeSample type +import { CodeSample } from '../utils/types'; + interface SettingsProps { isOpen: boolean; onClose: () => void; @@ -8,8 +11,8 @@ interface SettingsProps { onToggleDarkMode: () => void; outputFormat: string; setOutputFormat: (format: string) => void; - codeSample: string; - setCodeSample: (sample: string) => void; + codeSample: CodeSample; + setCodeSample: (sample: CodeSample) => void; saveSettings: boolean; setSaveSettings: (save: boolean) => void; } @@ -91,7 +94,7 @@ const Settings: React.FC = ({