8000 GitHub - bassceo/color-inverter: Simple Color Inverter for Dark Mode
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

bassceo/color-inverter

Repository files navigation

Dark Mode Color Inverter

Table of Contents


Getting Started

Prerequisites

Installation

  1. Clone the repository:
    git clone https://github.com/your-username/vite-vue-typescript-starter.git
  2. Navigate to the project directory:
    cd vite-vue-typescript-starter
  3. Install dependencies:
    npm install
    or
    yarn

Project Scripts

In the project directory, you can run the following scripts:

  • Development Server
    Starts the development server with hot reload on localhost:5173 (by default).

    npm run dev
  • Build
    Type checks the project and bundles it for production to the dist folder.

    npm run build
  • Preview
    Serves the production build locally for final testing.

    npm run preview

Project Structure

Below is a simplified view of the key files and directories:

vite-vue-typescript-starter
├─ public/
├─ src/
│  ├─ components/
│  ├─ utils/
│  │  └─ colorTransform.ts       // Contains the `invertHueRotate` function
│  ├─ App.vue
│  └─ main.ts
├─ tsconfig.json                  // TypeScript configuration
├─ vite.config.ts                 // Vite configuration
├─ package.json
└─ README.md                      // This file
  • src/components/ColorInverter.vue (demonstrative name):
    • Showcases a color inversion utility using a color picker from Element Plus.
    • Demonstrates TypeScript usage within the <script setup lang="ts">.
    • Includes error handling and color validation logic.

Usage Example

  1. Run the development server:
    npm run dev
  2. Open your browser and navigate to the provided local URL (e.g., http://localhost:5173).
  3. Color Inverter Demo:
    • Enter or pick a color using the integrated Element Plus color picker.
    • The inverted color for dark mode usage will be displayed on the right.
    • Copy the inverted color to the clipboard with a single click.

Here’s a snippet of the core logic in the color-inverter component:

import { ref, computed } from 'vue'
import { ElMessage } from 'element-plus'
import { invertHueRotate } from '../utils/colorTransform'

const inputColor = ref('#1E90FF')
const outputColor = <
6405
span class="pl-en">computed(() => {
  try {
    return invertHueRotate(inputColor.value)
  } catch (error) {
    ElMessage.error((error as Error).message)
    return '#000000'
  }
})

This showcases how you can write and manage reactive state with Vue 3 and TypeScript.


License

This project is open-sourced under the MIT License. Feel free to use, modify, and distribute it as you wish.


About

Simple Color Inverter for Dark Mode

Resources

Stars

Watchers

Forks

Packages

No packages published
0