-
Notifications
You must be signed in to change notification settings - Fork 64
Update plugin 颜色助手 v1.3.0 #175
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
Open
mekefly
wants to merge
2
commits into
ZToolsCenter:main
Choose a base branch
from
mekefly:plugin/colors
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| { | ||
| "name": "colors", | ||
| "version": "1.2.2", | ||
| "version": "1.3.0", | ||
| "private": true, | ||
| "type": "module", | ||
| "scripts": { | ||
|
|
||
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,19 +1,20 @@ | ||
| <script setup lang="ts"> | ||
| import { useCurrentColor } from "@/utils/current-color"; | ||
|
|
||
| defineProps<{ title?: string }>(); | ||
| const currentColorStore = useCurrentColor(); | ||
| </script> | ||
| <template> | ||
| <div class="col-span-6 space-y-6"> | ||
| <div | ||
| class="rounded-2xl p-6 shadow-lg" | ||
| :style="{ | ||
| backgroundColor: currentColorStore.currentColor.toHex(), | ||
| color: currentColorStore.currentColor.isDark() ? '#FFFFFF' : '#000000', | ||
| }" | ||
| > | ||
| <div class="transition-colors duration-500 ease-in-out"> | ||
| <slot></slot> | ||
| </div> | ||
| <div | ||
| class="flex h-full w-full flex-1 flex-col items-center justify-center rounded-2xl p-6 shadow-lg" | ||
| :style="{ | ||
| backgroundColor: currentColorStore.currentColor.toHex(), | ||
| color: currentColorStore.currentColor.isDark() ? '#FFFFFF' : '#000000', | ||
| }" | ||
| > | ||
| <div class="w-full transition-[color] duration-500 ease-in-out"> | ||
| <h3 v-if="title" class="mb-4 text-lg font-semibold">{{ title }}</h3> | ||
| <slot></slot> | ||
| </div> | ||
| </div> | ||
| </template> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| <script lang="ts" setup> | ||
| import { computed } from "vue"; | ||
| import { useConfigStore } from "@/utils/config"; | ||
| import { useCurrentColor } from "@/utils/current-color"; | ||
| import Select from "./Select.vue"; | ||
|
|
||
| const currentColorStore = useCurrentColor(); | ||
| const config = useConfigStore(); | ||
|
|
||
| // 定义颜色格式选项 | ||
| const colorFormatOptions = [ | ||
| { value: "hex", label: "HEX (#RRGGBB)" }, | ||
| { value: "rgb", label: "RGB (rgb(r, g, b))" }, | ||
| { value: "hsv/hsb", label: "HSV/HSB" }, | ||
| { value: "hsl", label: "HSL (hsl(h, s%, l%))" }, | ||
| { value: "hwb", label: "HWB" }, | ||
| { value: "cmyk", label: "CMYK" }, | ||
| { value: "lab", label: "LAB" }, | ||
| { value: "lch", label: "LCH" }, | ||
| { value: "xyz", label: "XYZ" }, | ||
| ]; | ||
|
|
||
| // 计算样式,保持原有的背景色功能 | ||
| const selectStyle = computed(() => ({ | ||
| background: currentColorStore.currentColor.toHex(), | ||
| })); | ||
| </script> | ||
|
|
||
| <template> | ||
| <Select | ||
| id="colorFormat" | ||
| v-model="config.format" | ||
| :options="colorFormatOptions" | ||
| :style="selectStyle" | ||
| /> | ||
| </template> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| <script lang="ts" setup> | ||
| import { useConfigStore } from "@/utils/config"; | ||
| import { useCurrentColor } from "@/utils/current-color"; | ||
| import ColorFormatSelect from "./ColorFormatSelect.vue"; | ||
| import SettingItem from "./SettingItem.vue"; | ||
| import ToggleButton from "./ToggleButton.vue"; | ||
|
|
||
| const config = useConfigStore(); | ||
| const { currentColor } = useCurrentColor(); | ||
| </script> | ||
| <template> | ||
| <div class="flex flex-col space-y-4"> | ||
| <SettingItem label="色值去 #"> | ||
| <ToggleButton v-model="config.removeHash" /> | ||
| </SettingItem> | ||
|
|
||
| <SettingItem label="复制格式"> | ||
| <ColorFormatSelect /> | ||
| </SettingItem> | ||
| </div> | ||
| </template> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,123 @@ | ||
| <script setup lang="ts"> | ||
| import { Colord, colord } from "colord"; | ||
| import { computed } from "vue"; | ||
| import Slider from "@/components/Slider.vue"; | ||
|
|
||
| interface Props { | ||
| modelValue: Colord; | ||
| } | ||
|
|
||
| const props = defineProps<Props>(); | ||
| const emit = defineEmits(["update:modelValue"]); | ||
|
|
||
| // 计算色相值 (0-360) | ||
| const hue = computed({ | ||
| get: () => { | ||
| const hsl = props.modelValue.toHsl(); | ||
| return hsl.h; | ||
| }, | ||
| set: (value: number) => { | ||
| const hsl = props.modelValue.toHsl(); | ||
| const newColor = colord({ h: value, s: hsl.s, l: hsl.l }); | ||
| emit("update:modelValue", newColor); | ||
| }, | ||
| }); | ||
|
|
||
| // 计算饱和度值 (0-100) | ||
| const saturation = computed({ | ||
| get: () => { | ||
| const hsl = props.modelValue.toHsl(); | ||
| return hsl.s; | ||
| }, | ||
| set: (value: number) => { | ||
| const hsl = props.modelValue.toHsl(); | ||
| const newColor = colord({ h: hsl.h, s: value, l: hsl.l }); | ||
| emit("update:modelValue", newColor); | ||
| }, | ||
| }); | ||
|
|
||
| // 计算亮度值 (0-100) | ||
| const lightness = computed({ | ||
| get: () => { | ||
| const hsl = props.modelValue.toHsl(); | ||
| return hsl.l; | ||
| }, | ||
| set: (value: number) => { | ||
| const hsl = props.modelValue.toHsl(); | ||
| const newColor = colord({ h: hsl.h, s: hsl.s, l: value }); | ||
| emit("update:modelValue", newColor); | ||
| }, | ||
| }); | ||
|
|
||
| // 计算渐变背景 | ||
| const hueGradient = computed(() => { | ||
| const hsl = props.modelValue.toHsl(); | ||
| const colors = [0, 60, 120, 180, 240, 300, 0].map((h) => colord({ ...hsl, h: h }).toHex()); | ||
|
|
||
| return `linear-gradient(to right, ${colors.join(", ")})`; | ||
| }); | ||
|
|
||
| const saturationGradient = computed(() => { | ||
| const hsl = props.modelValue.toHsl(); | ||
| const colors = [0, 100].map((s) => colord({ ...hsl, s }).toHex()); | ||
| return `linear-gradient(to right, ${colors.join(", ")})`; | ||
| }); | ||
|
|
||
| const lightnessGradient = computed(() => { | ||
| const hsl = props.modelValue.toHsl(); | ||
| const colors = [0, 100].map((l) => colord({ ...hsl, l }).toHex()); | ||
| return `linear-gradient(to right, ${colors.join(", ")})`; | ||
| }); | ||
| </script> | ||
|
|
||
| <template> | ||
| <div class="space-y-4"> | ||
| <!-- Hue Slider --> | ||
| <div class="flex items-center space-x-3"> | ||
| <span class="w-8 text-sm font-medium">H</span> | ||
| <div class="flex-1"> | ||
| <Slider | ||
| v-model="hue" | ||
| :min="0" | ||
| :max="360" | ||
| :step="1" | ||
| :background="hueGradient" | ||
| enable-wheel | ||
| /> | ||
| </div> | ||
| <span class="w-10 text-right text-sm">{{ Math.round(hue) }}</span> | ||
| </div> | ||
|
|
||
| <!-- Saturation Slider --> | ||
| <div class="flex items-center space-x-3"> | ||
| <span class="w-8 text-sm font-medium">S</span> | ||
| <div class="flex-1"> | ||
| <Slider | ||
| v-model="saturation" | ||
| :min="0" | ||
| :max="100" | ||
| :step="1" | ||
| :background="saturationGradient" | ||
| enable-wheel | ||
| /> | ||
| </div> | ||
| <span class="w-10 text-right text-sm">{{ Math.round(saturation) }}%</span> | ||
| </div> | ||
|
|
||
| <!-- Lightness Slider --> | ||
| <div class="flex items-center space-x-3"> | ||
| <span class="w-8 text-sm font-medium">L</span> | ||
| <div class="flex-1"> | ||
| <Slider | ||
| v-model="lightness" | ||
| :min="0" | ||
| :max="100" | ||
| :step="1" | ||
| :background="lightnessGradient" | ||
| enable-wheel | ||
| /> | ||
| </div> | ||
| <span class="w-10 text-right text-sm">{{ Math.round(lightness) }}%</span> | ||
| </div> | ||
| </div> | ||
| </template> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.